Merge pull request #2274 from esdrubal/udpclientreceive
[mono.git] / mono / io-layer / events.c
index fa3ae9d637c6f1469fa08e95e3f4a4d25426420c..3ad606bcebc95ebdf277e88344cc714b93237138 100644 (file)
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
-#include <mono/io-layer/misc-private.h>
-
 #include <mono/io-layer/event-private.h>
+#include <mono/utils/mono-once.h>
 
-#include <mono/utils/mono-mutex.h>
 #if 0
 #define DEBUG(...) g_message(__VA_ARGS__)
 #else
@@ -90,11 +88,9 @@ static mono_once_t event_ops_once=MONO_ONCE_INIT;
 static void event_ops_init (void)
 {
        _wapi_handle_register_capabilities (WAPI_HANDLE_EVENT,
-                                           WAPI_HANDLE_CAP_WAIT |
-                                           WAPI_HANDLE_CAP_SIGNAL);
+               (WapiHandleCapability)(WAPI_HANDLE_CAP_WAIT | WAPI_HANDLE_CAP_SIGNAL));
        _wapi_handle_register_capabilities (WAPI_HANDLE_NAMEDEVENT,
-                                           WAPI_HANDLE_CAP_WAIT |
-                                           WAPI_HANDLE_CAP_SIGNAL);
+               (WapiHandleCapability)(WAPI_HANDLE_CAP_WAIT | WAPI_HANDLE_CAP_SIGNAL));
 }
 
 static void event_signal(gpointer handle)
@@ -190,8 +186,6 @@ static gpointer event_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
                return(NULL);
        }
 
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
@@ -203,7 +197,6 @@ static gpointer event_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
 
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
-       pthread_cleanup_pop (0);
 
        return(handle);
 }
@@ -364,8 +357,6 @@ static gboolean event_pulse (gpointer handle)
                return(FALSE);
        }
        
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
 
@@ -381,8 +372,6 @@ static gboolean event_pulse (gpointer handle)
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
        
-       pthread_cleanup_pop (0);
-       
        if (event_handle->manual == TRUE) {
                /* For a manual-reset event, we're about to try and
                 * get the handle lock again, so give other threads a
@@ -399,7 +388,6 @@ static gboolean event_pulse (gpointer handle)
                DEBUG ("%s: Obtained write lock on event handle %p",
                           __func__, handle);
 
-               pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle, handle);
                thr_ret = _wapi_handle_lock_handle (handle);
                g_assert (thr_ret == 0);
                
@@ -407,7 +395,6 @@ static gboolean event_pulse (gpointer handle)
 
                thr_ret = _wapi_handle_unlock_handle (handle);
                g_assert (thr_ret == 0);
-               pthread_cleanup_pop (0);
        }
 
        return(TRUE);
@@ -518,8 +505,6 @@ static gboolean event_reset (gpointer handle)
 
        DEBUG ("%s: Resetting event handle %p", __func__, handle);
 
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
@@ -538,8 +523,6 @@ static gboolean event_reset (gpointer handle)
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
        
-       pthread_cleanup_pop (0);
-       
        return(TRUE);
 }
 
@@ -621,8 +604,6 @@ static gboolean event_set (gpointer handle)
                return(FALSE);
        }
        
-       pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
-                             handle);
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
 
@@ -638,8 +619,6 @@ static gboolean event_set (gpointer handle)
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
        
-       pthread_cleanup_pop (0);
-
        return(TRUE);
 }