Bug#57720 - Windows Vista and possibly Windows 7 can return ERROR_TIMEOUT...

Bug#57720 - Windows Vista and possibly Windows 7 can return ERROR_TIMEOUT instead of WAIT_TIMEOUT from calls to SleepConditionVariableCS() which is used in os0sync.c; os_cond_wait_timeout() where it is mapped to sleep_condition_variable().   

Consider ERROR_TIMEOUT to be a timeout just like WAIT_TIMEOUT.  

In addition, test for EINTR as a possible return value from pthread_cond_timeout() in the posix section of os_cond_wait_timeout(), even though it is not supposed to be returned, but just to be safe.
parent e548b2f1
...@@ -142,14 +142,24 @@ os_cond_wait_timed( ...@@ -142,14 +142,24 @@ os_cond_wait_timed(
) )
{ {
#ifdef __WIN__ #ifdef __WIN__
BOOL ret; BOOL ret;
DWORD err;
ut_a(sleep_condition_variable != NULL); ut_a(sleep_condition_variable != NULL);
ret = sleep_condition_variable(cond, mutex, time_in_ms); ret = sleep_condition_variable(cond, mutex, time_in_ms);
if (!ret && GetLastError() == WAIT_TIMEOUT) { if (!ret) {
return(TRUE); err = GetLastError();
/* From http://msdn.microsoft.com/en-us/library/ms686301%28VS.85%29.aspx,
"Condition variables are subject to spurious wakeups
(those not associated with an explicit wake) and stolen wakeups
(another thread manages to run before the woken thread)."
Check for both types of timeouts.
Conditions are checked by the caller.*/
if ((err == WAIT_TIMEOUT) || (err == ERROR_TIMEOUT)) {
return(TRUE);
}
} }
ut_a(ret); ut_a(ret);
...@@ -163,12 +173,15 @@ os_cond_wait_timed( ...@@ -163,12 +173,15 @@ os_cond_wait_timed(
switch (ret) { switch (ret) {
case 0: case 0:
case ETIMEDOUT: case ETIMEDOUT:
break; /* We play it safe by checking for EINTR even though
according to the POSIX documentation it can't return EINTR. */
case EINTR:
break;
default: default:
fprintf(stderr, " InnoDB: pthread_cond_timedwait() returned: " fprintf(stderr, " InnoDB: pthread_cond_timedwait() returned: "
"%d: abstime={%lu,%lu}\n", "%d: abstime={%lu,%lu}\n",
ret, abstime->tv_sec, abstime->tv_nsec); ret, abstime->tv_sec, abstime->tv_nsec);
ut_error; ut_error;
} }
...@@ -663,7 +676,7 @@ os_event_wait_time_low( ...@@ -663,7 +676,7 @@ os_event_wait_time_low(
if (err == WAIT_OBJECT_0) { if (err == WAIT_OBJECT_0) {
return(0); return(0);
} else if (err == WAIT_TIMEOUT) { } else if ((err == WAIT_TIMEOUT) || (err == ERROR_TIMEOUT)) {
return(OS_SYNC_TIME_EXCEEDED); return(OS_SYNC_TIME_EXCEEDED);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment