Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
2593a7cb
Commit
2593a7cb
authored
Nov 07, 2001
by
sasha@mysql.sashanet.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge work:/home/bk/mysql-4.0
into mysql.sashanet.com:/home/sasha/src/bk/mysql-4.0
parents
dd43f32d
c0e55b9d
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
409 additions
and
72 deletions
+409
-72
.bzrignore
.bzrignore
+2
-0
include/my_sys.h
include/my_sys.h
+31
-6
mysql-test/mysql-test-run.sh
mysql-test/mysql-test-run.sh
+24
-3
mysys/Makefile.am
mysys/Makefile.am
+4
-0
mysys/mf_iocache.c
mysys/mf_iocache.c
+240
-43
sql/mysqld.cc
sql/mysqld.cc
+65
-12
sql/sql_repl.cc
sql/sql_repl.cc
+11
-7
tools/mysqlmanager.c
tools/mysqlmanager.c
+32
-1
No files found.
.bzrignore
View file @
2593a7cb
...
@@ -348,8 +348,10 @@ mysql.kdevprj
...
@@ -348,8 +348,10 @@ mysql.kdevprj
mysql.proj
mysql.proj
mysqld.S
mysqld.S
mysqld.sym
mysqld.sym
mysys/#mf_iocache.c#
mysys/test_charset
mysys/test_charset
mysys/test_dir
mysys/test_dir
mysys/test_io_cache
mysys/test_thr_alarm
mysys/test_thr_alarm
mysys/test_thr_lock
mysys/test_thr_lock
mysys/testhash
mysys/testhash
...
...
include/my_sys.h
View file @
2593a7cb
...
@@ -293,6 +293,16 @@ typedef struct st_dynamic_string {
...
@@ -293,6 +293,16 @@ typedef struct st_dynamic_string {
struct
st_io_cache
;
struct
st_io_cache
;
typedef
int
(
*
IO_CACHE_CALLBACK
)(
struct
st_io_cache
*
);
typedef
int
(
*
IO_CACHE_CALLBACK
)(
struct
st_io_cache
*
);
#ifdef THREAD
#define lock_append_buffer(info) \
pthread_mutex_lock(&(info)->append_buffer_lock)
#define unlock_append_buffer(info) \
pthread_mutex_unlock(&(info)->append_buffer_lock)
#else
#define lock_append_buffer(info)
#define unlock_append_buffer(info)
#endif
typedef
struct
st_io_cache
/* Used when cacheing files */
typedef
struct
st_io_cache
/* Used when cacheing files */
{
{
my_off_t
pos_in_file
,
end_of_file
;
my_off_t
pos_in_file
,
end_of_file
;
...
@@ -301,13 +311,15 @@ typedef struct st_io_cache /* Used when cacheing files */
...
@@ -301,13 +311,15 @@ typedef struct st_io_cache /* Used when cacheing files */
that will use a buffer allocated somewhere
that will use a buffer allocated somewhere
else
else
*/
*/
byte
*
append_buffer
,
*
append_pos
,
*
append_end
;
byte
*
append_buffer
,
*
append_read_pos
,
*
write_pos
,
*
append_end
,
*
write_end
;
/* for append buffer used in READ_APPEND cache */
/* for append buffer used in READ_APPEND cache */
#ifdef THREAD
#ifdef THREAD
pthread_mutex_t
append_buffer_lock
;
pthread_mutex_t
append_buffer_lock
;
/* need mutex copying from append buffer to read buffer */
/* need mutex copying from append buffer to read buffer */
#endif
#endif
int
(
*
read_function
)(
struct
st_io_cache
*
,
byte
*
,
uint
);
int
(
*
read_function
)(
struct
st_io_cache
*
,
byte
*
,
uint
);
int
(
*
write_function
)(
struct
st_io_cache
*
,
const
byte
*
,
uint
);
/* callbacks when the actual read I/O happens */
/* callbacks when the actual read I/O happens */
IO_CACHE_CALLBACK
pre_read
;
IO_CACHE_CALLBACK
pre_read
;
IO_CACHE_CALLBACK
post_read
;
IO_CACHE_CALLBACK
post_read
;
...
@@ -342,16 +354,19 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
...
@@ -342,16 +354,19 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
((info)->rc_pos+=(Count)),0) :\
((info)->rc_pos+=(Count)),0) :\
(*(info)->read_function)((info),Buffer,Count))
(*(info)->read_function)((info),Buffer,Count))
#define my_b_write(info,Buffer,Count) \
((info)->write_pos + (Count) <=(info)->write_end ?\
(memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
((info)->write_pos+=(Count)),0) : \
(*(info)->write_function)((info),(Buffer),(Count)))
#define my_b_get(info) \
#define my_b_get(info) \
((info)->rc_pos != (info)->rc_end ?\
((info)->rc_pos != (info)->rc_end ?\
((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
_my_b_get(info))
_my_b_get(info))
#define my_b_write(info,Buffer,Count) \
((info)->rc_pos + (Count) <= (info)->rc_end ?\
(memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \
((info)->rc_pos+=(Count)),0) :\
_my_b_write(info,Buffer,Count))
/* my_b_write_byte dosn't have any err-check */
/* my_b_write_byte dosn't have any err-check */
#define my_b_write_byte(info,chr) \
#define my_b_write_byte(info,chr) \
...
@@ -564,6 +579,7 @@ extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
...
@@ -564,6 +579,7 @@ extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
extern
int
_my_b_get
(
IO_CACHE
*
info
);
extern
int
_my_b_get
(
IO_CACHE
*
info
);
extern
int
_my_b_async_read
(
IO_CACHE
*
info
,
byte
*
Buffer
,
uint
Count
);
extern
int
_my_b_async_read
(
IO_CACHE
*
info
,
byte
*
Buffer
,
uint
Count
);
extern
int
_my_b_write
(
IO_CACHE
*
info
,
const
byte
*
Buffer
,
uint
Count
);
extern
int
_my_b_write
(
IO_CACHE
*
info
,
const
byte
*
Buffer
,
uint
Count
);
extern
int
_my_b_append
(
IO_CACHE
*
info
,
const
byte
*
Buffer
,
uint
Count
);
extern
int
my_block_write
(
IO_CACHE
*
info
,
const
byte
*
Buffer
,
extern
int
my_block_write
(
IO_CACHE
*
info
,
const
byte
*
Buffer
,
uint
Count
,
my_off_t
pos
);
uint
Count
,
my_off_t
pos
);
extern
int
flush_io_cache
(
IO_CACHE
*
info
);
extern
int
flush_io_cache
(
IO_CACHE
*
info
);
...
@@ -634,6 +650,7 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
...
@@ -634,6 +650,7 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
ulong
checksum
(
const
byte
*
mem
,
uint
count
);
ulong
checksum
(
const
byte
*
mem
,
uint
count
);
uint
my_bit_log2
(
ulong
value
);
uint
my_bit_log2
(
ulong
value
);
#if defined(_MSC_VER) && !defined(__WIN__)
#if defined(_MSC_VER) && !defined(__WIN__)
extern
void
sleep
(
int
sec
);
extern
void
sleep
(
int
sec
);
#endif
#endif
...
@@ -646,3 +663,11 @@ extern my_bool have_tcpip; /* Is set if tcpip is used */
...
@@ -646,3 +663,11 @@ extern my_bool have_tcpip; /* Is set if tcpip is used */
#endif
#endif
#include "raid.h"
#include "raid.h"
#endif
/* _my_sys_h */
#endif
/* _my_sys_h */
mysql-test/mysql-test-run.sh
View file @
2593a7cb
...
@@ -164,7 +164,10 @@ while test $# -gt 0; do
...
@@ -164,7 +164,10 @@ while test $# -gt 0; do
--ssl-cert=
$BASEDIR
/SSL/server-cert.pem
\
--ssl-cert=
$BASEDIR
/SSL/server-cert.pem
\
--ssl-key=
$BASEDIR
/SSL/server-key.pem"
;;
--ssl-key=
$BASEDIR
/SSL/server-key.pem"
;;
--no-manager
|
--skip-manager
)
USE_MANAGER
=
0
;;
--no-manager
|
--skip-manager
)
USE_MANAGER
=
0
;;
--manager
)
USE_MANAGER
=
1
;;
--manager
)
USE_MANAGER
=
1
USE_RUNNING_SERVER
=
;;
--skip-innobase
)
--skip-innobase
)
EXTRA_MASTER_MYSQLD_OPT
=
"
$EXTRA_MASTER_MYSQLD_OPT
--skip-innobase"
EXTRA_MASTER_MYSQLD_OPT
=
"
$EXTRA_MASTER_MYSQLD_OPT
--skip-innobase"
EXTRA_SLAVE_MYSQLD_OPT
=
"
$EXTRA_SLAVE_MYSQLD_OPT
--skip-innobase"
;;
EXTRA_SLAVE_MYSQLD_OPT
=
"
$EXTRA_SLAVE_MYSQLD_OPT
--skip-innobase"
;;
...
@@ -210,6 +213,7 @@ while test $# -gt 0; do
...
@@ -210,6 +213,7 @@ while test $# -gt 0; do
--gdb
)
--gdb
)
START_WAIT_TIMEOUT
=
300
START_WAIT_TIMEOUT
=
300
STOP_WAIT_TIMEOUT
=
300
STOP_WAIT_TIMEOUT
=
300
USE_MANAGER
=
1
if
[
x
$BINARY_DIST
=
x1
]
;
then
if
[
x
$BINARY_DIST
=
x1
]
;
then
$ECHO
"Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --gdb option"
$ECHO
"Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --gdb option"
fi
fi
...
@@ -255,6 +259,8 @@ done
...
@@ -255,6 +259,8 @@ done
#--
#--
MYRUN_DIR
=
$MYSQL_TEST_DIR
/var/run
MYRUN_DIR
=
$MYSQL_TEST_DIR
/var/run
MANAGER_PID_FILE
=
"
$MYRUN_DIR
/manager.pid"
MASTER_MYDDIR
=
"
$MYSQL_TEST_DIR
/var/master-data"
MASTER_MYDDIR
=
"
$MYSQL_TEST_DIR
/var/master-data"
MASTER_MYSOCK
=
"
$MYSQL_TMP_DIR
/master.sock"
MASTER_MYSOCK
=
"
$MYSQL_TMP_DIR
/master.sock"
MASTER_MYPID
=
"
$MYRUN_DIR
/mysqld.pid"
MASTER_MYPID
=
"
$MYRUN_DIR
/mysqld.pid"
...
@@ -549,10 +555,20 @@ start_manager()
...
@@ -549,10 +555,20 @@ start_manager()
return
return
fi
fi
$ECHO
"Starting MySQL Manager"
$ECHO
"Starting MySQL Manager"
if
[
-f
"
$MANAGER_PID_FILE
"
]
;
then
kill
`
cat
$MANAGER_PID_FILE
`
sleep
1
if
[
-f
"
$MANAGER_PID_FILE
"
]
;
then
kill
-9
`
cat
$MANAGER_PID_FILE
`
sleep
1
fi
fi
rm
-f
$MANAGER_PID_FILE
MYSQL_MANAGER_PW
=
`
$MYSQL_MANAGER_PWGEN
-u
$MYSQL_MANAGER_USER
\
MYSQL_MANAGER_PW
=
`
$MYSQL_MANAGER_PWGEN
-u
$MYSQL_MANAGER_USER
\
-o
$MYSQL_MANAGER_PW_FILE
`
-o
$MYSQL_MANAGER_PW_FILE
`
$MYSQL_MANAGER
--log
=
$MYSQL_MANAGER_LOG
--port
=
$MYSQL_MANAGER_PORT
\
$MYSQL_MANAGER
--log
=
$MYSQL_MANAGER_LOG
--port
=
$MYSQL_MANAGER_PORT
\
--password-file
=
$MYSQL_MANAGER_PW_FILE
--password-file
=
$MYSQL_MANAGER_PW_FILE
--pid-file
=
$MANAGER_PID_FILE
abort_if_failed
"Could not start MySQL manager"
abort_if_failed
"Could not start MySQL manager"
mysqltest_manager_args
=
"--manager-host=localhost
\
mysqltest_manager_args
=
"--manager-host=localhost
\
--manager-user=
$MYSQL_MANAGER_USER
\
--manager-user=
$MYSQL_MANAGER_USER
\
...
@@ -561,7 +577,10 @@ start_manager()
...
@@ -561,7 +577,10 @@ start_manager()
--manager-wait-timeout=
$START_WAIT_TIMEOUT
"
--manager-wait-timeout=
$START_WAIT_TIMEOUT
"
MYSQL_TEST
=
"
$MYSQL_TEST
$mysqltest_manager_args
"
MYSQL_TEST
=
"
$MYSQL_TEST
$mysqltest_manager_args
"
MYSQL_TEST_ARGS
=
"
$MYSQL_TEST_ARGS
$mysqltest_manager_args
"
MYSQL_TEST_ARGS
=
"
$MYSQL_TEST_ARGS
$mysqltest_manager_args
"
while
[
!
-f
$MANAGER_PID_FILE
]
;
do
sleep
1
done
echo
"Manager started"
}
}
stop_manager
()
stop_manager
()
...
@@ -573,6 +592,8 @@ stop_manager()
...
@@ -573,6 +592,8 @@ stop_manager()
-p
$MYSQL_MANAGER_PW
-P
$MYSQL_MANAGER_PORT
<<
EOF
-p
$MYSQL_MANAGER_PW
-P
$MYSQL_MANAGER_PORT
<<
EOF
shutdown
shutdown
EOF
EOF
echo
"Manager terminated"
}
}
manager_launch
()
manager_launch
()
...
...
mysys/Makefile.am
View file @
2593a7cb
...
@@ -95,6 +95,10 @@ test_vsnprintf: my_vsnprintf.c $(LIBRARIES)
...
@@ -95,6 +95,10 @@ test_vsnprintf: my_vsnprintf.c $(LIBRARIES)
$(CP)
$(srcdir)
/my_vsnprintf.c test_vsnprintf.c
$(CP)
$(srcdir)
/my_vsnprintf.c test_vsnprintf.c
$(LINK)
$(FLAGS)
-DMAIN
./test_vsnprintf.c
$(LDADD)
$(LIBS)
$(LINK)
$(FLAGS)
-DMAIN
./test_vsnprintf.c
$(LDADD)
$(LIBS)
$(RM)
-f
test_vsnprintf.
*
$(RM)
-f
test_vsnprintf.
*
test_io_cache
:
mf_iocache.c $(LIBRARIES)
$(CP)
$(srcdir)
/mf_iocache.c test_io_cache.c
$(LINK)
$(FLAGS)
-DMAIN
./test_io_cache.c
$(LDADD)
$(LIBS)
$(RM)
-f
test_io_cache.
*
test_dir
:
test_dir.c $(LIBRARIES)
test_dir
:
test_dir.c $(LIBRARIES)
$(LINK)
$(FLAGS)
-DMAIN
$(srcdir)
/test_dir.c
$(LDADD)
$(LIBS)
$(LINK)
$(FLAGS)
-DMAIN
$(srcdir)
/test_dir.c
$(LDADD)
$(LIBS)
...
...
mysys/mf_iocache.c
View file @
2593a7cb
This diff is collapsed.
Click to expand it.
sql/mysqld.cc
View file @
2593a7cb
...
@@ -45,6 +45,11 @@
...
@@ -45,6 +45,11 @@
char
pstack_file_name
[
80
];
char
pstack_file_name
[
80
];
#endif
/* __linux__ */
#endif
/* __linux__ */
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ)
#define HAVE_CLOSE_SERVER_SOCK 1
void
close_server_sock
();
#endif
extern
"C"
{
// Because of SCO 3.2V4.2
extern
"C"
{
// Because of SCO 3.2V4.2
#include <errno.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/stat.h>
...
@@ -453,16 +458,7 @@ static void close_connections(void)
...
@@ -453,16 +458,7 @@ static void close_connections(void)
sql_print_error
(
"Got error %d from pthread_cond_timedwait"
,
error
);
sql_print_error
(
"Got error %d from pthread_cond_timedwait"
,
error
);
#endif
#endif
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ)
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ)
if
(
ip_sock
!=
INVALID_SOCKET
)
close_server_sock
();
{
DBUG_PRINT
(
"error"
,(
"closing TCP/IP and socket files"
));
VOID
(
shutdown
(
ip_sock
,
2
));
VOID
(
closesocket
(
ip_sock
));
VOID
(
shutdown
(
unix_sock
,
2
));
VOID
(
closesocket
(
unix_sock
));
VOID
(
unlink
(
mysql_unix_port
));
ip_sock
=
unix_sock
=
INVALID_SOCKET
;
}
#endif
#endif
}
}
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
...
@@ -577,10 +573,37 @@ static void close_connections(void)
...
@@ -577,10 +573,37 @@ static void close_connections(void)
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
#ifdef HAVE_CLOSE_SERVER_SOCK
void
close_server_sock
()
{
DBUG_ENTER
(
"close_server_sock"
);
if
(
ip_sock
!=
INVALID_SOCKET
)
{
DBUG_PRINT
(
"info"
,(
"closing TCP/IP socket"
));
VOID
(
shutdown
(
ip_sock
,
2
));
VOID
(
closesocket
(
ip_sock
));
ip_sock
=
INVALID_SOCKET
;
}
if
(
unix_sock
!=
INVALID_SOCKET
)
{
DBUG_PRINT
(
"info"
,(
"closing Unix socket"
));
VOID
(
shutdown
(
unix_sock
,
2
));
VOID
(
closesocket
(
unix_sock
));
VOID
(
unlink
(
mysql_unix_port
));
unix_sock
=
INVALID_SOCKET
;
}
DBUG_VOID_RETURN
;
}
#endif
void
kill_mysql
(
void
)
void
kill_mysql
(
void
)
{
{
DBUG_ENTER
(
"kill_mysql"
);
DBUG_ENTER
(
"kill_mysql"
);
#ifdef SIGNALS_DONT_BREAK_READ
close_server_sock
();
/* force accept to wake up */
#endif
#if defined(__WIN__)
#if defined(__WIN__)
{
{
if
(
!
SetEvent
(
hEventShutdown
))
if
(
!
SetEvent
(
hEventShutdown
))
...
@@ -604,6 +627,7 @@ void kill_mysql(void)
...
@@ -604,6 +627,7 @@ void kill_mysql(void)
#endif
#endif
DBUG_PRINT
(
"quit"
,(
"After pthread_kill"
));
DBUG_PRINT
(
"quit"
,(
"After pthread_kill"
));
shutdown_in_progress
=
1
;
// Safety if kill didn't work
shutdown_in_progress
=
1
;
// Safety if kill didn't work
abort_loop
=
1
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -683,9 +707,11 @@ void unireg_end(int signal_number __attribute__((unused)))
...
@@ -683,9 +707,11 @@ void unireg_end(int signal_number __attribute__((unused)))
void
unireg_abort
(
int
exit_code
)
void
unireg_abort
(
int
exit_code
)
{
{
DBUG_ENTER
(
"unireg_abort"
);
if
(
exit_code
)
if
(
exit_code
)
sql_print_error
(
"Aborting
\n
"
);
sql_print_error
(
"Aborting
\n
"
);
clean_up
();
/* purecov: inspected */
clean_up
();
/* purecov: inspected */
DBUG_PRINT
(
"quit"
,(
"done with cleanup in unireg_abort"
));
my_thread_end
();
my_thread_end
();
exit
(
exit_code
);
/* purecov: inspected */
exit
(
exit_code
);
/* purecov: inspected */
}
}
...
@@ -736,13 +762,15 @@ void clean_up(bool print_message)
...
@@ -736,13 +762,15 @@ void clean_up(bool print_message)
if
(
print_message
&&
errmesg
)
if
(
print_message
&&
errmesg
)
sql_print_error
(
ER
(
ER_SHUTDOWN_COMPLETE
),
my_progname
);
sql_print_error
(
ER
(
ER_SHUTDOWN_COMPLETE
),
my_progname
);
x_free
((
gptr
)
my_errmsg
[
ERRMAPP
]);
/* Free messages */
x_free
((
gptr
)
my_errmsg
[
ERRMAPP
]);
/* Free messages */
DBUG_PRINT
(
"quit"
,
(
"Error messages freed"
));
/* Tell main we are ready */
/* Tell main we are ready */
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
DBUG_PRINT
(
"quit"
,
(
"got thread count lock"
));
ready_to_exit
=
1
;
ready_to_exit
=
1
;
/* do the broadcast inside the lock to ensure that my_end() is not called */
/* do the broadcast inside the lock to ensure that my_end() is not called */
(
void
)
pthread_cond_broadcast
(
&
COND_thread_count
);
(
void
)
pthread_cond_broadcast
(
&
COND_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
DBUG_PRINT
(
"quit"
,
(
"done with cleanup"
));
}
/* clean_up */
}
/* clean_up */
...
@@ -2023,6 +2051,7 @@ The server will not act as a slave.");
...
@@ -2023,6 +2051,7 @@ The server will not act as a slave.");
sql_print_error
(
"Before Lock_thread_count"
);
sql_print_error
(
"Before Lock_thread_count"
);
#endif
#endif
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
DBUG_PRINT
(
"quit"
,
(
"Got thread_count mutex"
));
select_thread_in_use
=
0
;
// For close_connections
select_thread_in_use
=
0
;
// For close_connections
(
void
)
pthread_cond_broadcast
(
&
COND_thread_count
);
(
void
)
pthread_cond_broadcast
(
&
COND_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
...
@@ -2054,10 +2083,14 @@ The server will not act as a slave.");
...
@@ -2054,10 +2083,14 @@ The server will not act as a slave.");
#endif
/* HAVE_OPENSSL */
#endif
/* HAVE_OPENSSL */
/* Wait until cleanup is done */
/* Wait until cleanup is done */
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_lock
(
&
LOCK_thread_count
);
DBUG_PRINT
(
"quit"
,
(
"Got thread_count mutex for clean up wait"
));
while
(
!
ready_to_exit
)
while
(
!
ready_to_exit
)
{
{
DBUG_PRINT
(
"quit"
,
(
"not yet ready to exit"
));
pthread_cond_wait
(
&
COND_thread_count
,
&
LOCK_thread_count
);
pthread_cond_wait
(
&
COND_thread_count
,
&
LOCK_thread_count
);
}
}
DBUG_PRINT
(
"quit"
,
(
"ready to exit"
));
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
(
void
)
pthread_mutex_unlock
(
&
LOCK_thread_count
);
my_end
(
opt_endinfo
?
MY_CHECK_ERROR
|
MY_GIVE_INFO
:
0
);
my_end
(
opt_endinfo
?
MY_CHECK_ERROR
|
MY_GIVE_INFO
:
0
);
exit
(
0
);
exit
(
0
);
...
@@ -2257,6 +2290,20 @@ static void create_new_thread(THD *thd)
...
@@ -2257,6 +2290,20 @@ static void create_new_thread(THD *thd)
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
#ifdef SIGNALS_DONT_BREAK_READ
inline
void
kill_broken_server
()
{
/* hack to get around signals ignored in syscalls for problem OS's */
if
(
unix_sock
==
INVALID_SOCKET
||
ip_sock
==
INVALID_SOCKET
)
{
select_thread_in_use
=
0
;
kill_server
((
void
*
)
MYSQL_KILL_SIGNAL
);
/* never returns */
}
}
#define MAYBE_BROKEN_SYSCALL kill_broken_server();
#else
#define MAYBE_BROKEN_SYSCALL
#endif
/* Handle new connections and spawn new process to handle them */
/* Handle new connections and spawn new process to handle them */
...
@@ -2292,6 +2339,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
...
@@ -2292,6 +2339,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
#endif
#endif
DBUG_PRINT
(
"general"
,(
"Waiting for connections."
));
DBUG_PRINT
(
"general"
,(
"Waiting for connections."
));
MAYBE_BROKEN_SYSCALL
;
while
(
!
abort_loop
)
while
(
!
abort_loop
)
{
{
readFDs
=
clientFDs
;
readFDs
=
clientFDs
;
...
@@ -2306,12 +2354,15 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
...
@@ -2306,12 +2354,15 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
if
(
!
select_errors
++
&&
!
abort_loop
)
/* purecov: inspected */
if
(
!
select_errors
++
&&
!
abort_loop
)
/* purecov: inspected */
sql_print_error
(
"mysqld: Got error %d from select"
,
socket_errno
);
/* purecov: inspected */
sql_print_error
(
"mysqld: Got error %d from select"
,
socket_errno
);
/* purecov: inspected */
}
}
MAYBE_BROKEN_SYSCALL
continue
;
continue
;
}
}
#endif
/* HPUX */
#endif
/* HPUX */
if
(
abort_loop
)
if
(
abort_loop
)
{
MAYBE_BROKEN_SYSCALL
;
break
;
break
;
}
/*
/*
** Is this a new connection request
** Is this a new connection request
*/
*/
...
@@ -2347,6 +2398,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
...
@@ -2347,6 +2398,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
if
(
new_sock
!=
INVALID_SOCKET
||
if
(
new_sock
!=
INVALID_SOCKET
||
(
socket_errno
!=
SOCKET_EINTR
&&
socket_errno
!=
SOCKET_EAGAIN
))
(
socket_errno
!=
SOCKET_EINTR
&&
socket_errno
!=
SOCKET_EAGAIN
))
break
;
break
;
MAYBE_BROKEN_SYSCALL
;
#if !defined(NO_FCNTL_NONBLOCK)
#if !defined(NO_FCNTL_NONBLOCK)
if
(
!
(
test_flags
&
TEST_BLOCKING
))
if
(
!
(
test_flags
&
TEST_BLOCKING
))
{
{
...
@@ -2363,6 +2415,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
...
@@ -2363,6 +2415,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
{
{
if
((
error_count
++
&
255
)
==
0
)
// This can happen often
if
((
error_count
++
&
255
)
==
0
)
// This can happen often
sql_perror
(
"Error in accept"
);
sql_perror
(
"Error in accept"
);
MAYBE_BROKEN_SYSCALL
;
if
(
socket_errno
==
SOCKET_ENFILE
||
socket_errno
==
SOCKET_EMFILE
)
if
(
socket_errno
==
SOCKET_ENFILE
||
socket_errno
==
SOCKET_EMFILE
)
sleep
(
1
);
// Give other threads some time
sleep
(
1
);
// Give other threads some time
continue
;
continue
;
...
...
sql/sql_repl.cc
View file @
2593a7cb
...
@@ -38,6 +38,13 @@ bool opt_sporadic_binlog_dump_fail = 0;
...
@@ -38,6 +38,13 @@ bool opt_sporadic_binlog_dump_fail = 0;
static
int
binlog_dump_count
=
0
;
static
int
binlog_dump_count
=
0
;
#endif
#endif
#ifdef SIGNAL_WITH_VIO_CLOSE
#define KICK_SLAVE { slave_thd->close_active_vio(); \
thr_alarm_kill(slave_real_id); }
#else
#define KICK_SLAVE thr_alarm_kill(slave_real_id);
#endif
static
Slave_log_event
*
find_slave_event
(
IO_CACHE
*
log
,
static
Slave_log_event
*
find_slave_event
(
IO_CACHE
*
log
,
const
char
*
log_file_name
,
const
char
*
log_file_name
,
char
*
errmsg
);
char
*
errmsg
);
...
@@ -700,10 +707,7 @@ int stop_slave(THD* thd, bool net_report )
...
@@ -700,10 +707,7 @@ int stop_slave(THD* thd, bool net_report )
if
(
slave_running
)
if
(
slave_running
)
{
{
abort_slave
=
1
;
abort_slave
=
1
;
thr_alarm_kill
(
slave_real_id
);
KICK_SLAVE
;
#ifdef SIGNAL_WITH_VIO_CLOSE
slave_thd
->
close_active_vio
();
#endif
// do not abort the slave in the middle of a query, so we do not set
// do not abort the slave in the middle of a query, so we do not set
// thd->killed for the slave thread
// thd->killed for the slave thread
thd
->
proc_info
=
"waiting for slave to die"
;
thd
->
proc_info
=
"waiting for slave to die"
;
...
@@ -728,7 +732,7 @@ int stop_slave(THD* thd, bool net_report )
...
@@ -728,7 +732,7 @@ int stop_slave(THD* thd, bool net_report )
#endif
#endif
pthread_cond_timedwait
(
&
COND_slave_stopped
,
&
LOCK_slave
,
&
abstime
);
pthread_cond_timedwait
(
&
COND_slave_stopped
,
&
LOCK_slave
,
&
abstime
);
if
(
slave_running
)
if
(
slave_running
)
thr_alarm_kill
(
slave_real_id
)
;
KICK_SLAVE
;
}
}
}
}
else
else
...
@@ -818,7 +822,7 @@ int change_master(THD* thd)
...
@@ -818,7 +822,7 @@ int change_master(THD* thd)
if
((
slave_was_running
=
slave_running
))
if
((
slave_was_running
=
slave_running
))
{
{
abort_slave
=
1
;
abort_slave
=
1
;
thr_alarm_kill
(
slave_real_id
)
;
KICK_SLAVE
;
thd
->
proc_info
=
"waiting for slave to die"
;
thd
->
proc_info
=
"waiting for slave to die"
;
while
(
slave_running
)
while
(
slave_running
)
pthread_cond_wait
(
&
COND_slave_stopped
,
&
LOCK_slave
);
// wait until done
pthread_cond_wait
(
&
COND_slave_stopped
,
&
LOCK_slave
);
// wait until done
...
@@ -1470,7 +1474,7 @@ int load_master_data(THD* thd)
...
@@ -1470,7 +1474,7 @@ int load_master_data(THD* thd)
if
((
slave_was_running
=
slave_running
))
if
((
slave_was_running
=
slave_running
))
{
{
abort_slave
=
1
;
abort_slave
=
1
;
thr_alarm_kill
(
slave_real_id
)
;
KICK_SLAVE
;
thd
->
proc_info
=
"waiting for slave to die"
;
thd
->
proc_info
=
"waiting for slave to die"
;
while
(
slave_running
)
while
(
slave_running
)
pthread_cond_wait
(
&
COND_slave_stopped
,
&
LOCK_slave
);
// wait until done
pthread_cond_wait
(
&
COND_slave_stopped
,
&
LOCK_slave
);
// wait until done
...
...
tools/mysqlmanager.c
View file @
2593a7cb
...
@@ -189,6 +189,8 @@ static void run_launcher_loop();
...
@@ -189,6 +189,8 @@ static void run_launcher_loop();
int
to_launcher_pipe
[
2
],
from_launcher_pipe
[
2
];
int
to_launcher_pipe
[
2
],
from_launcher_pipe
[
2
];
pid_t
launcher_pid
;
pid_t
launcher_pid
;
int
in_segfault
=
0
;
int
in_segfault
=
0
;
const
char
*
pid_file
=
"/var/run/mysqlmanager.pid"
;
int
created_pid_file
=
0
;
struct
manager_cmd
struct
manager_cmd
{
{
...
@@ -283,6 +285,7 @@ struct option long_options[] =
...
@@ -283,6 +285,7 @@ struct option long_options[] =
{
"one-thread"
,
no_argument
,
0
,
'd'
},
{
"one-thread"
,
no_argument
,
0
,
'd'
},
{
"connect-retries"
,
required_argument
,
0
,
'C'
},
{
"connect-retries"
,
required_argument
,
0
,
'C'
},
{
"password-file"
,
required_argument
,
0
,
'p'
},
{
"password-file"
,
required_argument
,
0
,
'p'
},
{
"pid-file"
,
required_argument
,
0
,
'f'
},
{
"version"
,
no_argument
,
0
,
'V'
},
{
"version"
,
no_argument
,
0
,
'V'
},
{
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
}
};
};
...
@@ -327,6 +330,17 @@ LOG_MSG_FUNC(log_debug,LOG_DEBUG)
...
@@ -327,6 +330,17 @@ LOG_MSG_FUNC(log_debug,LOG_DEBUG)
void
log_debug
(
const
char
*
__attribute__
((
unused
))
fmt
,...)
{}
void
log_debug
(
const
char
*
__attribute__
((
unused
))
fmt
,...)
{}
#endif
#endif
static
void
handle_sigterm
(
int
sig
)
{
log_info
(
"Got SIGTERM"
);
if
(
!
one_thread
)
{
kill
(
launcher_pid
,
SIGTERM
);
pthread_kill
(
loop_th
,
SIGTERM
);
}
clean_up
();
exit
(
0
);
}
static
void
handle_segfault
(
int
sig
)
static
void
handle_segfault
(
int
sig
)
{
{
...
@@ -1250,6 +1264,8 @@ static void clean_up()
...
@@ -1250,6 +1264,8 @@ static void clean_up()
if
(
errfp
!=
stderr
)
if
(
errfp
!=
stderr
)
fclose
(
errfp
);
fclose
(
errfp
);
hash_free
(
&
exec_hash
);
hash_free
(
&
exec_hash
);
if
(
created_pid_file
)
my_delete
(
pid_file
,
MYF
(
0
));
}
}
static
void
print_version
(
void
)
static
void
print_version
(
void
)
...
@@ -1287,7 +1303,7 @@ static void usage()
...
@@ -1287,7 +1303,7 @@ static void usage()
static
int
parse_args
(
int
argc
,
char
**
argv
)
static
int
parse_args
(
int
argc
,
char
**
argv
)
{
{
int
c
,
option_index
=
0
;
int
c
,
option_index
=
0
;
while
((
c
=
getopt_long
(
argc
,
argv
,
"P:?#:Vl:b:B:g:m:dC:p:"
,
while
((
c
=
getopt_long
(
argc
,
argv
,
"P:?#:Vl:b:B:g:m:dC:p:
f:
"
,
long_options
,
&
option_index
))
!=
EOF
)
long_options
,
&
option_index
))
!=
EOF
)
{
{
switch
(
c
)
switch
(
c
)
...
@@ -1301,6 +1317,9 @@ static int parse_args(int argc, char **argv)
...
@@ -1301,6 +1317,9 @@ static int parse_args(int argc, char **argv)
case
'p'
:
case
'p'
:
manager_pw_file
=
optarg
;
manager_pw_file
=
optarg
;
break
;
break
;
case
'f'
:
pid_file
=
optarg
;
break
;
case
'C'
:
case
'C'
:
manager_connect_retries
=
atoi
(
optarg
);
manager_connect_retries
=
atoi
(
optarg
);
break
;
break
;
...
@@ -1662,6 +1681,16 @@ static void init_user_hash()
...
@@ -1662,6 +1681,16 @@ static void init_user_hash()
fclose
(
f
);
fclose
(
f
);
}
}
static
void
init_pid_file
()
{
FILE
*
fp
=
fopen
(
pid_file
,
"w"
);
if
(
!
fp
)
die
(
"Could not open pid file %s"
,
pid_file
);
created_pid_file
=
1
;
fprintf
(
fp
,
"%d
\n
"
,
getpid
());
fclose
(
fp
);
}
static
void
init_globals
()
static
void
init_globals
()
{
{
pthread_attr_t
thr_attr
;
pthread_attr_t
thr_attr
;
...
@@ -1680,8 +1709,10 @@ static void init_globals()
...
@@ -1680,8 +1709,10 @@ static void init_globals()
/* (void) pthread_attr_destroy(&thr_attr); */
/* (void) pthread_attr_destroy(&thr_attr); */
}
}
init_user_hash
();
init_user_hash
();
init_pid_file
();
loop_th
=
pthread_self
();
loop_th
=
pthread_self
();
signal
(
SIGPIPE
,
handle_sigpipe
);
signal
(
SIGPIPE
,
handle_sigpipe
);
signal
(
SIGTERM
,
handle_sigterm
);
}
}
static
int
open_and_dup
(
int
fd
,
char
*
path
)
static
int
open_and_dup
(
int
fd
,
char
*
path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment