X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fio-layer%2Fevents.c;h=5c072aafd9ef1603b820fe03904df144d29a3363;hb=01ea58cbd474d4a9230acbba5571738896539d42;hp=40687cbcd4eeb062f299679319ceeb3905f9379c;hpb=1fabd87b02f8d2e359150ed7a9e92613e60383bc;p=mono.git diff --git a/mono/io-layer/events.c b/mono/io-layer/events.c index 40687cbcd4e..5c072aafd9e 100644 --- a/mono/io-layer/events.c +++ b/mono/io-layer/events.c @@ -21,7 +21,11 @@ #include -#undef DEBUG +#if 0 +#define DEBUG(...) g_message(__VA_ARGS__) +#else +#define DEBUG(...) +#endif static void event_signal(gpointer handle); static gboolean event_own (gpointer handle); @@ -96,7 +100,7 @@ static void event_ops_init (void) static void event_signal(gpointer handle) { - ResetEvent(handle); + SetEvent(handle); } static gboolean event_own (gpointer handle) @@ -112,9 +116,7 @@ static gboolean event_own (gpointer handle) return (FALSE); } -#ifdef DEBUG - g_message("%s: owning event handle %p", __func__, handle); -#endif + DEBUG("%s: owning event handle %p", __func__, handle); if(event_handle->manual==FALSE) { g_assert (event_handle->set_count > 0); @@ -129,7 +131,7 @@ static gboolean event_own (gpointer handle) static void namedevent_signal (gpointer handle) { - ResetEvent (handle); + SetEvent (handle); } /* NB, always called with the shared handle lock held */ @@ -138,9 +140,7 @@ static gboolean namedevent_own (gpointer handle) struct _WapiHandle_namedevent *namedevent_handle; gboolean ok; -#ifdef DEBUG - g_message ("%s: owning named event handle %p", __func__, handle); -#endif + DEBUG ("%s: owning named event handle %p", __func__, handle); ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDEVENT, (gpointer *)&namedevent_handle); @@ -173,9 +173,7 @@ static gpointer event_create (WapiSecurityAttributes *security G_GNUC_UNUSED, */ SetLastError (ERROR_SUCCESS); -#ifdef DEBUG - g_message ("%s: Creating unnamed event", __func__); -#endif + DEBUG ("%s: Creating unnamed event", __func__); event_handle.manual = manual; event_handle.set_count = 0; @@ -202,9 +200,7 @@ static gpointer event_create (WapiSecurityAttributes *security G_GNUC_UNUSED, _wapi_handle_set_signal_state (handle, TRUE, FALSE); } -#ifdef DEBUG - g_message("%s: created new event handle %p", __func__, handle); -#endif + DEBUG("%s: created new event handle %p", __func__, handle); thr_ret = _wapi_handle_unlock_handle (handle); g_assert (thr_ret == 0); @@ -239,9 +235,7 @@ static gpointer namedevent_create (WapiSecurityAttributes *security G_GNUC_UNUSE utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL); -#ifdef DEBUG - g_message ("%s: Creating named event [%s]", __func__, utf8_name); -#endif + DEBUG ("%s: Creating named event [%s]", __func__, utf8_name); offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT, utf8_name); @@ -312,9 +306,7 @@ static gpointer namedevent_create (WapiSecurityAttributes *security G_GNUC_UNUSE _wapi_handle_unlock_shared_handles (); } -#ifdef DEBUG - g_message ("%s: returning event handle %p", __func__, handle); -#endif + DEBUG ("%s: returning event handle %p", __func__, handle); cleanup: g_free (utf8_name); @@ -378,9 +370,7 @@ static gboolean event_pulse (gpointer handle) thr_ret = _wapi_handle_lock_handle (handle); g_assert (thr_ret == 0); -#ifdef DEBUG - g_message ("%s: Pulsing event handle %p", __func__, handle); -#endif + DEBUG ("%s: Pulsing event handle %p", __func__, handle); if (event_handle->manual == TRUE) { _wapi_handle_set_signal_state (handle, TRUE, TRUE); @@ -407,10 +397,8 @@ static gboolean event_pulse (gpointer handle) * have proceeded. Currently we rely on broadcasting * a condition. */ -#ifdef DEBUG - g_message ("%s: Obtained write lock on event handle %p", + DEBUG ("%s: Obtained write lock on event handle %p", __func__, handle); -#endif pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle, handle); thr_ret = _wapi_handle_lock_handle (handle); @@ -443,9 +431,7 @@ static gboolean namedevent_pulse (gpointer handle) thr_ret = _wapi_handle_lock_shared_handles (); g_assert (thr_ret == 0); -#ifdef DEBUG - g_message ("%s: Pulsing named event handle %p", __func__, handle); -#endif + DEBUG ("%s: Pulsing named event handle %p", __func__, handle); if (namedevent_handle->manual == TRUE) { _wapi_shared_handle_set_signal_state (handle, TRUE); @@ -469,10 +455,8 @@ static gboolean namedevent_pulse (gpointer handle) * have proceeded. Currently we rely on waiting for * twice the shared handle poll interval. */ -#ifdef DEBUG - g_message ("%s: Obtained write lock on event handle %p", + DEBUG ("%s: Obtained write lock on event handle %p", __func__, handle); -#endif thr_ret = _wapi_handle_lock_shared_handles (); g_assert (thr_ret == 0); @@ -533,9 +517,7 @@ static gboolean event_reset (gpointer handle) return(FALSE); } -#ifdef DEBUG - g_message ("%s: Resetting event handle %p", __func__, handle); -#endif + DEBUG ("%s: Resetting event handle %p", __func__, handle); pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle, handle); @@ -543,15 +525,11 @@ static gboolean event_reset (gpointer handle) g_assert (thr_ret == 0); if (_wapi_handle_issignalled (handle) == FALSE) { -#ifdef DEBUG - g_message ("%s: No need to reset event handle %p", __func__, + DEBUG ("%s: No need to reset event handle %p", __func__, handle); -#endif } else { -#ifdef DEBUG - g_message ("%s: Obtained write lock on event handle %p", + DEBUG ("%s: Obtained write lock on event handle %p", __func__, handle); -#endif _wapi_handle_set_signal_state (handle, FALSE, FALSE); } @@ -580,23 +558,17 @@ static gboolean namedevent_reset (gpointer handle) return(FALSE); } -#ifdef DEBUG - g_message ("%s: Resetting named event handle %p", __func__, handle); -#endif + DEBUG ("%s: Resetting named event handle %p", __func__, handle); thr_ret = _wapi_handle_lock_shared_handles (); g_assert (thr_ret == 0); if (_wapi_handle_issignalled (handle) == FALSE) { -#ifdef DEBUG - g_message ("%s: No need to reset named event handle %p", + DEBUG ("%s: No need to reset named event handle %p", __func__, handle); -#endif } else { -#ifdef DEBUG - g_message ("%s: Obtained write lock on named event handle %p", + DEBUG ("%s: Obtained write lock on named event handle %p", __func__, handle); -#endif _wapi_shared_handle_set_signal_state (handle, FALSE); } @@ -655,9 +627,7 @@ static gboolean event_set (gpointer handle) thr_ret = _wapi_handle_lock_handle (handle); g_assert (thr_ret == 0); -#ifdef DEBUG - g_message ("%s: Setting event handle %p", __func__, handle); -#endif + DEBUG ("%s: Setting event handle %p", __func__, handle); if (event_handle->manual == TRUE) { _wapi_handle_set_signal_state (handle, TRUE, TRUE); @@ -691,9 +661,7 @@ static gboolean namedevent_set (gpointer handle) thr_ret = _wapi_handle_lock_shared_handles (); g_assert (thr_ret == 0); -#ifdef DEBUG - g_message ("%s: Setting named event handle %p", __func__, handle); -#endif + DEBUG ("%s: Setting named event handle %p", __func__, handle); if (namedevent_handle->manual == TRUE) { _wapi_shared_handle_set_signal_state (handle, TRUE); @@ -758,9 +726,7 @@ gpointer OpenEvent (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL); -#ifdef DEBUG - g_message ("%s: Opening named event [%s]", __func__, utf8_name); -#endif + DEBUG ("%s: Opening named event [%s]", __func__, utf8_name); offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT, utf8_name); @@ -789,9 +755,7 @@ gpointer OpenEvent (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED } ret = handle; -#ifdef DEBUG - g_message ("%s: returning named event handle %p", __func__, handle); -#endif + DEBUG ("%s: returning named event handle %p", __func__, handle); cleanup: g_free (utf8_name);