summaryrefslogtreecommitdiff
path: root/innobase/os/os0sync.c
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2003-05-30 22:44:37 +0300
committerunknown <heikki@hundin.mysql.fi>2003-05-30 22:44:37 +0300
commitd9711e32b966610af3969c76f7e96f18478dffca (patch)
tree9565fc6f3fff83d440f4639b6183c6c4a59a7433 /innobase/os/os0sync.c
parentfadfa46796576b5566ee3f45920b07e2f2326552 (diff)
downloadmariadb-git-d9711e32b966610af3969c76f7e96f18478dffca.tar.gz
Many files:
Exit all threads created by innoDB at shutdown innobase/os/os0file.c: Exit all threads created by innoDB at shutdown innobase/os/os0sync.c: Exit all threads created by innoDB at shutdown innobase/os/os0thread.c: Exit all threads created by innoDB at shutdown innobase/include/os0file.h: Exit all threads created by innoDB at shutdown innobase/include/os0sync.h: Exit all threads created by innoDB at shutdown innobase/include/os0thread.h: Exit all threads created by innoDB at shutdown innobase/log/log0log.c: Exit all threads created by innoDB at shutdown innobase/srv/srv0srv.c: Exit all threads created by innoDB at shutdown innobase/srv/srv0start.c: Exit all threads created by innoDB at shutdown
Diffstat (limited to 'innobase/os/os0sync.c')
-rw-r--r--innobase/os/os0sync.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c
index 407b280f805..abcfa254710 100644
--- a/innobase/os/os0sync.c
+++ b/innobase/os/os0sync.c
@@ -17,6 +17,7 @@ Created 9/6/1995 Heikki Tuuri
#endif
#include "ut0mem.h"
+#include "srv0start.h"
/* Type definition for an operating system mutex struct */
struct os_mutex_struct{
@@ -26,9 +27,16 @@ struct os_mutex_struct{
recursively lock the mutex: we
do not assume that the OS mutex
supports recursive locking, though
- NT seems to do that */
+ NT seems to do that */
};
+/* Mutex protecting the thread count */
+os_mutex_t os_thread_count_mutex;
+
+/* This is incremented by 1 in os_thread_create and decremented by 1 in
+os_thread_exit */
+ulint os_thread_count = 0;
+
/*************************************************************
Creates an event semaphore, i.e., a semaphore which may
just have two states: signaled and nonsignaled.
@@ -190,7 +198,10 @@ os_event_free(
}
/**************************************************************
-Waits for an event object until it is in the signaled state. */
+Waits for an event object until it is in the signaled state. If
+srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the
+waiting thread when the event becomes signaled (or immediately if the
+event is already in the signaled state). */
void
os_event_wait(
@@ -206,12 +217,20 @@ os_event_wait(
err = WaitForSingleObject(event, INFINITE);
ut_a(err == WAIT_OBJECT_0);
+
+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
+ os_thread_exit(NULL);
+ }
#else
os_fast_mutex_lock(&(event->os_mutex));
loop:
if (event->is_set == TRUE) {
os_fast_mutex_unlock(&(event->os_mutex));
+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
+
+ os_thread_exit(NULL);
+ }
/* Ok, we may return */
return;
@@ -299,6 +318,10 @@ os_event_wait_multiple(
ut_a(index >= WAIT_OBJECT_0);
ut_a(index < WAIT_OBJECT_0 + n);
+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
+ os_thread_exit(NULL);
+ }
+
return(index - WAIT_OBJECT_0);
#else
ut_a(n == 0);