gunichar2 *utf16_basename;
time_t create_time;
glong bytes;
- int thr_ret;
gboolean ret = FALSE;
ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
return(FALSE);
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
retry:
if (find_handle->count >= find_handle->num) {
g_free (utf16_basename);
cleanup:
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return(ret);
}
{
struct _WapiHandle_find *find_handle;
gboolean ok;
- int thr_ret;
if (handle == NULL) {
SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
g_strfreev (find_handle->namelist);
g_free (find_handle->dir_part);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
mono_w32handle_unref (handle);
static gpointer event_handle_create (MonoW32HandleEvent *event_handle, MonoW32HandleType type, gboolean manual, gboolean initial)
{
gpointer handle;
- int thr_ret;
event_handle->manual = manual;
event_handle->set_count = (initial && !manual) ? 1 : 0;
return NULL;
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
if (initial)
mono_w32handle_set_signal_state (handle, TRUE, FALSE);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
{
MonoW32HandleType type;
MonoW32HandleEvent *event_handle;
- int thr_ret;
if (handle == NULL) {
SetLastError (ERROR_INVALID_HANDLE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
if (!event_handle->manual) {
event_handle->set_count = 1;
mono_w32handle_set_signal_state (handle, TRUE, TRUE);
}
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return TRUE;
}
{
MonoW32HandleType type;
MonoW32HandleEvent *event_handle;
- int thr_ret;
SetLastError (ERROR_SUCCESS);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: resetting %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
if (!mono_w32handle_issignalled (handle)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: no need to reset %s handle %p",
event_handle->set_count = 0;
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return TRUE;
}
return handle_data->signalled;
}
-static int
+static void
mono_w32handle_lock_signal_mutex (void)
{
#ifdef DEBUG
#endif
mono_os_mutex_lock (&global_signal_mutex);
-
- return 0;
}
-static int
+static void
mono_w32handle_unlock_signal_mutex (void)
{
#ifdef DEBUG
#endif
mono_os_mutex_unlock (&global_signal_mutex);
-
- return 0;
}
-int
+void
mono_w32handle_lock_handle (gpointer handle)
{
MonoW32HandleBase *handle_data;
-#ifdef DEBUG
- g_message ("%s: locking handle %p", __func__, handle);
-#endif
-
- if (!mono_w32handle_lookup_data (handle, &handle_data)) {
- return(0);
- }
+ if (!mono_w32handle_lookup_data (handle, &handle_data))
+ g_error ("%s: failed to lookup handle %p", __func__, handle);
mono_w32handle_ref (handle);
mono_os_mutex_lock (&handle_data->signal_mutex);
- return 0;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: lock handle %p", __func__, handle);
}
-int
+gboolean
mono_w32handle_trylock_handle (gpointer handle)
{
MonoW32HandleBase *handle_data;
- int ret;
+ gboolean locked;
-#ifdef DEBUG
- g_message ("%s: locking handle %p", __func__, handle);
-#endif
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: trylock handle %p", __func__, handle);
- if (!mono_w32handle_lookup_data (handle, &handle_data)) {
- return(0);
- }
+ if (!mono_w32handle_lookup_data (handle, &handle_data))
+ g_error ("%s: failed to lookup handle %p", __func__, handle);
mono_w32handle_ref (handle);
- ret = mono_os_mutex_trylock (&handle_data->signal_mutex);
- if (ret != 0) {
+ locked = mono_os_mutex_trylock (&handle_data->signal_mutex) == 0;
+ if (!locked)
mono_w32handle_unref (handle);
- }
- return(ret);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: trylock handle %p, locked: %s", __func__, handle, locked ? "true" : "false");
+
+ return locked;
}
-int
+void
mono_w32handle_unlock_handle (gpointer handle)
{
MonoW32HandleBase *handle_data;
-#ifdef DEBUG
- g_message ("%s: unlocking handle %p", __func__, handle);
-#endif
+ if (!mono_w32handle_lookup_data (handle, &handle_data))
+ g_error ("%s: failed to lookup handle %p", __func__, handle);
- if (!mono_w32handle_lookup_data (handle, &handle_data)) {
- return(0);
- }
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: unlock handle %p", __func__, handle);
mono_os_mutex_unlock (&handle_data->signal_mutex);
mono_w32handle_unref (handle);
-
- return 0;
}
/*
mono_w32handle_lock_handles (gpointer *handles, gsize numhandles)
{
guint32 i, iter=0;
- int thr_ret;
/* Lock all the handles, with backoff */
again:
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: attempting to lock %p", __func__, handle);
- thr_ret = mono_w32handle_trylock_handle (handle);
-
- if (thr_ret != 0) {
+ if (!mono_w32handle_trylock_handle (handle)) {
/* Bummer */
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: attempt failed for %p: %s", __func__,
- handle, strerror (thr_ret));
+ handle);
while (i--) {
handle = handles[i];
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
}
/* If iter ever reaches 100 the nanosleep will
mono_w32handle_unlock_handles (gpointer *handles, gsize numhandles)
{
guint32 i;
- int thr_ret;
for(i=0; i<numhandles; i++) {
gpointer handle = handles[i];
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: unlocking handle %p", __func__, handle);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
}
}
MonoW32HandleWaitRet ret;
gboolean alerted;
gint64 start;
- gint thr_ret;
guint32 statuscode = 0;
alerted = FALSE;
return MONO_W32HANDLE_WAIT_RET_FAILED;
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
if (mono_w32handle_test_capabilities (handle, MONO_W32HANDLE_CAP_OWN)) {
if (own_if_owned (handle, &statuscode)) {
}
done:
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return ret;
}
{
MonoW32HandleWaitRet ret;
gboolean alerted, poll;
- gint i, thr_ret;
+ gint i;
gint64 start;
gpointer handles_sorted [MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS];
guint32 statuscodes [MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS] = {0};
}
}
- thr_ret = mono_w32handle_lock_signal_mutex ();
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_signal_mutex ();
if (waitall) {
signalled = TRUE;
if (elapsed > timeout) {
ret = MONO_W32HANDLE_WAIT_RET_TIMEOUT;
- thr_ret = mono_w32handle_unlock_signal_mutex ();
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_signal_mutex ();
goto done;
}
}
}
- thr_ret = mono_w32handle_unlock_signal_mutex ();
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_signal_mutex ();
if (alerted) {
ret = MONO_W32HANDLE_WAIT_RET_ALERTED;
MonoW32HandleWaitRet ret;
gint64 start;
gboolean alerted;
- gint thr_ret;
guint32 statuscode = 0;
+ gpointer handles [2];
alerted = FALSE;
return MONO_W32HANDLE_WAIT_RET_FAILED;
}
- thr_ret = mono_w32handle_lock_handle (wait_handle);
- g_assert (thr_ret == 0);
+ handles [0] = wait_handle;
+ handles [1] = signal_handle;
+
+ mono_w32handle_lock_handles (handles, 2);
mono_w32handle_ops_signal (signal_handle);
+ mono_w32handle_unlock_handle (signal_handle);
+
if (mono_w32handle_test_capabilities (wait_handle, MONO_W32HANDLE_CAP_OWN)) {
if (own_if_owned (wait_handle, &statuscode)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p already owned",
}
done:
- thr_ret = mono_w32handle_unlock_handle (wait_handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (wait_handle);
return ret;
}
gboolean
mono_w32handle_issignalled (gpointer handle);
-int
+void
mono_w32handle_lock_handle (gpointer handle);
-int
+gboolean
mono_w32handle_trylock_handle (gpointer handle);
-int
+void
mono_w32handle_unlock_handle (gpointer handle);
MonoW32HandleWaitRet
static gpointer mutex_handle_create (MonoW32HandleMutex *mutex_handle, MonoW32HandleType type, gboolean owned)
{
gpointer handle;
- int thr_ret;
guint32 statuscode;
mutex_handle->tid = 0;
return NULL;
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
if (owned)
mutex_handle_own (handle, type, &statuscode);
else
mono_w32handle_set_signal_state (handle, TRUE, FALSE);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
MonoW32HandleType type;
MonoW32HandleMutex *mutex_handle;
pthread_t tid;
- int thr_ret;
gboolean ret;
if (handle == NULL) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: releasing %s handle %p, tid: %p recursion: %d",
__func__, mono_w32handle_ops_typename (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion);
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
tid = pthread_self ();
}
}
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return ret;
}
MonoW32HandleMutex *mutex_handle;
MonoNativeThreadId tid;
gpointer handle;
- int thr_ret;
handle = g_ptr_array_index (internal->owned_mutexes, 0);
g_error ("%s: trying to release mutex %p acquired by thread %p from thread %p",
__func__, handle, (gpointer) mutex_handle->tid, (gpointer) tid);
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
mutex_handle->recursion = 0;
mutex_handle->tid = 0;
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: abandoned %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
}
g_ptr_array_free (internal->owned_mutexes, TRUE);
sem_handle_create (MonoW32HandleSemaphore *sem_handle, MonoW32HandleType type, gint32 initial, gint32 max)
{
gpointer handle;
- int thr_ret;
sem_handle->val = initial;
sem_handle->max = max;
return NULL;
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
if (initial != 0)
mono_w32handle_set_signal_state (handle, TRUE, FALSE);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
{
MonoW32HandleType type;
MonoW32HandleSemaphore *sem_handle;
- int thr_ret;
MonoBoolean ret;
if (!handle) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: releasing %s handle %p",
__func__, mono_w32handle_ops_typename (type), handle);
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
/* Do this before checking for count overflow, because overflowing
* max is a listed technique for finding the current value */
ret = TRUE;
}
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return ret;
}