Author: dick
Date: 2005-04-11 14:59:35 -0400 (Mon, 11 Apr 2005)
New Revision: 42794
Modified:
branches/dick/io-layer-no-daemon/wait.c
Log:
Check conditions before blocking
Modified: branches/dick/io-layer-no-daemon/wait.c
===================================================================
--- branches/dick/io-layer-no-daemon/wait.c 2005-04-11 17:15:38 UTC (rev
42793)
+++ branches/dick/io-layer-no-daemon/wait.c 2005-04-11 18:59:35 UTC (rev
42794)
@@ -114,6 +114,19 @@
}
do {
+ /* Check before waiting on the condition, just in case
+ */
+ if (_wapi_handle_issignalled (handle)) {
+#ifdef DEBUG
+ g_message ("%s: handle %p signalled", __func__,
+ handle);
+#endif
+
+ _wapi_handle_ops_own (handle);
+ ret = WAIT_OBJECT_0;
+ goto done;
+ }
+
if (timeout == INFINITE) {
waited = _wapi_handle_wait_signal_handle (handle);
} else {
@@ -270,27 +283,38 @@
goto done;
}
- if(_wapi_handle_issignalled (wait)) {
+ if (_wapi_handle_issignalled (wait)) {
#ifdef DEBUG
g_message ("%s: handle %p already signalled", __func__, wait);
#endif
_wapi_handle_ops_own (wait);
- ret=WAIT_OBJECT_0;
+ ret = WAIT_OBJECT_0;
goto done;
}
/* Have to wait for it */
- if(timeout!=INFINITE) {
+ if (timeout != INFINITE) {
_wapi_calc_timeout (&abstime, timeout);
}
do {
- if(timeout==INFINITE) {
- waited=_wapi_handle_wait_signal_handle (wait);
+ /* Check before waiting on the condition, just in case
+ */
+ if (_wapi_handle_issignalled (wait)) {
+#ifdef DEBUG
+ g_message ("%s: handle %p signalled", __func__, wait);
+#endif
+
+ _wapi_handle_ops_own (wait);
+ ret = WAIT_OBJECT_0;
+ goto done;
+ }
+
+ if (timeout == INFINITE) {
+ waited = _wapi_handle_wait_signal_handle (wait);
} else {
- waited=_wapi_handle_timedwait_signal_handle (wait,
- &abstime);
+ waited = _wapi_handle_timedwait_signal_handle (wait,
&abstime);
}
if (alertable) {
@@ -532,6 +556,14 @@
}
while(1) {
+ /* Check before waiting on the condition, just in case
+ */
+ done = test_and_own (numobjects, handles, waitall,
+ &count, &lowest);
+ if (done == TRUE) {
+ return(WAIT_OBJECT_0 + lowest);
+ }
+
#ifdef DEBUG
g_message ("%s: locking signal mutex", __func__);
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches