summaryrefslogtreecommitdiff
path: root/innobase/include
diff options
context:
space:
mode:
authorheikki@hundin.mysql.fi <>2003-06-02 13:11:20 +0300
committerheikki@hundin.mysql.fi <>2003-06-02 13:11:20 +0300
commite8e98d05f998aeba8adc311ee6ae58ec70d7617a (patch)
tree2c5725cba5b986c6857be7be12c3220e06d81809 /innobase/include
parentf6a365a53218c4ba8d3b6c03088090f5878115ff (diff)
downloadmariadb-git-e8e98d05f998aeba8adc311ee6ae58ec70d7617a.tar.gz
os0thread.h, os0sync.ic, os0sync.h, os0thread.c, os0sync.c, os0file.c:
Release all event semaphores at shutdown also in Windows srv0start.c, srv0srv.c: make test sometimes failed because lock timeout thread exited without decrementing the InnoDB thread counter
Diffstat (limited to 'innobase/include')
-rw-r--r--innobase/include/os0sync.h51
-rw-r--r--innobase/include/os0sync.ic1
-rw-r--r--innobase/include/os0thread.h4
3 files changed, 36 insertions, 20 deletions
diff --git a/innobase/include/os0sync.h b/innobase/include/os0sync.h
index bad8e6e120a..634507467f9 100644
--- a/innobase/include/os0sync.h
+++ b/innobase/include/os0sync.h
@@ -13,13 +13,26 @@ Created 9/6/1995 Heikki Tuuri
#include "ut0lst.h"
#ifdef __WIN__
+
#define os_fast_mutex_t CRITICAL_SECTION
-typedef HANDLE os_event_t;
+
+typedef HANDLE os_native_event_t;
+
+typedef struct os_event_struct os_event_struct_t;
+typedef os_event_struct_t* os_event_t;
+
+struct os_event_struct {
+ os_native_event_t handle;
+ /* Windows event */
+ UT_LIST_NODE_T(os_event_struct_t) os_event_list;
+ /* list of all created events */
+};
#else
typedef pthread_mutex_t os_fast_mutex_t;
typedef struct os_event_struct os_event_struct_t;
typedef os_event_struct_t* os_event_t;
+
struct os_event_struct {
os_fast_mutex_t os_mutex; /* this mutex protects the next
fields */
@@ -39,16 +52,16 @@ typedef os_mutex_str_t* os_mutex_t;
#define OS_SYNC_TIME_EXCEEDED 1
-/* Mutex protecting the thread count and event and OS 'slow' mutex lists */
+/* Mutex protecting counts and the event and OS 'slow' mutex lists */
extern os_mutex_t os_sync_mutex;
/* This is incremented by 1 in os_thread_create and decremented by 1 in
os_thread_exit */
extern ulint os_thread_count;
-/* The following are approximate counters for debugging in Unix */
extern ulint os_event_count;
extern ulint os_mutex_count;
+extern ulint os_fast_mutex_count;
/*************************************************************
Initializes global event and OS 'slow' mutex lists. */
@@ -57,15 +70,14 @@ void
os_sync_init(void);
/*==============*/
/*************************************************************
-Frees created events (not in Windows) and OS 'slow' mutexes. */
+Frees created events and OS 'slow' mutexes. */
void
os_sync_free(void);
/*==============*/
-/*************************************************************
-Creates an event semaphore, i.e., a semaphore which may
-just have two states: signaled and nonsignaled.
-The created event is manual reset: it must be reset
+/*************************************************************
+Creates an event semaphore, i.e., a semaphore which may just have two states:
+signaled and nonsignaled. The created event is manual reset: it must be reset
explicitly by calling sync_os_reset_event. */
os_event_t
@@ -74,10 +86,10 @@ os_event_create(
/* out: the event handle */
char* name); /* in: the name of the event, if NULL
the event is created without a name */
+#ifdef __WIN__
/*************************************************************
-Creates an auto-reset event semaphore, i.e., an event
-which is automatically reset when a single thread is
-released. */
+Creates an auto-reset event semaphore, i.e., an event which is automatically
+reset when a single thread is released. Works only in Windows. */
os_event_t
os_event_create_auto(
@@ -85,6 +97,7 @@ os_event_create_auto(
/* out: the event handle */
char* name); /* in: the name of the event, if NULL
the event is created without a name */
+#endif
/**************************************************************
Sets an event semaphore to the signaled state: lets waiting threads
proceed. */
@@ -120,7 +133,7 @@ os_event_wait(
os_event_t event); /* in: event to wait */
/**************************************************************
Waits for an event object until it is in the signaled state or
-a timeout is exceeded. */
+a timeout is exceeded. In Unix the timeout is always infinite. */
ulint
os_event_wait_time(
@@ -131,8 +144,9 @@ os_event_wait_time(
os_event_t event, /* in: event to wait */
ulint time); /* in: timeout in microseconds, or
OS_SYNC_INFINITE_TIME */
+#ifdef __WIN__
/**************************************************************
-Waits for any event in an event array. Returns if even a single
+Waits for any event in an OS native event array. Returns if even a single
one is signaled or becomes signaled. */
ulint
@@ -140,14 +154,15 @@ os_event_wait_multiple(
/*===================*/
/* out: index of the event
which was signaled */
- ulint n, /* in: number of events in the
+ ulint n, /* in: number of events in the
array */
- os_event_t* event_array); /* in: pointer to an array of event
+ os_native_event_t* native_event_array);
+ /* in: pointer to an array of event
handles */
+#endif
/*************************************************************
-Creates an operating system mutex semaphore.
-Because these are slow, the mutex semaphore of the database
-itself (sync_mutex_t) should be used where possible. */
+Creates an operating system mutex semaphore. Because these are slow, the
+mutex semaphore of InnoDB itself (mutex_t) should be used where possible. */
os_mutex_t
os_mutex_create(
diff --git a/innobase/include/os0sync.ic b/innobase/include/os0sync.ic
index 10b85c435e3..1337e97152a 100644
--- a/innobase/include/os0sync.ic
+++ b/innobase/include/os0sync.ic
@@ -44,4 +44,3 @@ os_fast_mutex_trylock(
#endif
#endif
}
-
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h
index 92187f315c2..491d8866af4 100644
--- a/innobase/include/os0thread.h
+++ b/innobase/include/os0thread.h
@@ -65,7 +65,9 @@ os_thread_pf(
/********************************************************************
Creates a new thread of execution. The execution starts from
the function given. The start function takes a void* parameter
-and returns a ulint. */
+and returns a ulint.
+NOTE: We count the number of threads in os_thread_exit(). A created
+thread should always use that to exit and not use return() to exit. */
os_thread_t
os_thread_create(