summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-11-03 16:54:00 -0700
committerunknown <sasha@mysql.sashanet.com>2001-11-03 16:54:00 -0700
commitcd825a19936d26735db0c1b4b251bd78617d0c2b (patch)
tree8abf01e56458b77f0e836d8f72481d71cc846b68 /sql
parent368c6c1f30f44d1d028022a06dbcb9754815ee92 (diff)
downloadmariadb-git-cd825a19936d26735db0c1b4b251bd78617d0c2b.tar.gz
more work on IO_CACHE
portability fixes for systems with broken syscalls that do not interrupt on a signal temporary commit - will not be pushed, need to sync up include/my_sys.h: work on READ_APPEND cache mysys/Makefile.am: change to test IO_CACHE mysys/mf_iocache.c: work on READ_APPEND cache BitKeeper/etc/ignore: Added mysys/#mf_iocache.c# mysys/test_io_cache to the ignore list sql/mysqld.cc: make shutdown work on broken systems sql/sql_repl.cc: make sure slave can be stopped on broken systems in all cases, clean-up
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc71
-rw-r--r--sql/sql_repl.cc18
2 files changed, 71 insertions, 18 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9a87acb5596..f92d25e3615 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -45,6 +45,11 @@
char pstack_file_name[80];
#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
#include <errno.h>
#include <sys/stat.h>
@@ -453,16 +458,7 @@ static void close_connections(void)
sql_print_error("Got error %d from pthread_cond_timedwait",error);
#endif
#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ)
- if (ip_sock != INVALID_SOCKET)
- {
- 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;
- }
+ close_server_sock();
#endif
}
(void) pthread_mutex_unlock(&LOCK_thread_count);
@@ -577,10 +573,37 @@ static void close_connections(void)
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)
{
DBUG_ENTER("kill_mysql");
+#ifdef SIGNALS_DONT_BREAK_READ
+ close_server_sock(); /* force accept to wake up */
+#endif
+
#if defined(__WIN__)
{
if (!SetEvent(hEventShutdown))
@@ -604,6 +627,7 @@ void kill_mysql(void)
#endif
DBUG_PRINT("quit",("After pthread_kill"));
shutdown_in_progress=1; // Safety if kill didn't work
+ abort_loop=1;
DBUG_VOID_RETURN;
}
@@ -2023,6 +2047,7 @@ The server will not act as a slave.");
sql_print_error("Before Lock_thread_count");
#endif
(void) pthread_mutex_lock(&LOCK_thread_count);
+ DBUG_PRINT("quit", ("Got thread_count mutex"));
select_thread_in_use=0; // For close_connections
(void) pthread_cond_broadcast(&COND_thread_count);
(void) pthread_mutex_unlock(&LOCK_thread_count);
@@ -2054,10 +2079,14 @@ The server will not act as a slave.");
#endif /* HAVE_OPENSSL */
/* Wait until cleanup is done */
(void) pthread_mutex_lock(&LOCK_thread_count);
+ DBUG_PRINT("quit", ("Got thread_count mutex for clean up wait"));
+
while (!ready_to_exit)
{
+ DBUG_PRINT("quit", ("not yet ready to exit"));
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
}
+ DBUG_PRINT("quit", ("ready to exit"));
(void) pthread_mutex_unlock(&LOCK_thread_count);
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(0);
@@ -2253,6 +2282,20 @@ static void create_new_thread(THD *thd)
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 */
@@ -2288,6 +2331,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
#endif
DBUG_PRINT("general",("Waiting for connections."));
+ MAYBE_BROKEN_SYSCALL;
while (!abort_loop)
{
readFDs=clientFDs;
@@ -2302,12 +2346,15 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
if (!select_errors++ && !abort_loop) /* purecov: inspected */
sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */
}
+ MAYBE_BROKEN_SYSCALL
continue;
}
#endif /* HPUX */
if (abort_loop)
+ {
+ MAYBE_BROKEN_SYSCALL;
break;
-
+ }
/*
** Is this a new connection request
*/
@@ -2343,6 +2390,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
if (new_sock != INVALID_SOCKET ||
(socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
break;
+ MAYBE_BROKEN_SYSCALL;
#if !defined(NO_FCNTL_NONBLOCK)
if (!(test_flags & TEST_BLOCKING))
{
@@ -2359,6 +2407,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
{
if ((error_count++ & 255) == 0) // This can happen often
sql_perror("Error in accept");
+ MAYBE_BROKEN_SYSCALL;
if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
sleep(1); // Give other threads some time
continue;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index b5300813410..684c084ece3 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -38,6 +38,13 @@ bool opt_sporadic_binlog_dump_fail = 0;
static int binlog_dump_count = 0;
#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,
const char* log_file_name,
char* errmsg);
@@ -700,10 +707,7 @@ int stop_slave(THD* thd, bool net_report )
if (slave_running)
{
abort_slave = 1;
- thr_alarm_kill(slave_real_id);
-#ifdef SIGNAL_WITH_VIO_CLOSE
- slave_thd->close_active_vio();
-#endif
+ KICK_SLAVE;
// do not abort the slave in the middle of a query, so we do not set
// thd->killed for the slave thread
thd->proc_info = "waiting for slave to die";
@@ -728,7 +732,7 @@ int stop_slave(THD* thd, bool net_report )
#endif
pthread_cond_timedwait(&COND_slave_stopped, &LOCK_slave, &abstime);
if (slave_running)
- thr_alarm_kill(slave_real_id);
+ KICK_SLAVE;
}
}
else
@@ -818,7 +822,7 @@ int change_master(THD* thd)
if ((slave_was_running = slave_running))
{
abort_slave = 1;
- thr_alarm_kill(slave_real_id);
+ KICK_SLAVE;
thd->proc_info = "waiting for slave to die";
while (slave_running)
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); // wait until done
@@ -1470,7 +1474,7 @@ int load_master_data(THD* thd)
if ((slave_was_running = slave_running))
{
abort_slave = 1;
- thr_alarm_kill(slave_real_id);
+ KICK_SLAVE;
thd->proc_info = "waiting for slave to die";
while (slave_running)
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); // wait until done