Author: dick
Date: 2005-04-21 13:17:00 -0400 (Thu, 21 Apr 2005)
New Revision: 43413

Modified:
   trunk/mono/mono/io-layer/ChangeLog
   trunk/mono/mono/io-layer/handles.c
   trunk/mono/mono/io-layer/wait.c
Log:

2005-04-21  Dick Porter  <[EMAIL PROTECTED]>

        * wait.c (WaitForMultipleObjectsEx): Implement special waits

        * handles.c (_wapi_handle_wait_signal_poll_share): Don't return a
        timeout, just wait briefly for the private signals and let the
        waiting thread test again.  This prevents us missing shared
        signals.




Modified: trunk/mono/mono/io-layer/ChangeLog
===================================================================
--- trunk/mono/mono/io-layer/ChangeLog  2005-04-21 17:10:54 UTC (rev 43412)
+++ trunk/mono/mono/io-layer/ChangeLog  2005-04-21 17:17:00 UTC (rev 43413)
@@ -1,5 +1,14 @@
 2005-04-21  Dick Porter  <[EMAIL PROTECTED]>
 
+       * wait.c (WaitForMultipleObjectsEx): Implement special waits
+
+       * handles.c (_wapi_handle_wait_signal_poll_share): Don't return a
+       timeout, just wait briefly for the private signals and let the
+       waiting thread test again.  This prevents us missing shared
+       signals.
+
+2005-04-21  Dick Porter  <[EMAIL PROTECTED]>
+
        * collection.h (_WAPI_HANDLE_COLLECTION_EXPIRED_INTERVAL): Reduce
        the time before a slot is considered too old and deleted.  This is
        a workaround while I come up with a proper fix.

Modified: trunk/mono/mono/io-layer/handles.c
===================================================================
--- trunk/mono/mono/io-layer/handles.c  2005-04-21 17:10:54 UTC (rev 43412)
+++ trunk/mono/mono/io-layer/handles.c  2005-04-21 17:17:00 UTC (rev 43413)
@@ -1227,44 +1227,35 @@
 int _wapi_handle_wait_signal_poll_share (void)
 {
        struct timespec fake_timeout;
-       guint32 signal_count = _wapi_shared_layout->signal_count;
        int ret;
        
 #ifdef DEBUG
        g_message ("%s: poll private and shared handles", __func__);
 #endif
 
-       while(1) {
-               _wapi_calc_timeout (&fake_timeout, 100);
+       _wapi_calc_timeout (&fake_timeout, 100);
        
-               ret = mono_cond_timedwait (&_wapi_global_signal_cond,
-                                          &_wapi_global_signal_mutex,
-                                          &fake_timeout);
+       ret = mono_cond_timedwait (&_wapi_global_signal_cond,
+                                  &_wapi_global_signal_mutex, &fake_timeout);
        
-               /* Check the shared signal counter */
-               if (ret == ETIMEDOUT) {
-                       if (signal_count != _wapi_shared_layout->signal_count) {
+       if (ret == ETIMEDOUT) {
+               /* This will cause the waiting thread to check signal
+                * status for all handles
+                */
 #ifdef DEBUG
-                               g_message ("%s: A shared handle was signalled",
-                                          __func__);
+               g_message ("%s: poll timed out, returning success", __func__);
 #endif
 
-                               return (0);
-                       }
-               } else {
-                       /* This will be 0 indicating a private handle
-                        * was signalled, or an error
-                        */
+               return (0);
+       } else {
+               /* This will be 0 indicating a private handle was
+                * signalled, or an error
+                */
 #ifdef DEBUG
-                       g_message ("%s: returning: %d", __func__, ret);
+               g_message ("%s: returning: %d", __func__, ret);
 #endif
 
-                       return (ret);
-               }
-
-               /* If timeout and no shared handle was signalled, go
-                * round again
-                */
+               return (ret);
        }
 }
 

Modified: trunk/mono/mono/io-layer/wait.c
===================================================================
--- trunk/mono/mono/io-layer/wait.c     2005-04-21 17:10:54 UTC (rev 43412)
+++ trunk/mono/mono/io-layer/wait.c     2005-04-21 17:17:00 UTC (rev 43413)
@@ -111,7 +111,14 @@
                g_message ("%s: handle %p has special wait", __func__, handle);
 #endif
 
-               return (_wapi_handle_ops_special_wait (handle, timeout));
+               ret = _wapi_handle_ops_special_wait (handle, timeout);
+       
+               if (alertable && _wapi_thread_apc_pending (current_thread)) {
+                       apc_pending = TRUE;
+                       ret = WAIT_IO_COMPLETION;
+               }
+
+               goto check_pending;
        }
        
        
@@ -216,6 +223,7 @@
        g_assert (thr_ret == 0);
        pthread_cleanup_pop (0);
        
+check_pending:
        if (apc_pending) {
                _wapi_thread_dispatch_apc_queue (current_thread);
                ret = WAIT_IO_COMPLETION;
@@ -534,13 +542,6 @@
                        bogustype = TRUE;
                }
 
-               if (_wapi_handle_test_capabilities (handles[i], 
WAPI_HANDLE_CAP_SPECIAL_WAIT) == TRUE) {
-                       g_warning ("%s: handle %p has special wait, implement 
me!!",
-                                  __func__, handles[i]);
-                       
-                       bogustype = TRUE;
-               }
-
                if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handles[i]))) {
                        shared_wait = TRUE;
                }
@@ -583,6 +584,15 @@
        }
        
        while(1) {
+               /* Prod all special-wait handles that aren't already
+                * signalled
+                */
+               for (i = 0; i < numobjects; i++) {
+                       if (_wapi_handle_test_capabilities (handles[i], 
WAPI_HANDLE_CAP_SPECIAL_WAIT) == TRUE && _wapi_handle_issignalled (handles[i]) 
== FALSE) {
+                               _wapi_handle_ops_special_wait (handles[i], 0);
+                       }
+               }
+
                /* Check before waiting on the condition, just in case
                 */
                done = test_and_own (numobjects, handles, waitall,
@@ -626,15 +636,18 @@
                        return WAIT_IO_COMPLETION;
                }
        
-               if(ret==0) {
-                       /* Something was signalled ... */
-                       done = test_and_own (numobjects, handles, waitall,
-                                            &count, &lowest);
-                       if(done==TRUE) {
-                               return(WAIT_OBJECT_0+lowest);
-                       }
-               } else {
-                       /* Timeout or other error */
+               /* Check if everything is signalled, as we can't
+                * guarantee to notice a shared signal even if the
+                * wait timed out
+                */
+               done = test_and_own (numobjects, handles, waitall,
+                                    &count, &lowest);
+               if (done == TRUE) {
+                       return(WAIT_OBJECT_0+lowest);
+               } else if (ret != 0) {
+                       /* Didn't get all handles, and there was a
+                        * timeout or other error
+                        */
 #ifdef DEBUG
                        g_message ("%s: wait returned error: %s", __func__,
                                   strerror (ret));

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to