summaryrefslogtreecommitdiff
path: root/innobase/os/os0sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/os/os0sync.c')
-rw-r--r--innobase/os/os0sync.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c
index 1647dd982f3..4c283431575 100644
--- a/innobase/os/os0sync.c
+++ b/innobase/os/os0sync.c
@@ -60,9 +60,9 @@ os_event_create(
event = ut_malloc(sizeof(struct os_event_struct));
os_fast_mutex_init(&(event->os_mutex));
- os_fast_mutex_init(&(event->wait_mutex));
+ pthread_cond_init(&(event->cond_var), NULL);
- event->is_set = TRUE;
+ event->is_set = FALSE;
return(event);
#endif
@@ -119,8 +119,8 @@ os_event_set(
if (event->is_set) {
/* Do nothing */
} else {
- os_fast_mutex_unlock(&(event->wait_mutex));
event->is_set = TRUE;
+ pthread_cond_broadcast(&(event->cond_var));
}
os_fast_mutex_unlock(&(event->os_mutex));
@@ -148,7 +148,6 @@ os_event_reset(
if (!event->is_set) {
/* Do nothing */
} else {
- os_fast_mutex_lock(&(event->wait_mutex));
event->is_set = FALSE;
}
@@ -173,7 +172,7 @@ os_event_free(
ut_a(event);
os_fast_mutex_free(&(event->os_mutex));
- os_fast_mutex_free(&(event->wait_mutex));
+ pthread_cond_destroy(&(event->cond_var));
ut_free(event);
#endif
@@ -197,8 +196,22 @@ os_event_wait(
ut_a(err == WAIT_OBJECT_0);
#else
- os_fast_mutex_lock(&(event->wait_mutex));
- os_fast_mutex_unlock(&(event->wait_mutex));
+ os_fast_mutex_lock(&(event->os_mutex));
+loop:
+ if (event->is_set == TRUE) {
+ os_fast_mutex_unlock(&(event->os_mutex));
+
+ /* Ok, we may return */
+
+ return;
+ }
+
+ pthread_cond_wait(&(event->cond_var), &(event->os_mutex));
+
+ /* Solaris manual said that spurious wakeups may occur: we have
+ to check the 'is_set' variable again */
+
+ goto loop;
#endif
}