* Author:
* Dick Porter (dick@ximian.com)
*
- * (C) 2002 Ximian, Inc.
+ * (C) 2002-2006 Novell, Inc.
*/
#include <config.h>
struct timespec abstime;
int thr_ret;
gboolean apc_pending = FALSE;
- gpointer current_thread = GetCurrentThread ();
+ gpointer current_thread = _wapi_thread_handle_from_id (pthread_self ());
+
+ if (current_thread == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(WAIT_FAILED);
+ }
+
+ if (handle == _WAPI_THREAD_CURRENT) {
+ handle = _wapi_thread_handle_from_id (pthread_self ());
+ if (handle == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(WAIT_FAILED);
+ }
+ }
if (_wapi_handle_test_capabilities (handle,
WAPI_HANDLE_CAP_WAIT) == FALSE) {
}
if (timeout == INFINITE) {
- waited = _wapi_handle_wait_signal_handle (handle);
+ waited = _wapi_handle_wait_signal_handle (handle, alertable);
} else {
- waited = _wapi_handle_timedwait_signal_handle (handle, &abstime);
+ waited = _wapi_handle_timedwait_signal_handle (handle, &abstime, alertable);
}
if (alertable)
struct timespec abstime;
int thr_ret;
gboolean apc_pending = FALSE;
- gpointer current_thread = GetCurrentThread ();
+ gpointer current_thread = _wapi_thread_handle_from_id (pthread_self ());
+
+ if (current_thread == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(WAIT_FAILED);
+ }
+
+ if (signal_handle == _WAPI_THREAD_CURRENT) {
+ signal_handle = _wapi_thread_handle_from_id (pthread_self ());
+ if (signal_handle == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(WAIT_FAILED);
+ }
+ }
+
+ if (wait == _WAPI_THREAD_CURRENT) {
+ wait = _wapi_thread_handle_from_id (pthread_self ());
+ if (wait == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(WAIT_FAILED);
+ }
+ }
if (_wapi_handle_test_capabilities (signal_handle,
WAPI_HANDLE_CAP_SIGNAL)==FALSE) {
}
if (timeout == INFINITE) {
- waited = _wapi_handle_wait_signal_handle (wait);
+ waited = _wapi_handle_wait_signal_handle (wait, alertable);
} else {
- waited = _wapi_handle_timedwait_signal_handle (wait, &abstime);
+ waited = _wapi_handle_timedwait_signal_handle (wait, &abstime, alertable);
}
if (alertable) {
guint i;
guint32 ret;
int thr_ret;
- gpointer current_thread = GetCurrentThread ();
+ gpointer current_thread = _wapi_thread_handle_from_id (pthread_self ());
+
+ if (current_thread == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(WAIT_FAILED);
+ }
if (numobjects > MAXIMUM_WAIT_OBJECTS) {
#ifdef DEBUG
/* Check for duplicates */
dups = g_hash_table_new (g_direct_hash, g_direct_equal);
for (i = 0; i < numobjects; i++) {
- gpointer exists = g_hash_table_lookup (dups, handles[i]);
+ gpointer exists;
+
+ if (handles[i] == _WAPI_THREAD_CURRENT) {
+ handles[i] = _wapi_thread_handle_from_id (pthread_self ());
+
+ if (handles[i] == NULL) {
+#ifdef DEBUG
+ g_message ("%s: Handle %d bogus", __func__, i);
+#endif
+
+ bogustype = TRUE;
+ break;
+ }
+ }
+
+ exists = g_hash_table_lookup (dups, handles[i]);
if (exists != NULL) {
#ifdef DEBUG
g_message ("%s: Handle %p duplicated", __func__,