ret = _wapi_handle_ops_special_wait (handle, timeout, alertable);
- if (alertable && _wapi_thread_cur_apc_pending ()) {
- apc_pending = TRUE;
+ if (alertable && _wapi_thread_cur_apc_pending ())
ret = WAIT_IO_COMPLETION;
- }
- goto check_pending;
+ return ret;
}
goto done;
}
}
-
- if (alertable && _wapi_thread_cur_apc_pending ()) {
- apc_pending = TRUE;
- ret = WAIT_IO_COMPLETION;
- goto done;
- }
-
+
if (own_if_signalled (handle) == TRUE) {
DEBUG ("%s: handle %p already signalled", __func__,
handle);
ret = WAIT_OBJECT_0;
goto done;
}
-
- waited = _wapi_handle_timedwait_signal_handle (handle, timeout == INFINITE ? NULL : &abstime, alertable, FALSE);
- if (alertable)
- apc_pending = _wapi_thread_cur_apc_pending ();
+ waited = _wapi_handle_timedwait_signal_handle (handle, timeout == INFINITE ? NULL : &abstime, alertable, FALSE, &apc_pending);
if(waited==0 && !apc_pending) {
/* Condition was signalled, so hopefully
DEBUG ("%s: wait on handle %p error: %s", __func__, handle,
strerror (waited));
- ret = WAIT_TIMEOUT;
-
+ ret = apc_pending ? WAIT_IO_COMPLETION : WAIT_TIMEOUT;
+
done:
DEBUG ("%s: unlocking handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
-
-check_pending:
- if (apc_pending)
- ret = WAIT_IO_COMPLETION;
-
+
return(ret);
}
goto done;
}
}
-
- if (alertable && _wapi_thread_cur_apc_pending ()) {
- apc_pending = TRUE;
- ret = WAIT_IO_COMPLETION;
- goto done;
- }
-
+
if (own_if_signalled (wait)) {
DEBUG ("%s: handle %p already signalled", __func__, wait);
goto done;
}
- waited = _wapi_handle_timedwait_signal_handle (wait, timeout == INFINITE ? NULL : &abstime, alertable, FALSE);
-
- if (alertable) {
- apc_pending = _wapi_thread_cur_apc_pending ();
- }
+ waited = _wapi_handle_timedwait_signal_handle (wait, timeout == INFINITE ? NULL : &abstime, alertable, FALSE, &apc_pending);
if (waited==0 && !apc_pending) {
/* Condition was signalled, so hopefully
DEBUG ("%s: wait on handle %p error: %s", __func__, wait,
strerror (ret));
- ret = WAIT_TIMEOUT;
-
+ ret = apc_pending ? WAIT_IO_COMPLETION : WAIT_TIMEOUT;
+
done:
DEBUG ("%s: unlocking handle %p", __func__, wait);
thr_ret = _wapi_handle_unlock_handle (wait);
g_assert (thr_ret == 0);
- if (apc_pending)
- ret = WAIT_IO_COMPLETION;
-
return(ret);
}
guint32 retval;
gboolean poll;
gpointer sorted_handles [MAXIMUM_WAIT_OBJECTS];
+ gboolean apc_pending = FALSE;
if (current_thread == NULL) {
SetLastError (ERROR_INVALID_HANDLE);
_wapi_calc_timeout (&abstime, timeout);
}
- if (alertable && _wapi_thread_cur_apc_pending ())
- return WAIT_IO_COMPLETION;
-
for (i = 0; i < numobjects; i++) {
/* Add a reference, as we need to ensure the handle wont
* disappear from under us while we're waiting in the loop
if (!done) {
/* Enter the wait */
- ret = _wapi_handle_timedwait_signal (timeout == INFINITE ? NULL : &abstime, poll);
+ ret = _wapi_handle_timedwait_signal (timeout == INFINITE ? NULL : &abstime, poll, &apc_pending);
} else {
/* No need to wait */
ret = 0;
thr_ret = _wapi_handle_unlock_signal_mutex (NULL);
g_assert (thr_ret == 0);
- if (alertable && _wapi_thread_cur_apc_pending ()) {
+ if (alertable && apc_pending) {
retval = WAIT_IO_COMPLETION;
break;
}