Commit 0516d4d7 authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

ntdll: Implement NtSignalAndWaitForSingleObject().

parent 3a3784f2
......@@ -843,6 +843,34 @@ NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_an
return ret;
}
NTSTATUS esync_signal_and_wait( HANDLE signal, HANDLE wait, BOOLEAN alertable,
const LARGE_INTEGER *timeout )
{
struct esync *obj;
NTSTATUS ret;
if ((ret = get_object( signal, &obj ))) return ret;
switch (obj->type)
{
case ESYNC_SEMAPHORE:
ret = esync_release_semaphore( signal, 1, NULL );
break;
case ESYNC_AUTO_EVENT:
case ESYNC_MANUAL_EVENT:
ret = esync_set_event( signal );
break;
case ESYNC_MUTEX:
ret = esync_release_mutex( signal, NULL );
break;
default:
return STATUS_OBJECT_TYPE_MISMATCH;
}
if (ret) return ret;
return esync_wait_objects( 1, &wait, TRUE, alertable, timeout );
}
void esync_init(void)
{
struct stat st;
......
......@@ -37,6 +37,8 @@ extern NTSTATUS esync_release_mutex( HANDLE *handle, LONG *prev ) DECLSPEC_HIDDE
extern NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_any,
BOOLEAN alertable, const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
extern NTSTATUS esync_signal_and_wait( HANDLE signal, HANDLE wait, BOOLEAN alertable,
const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
/* We have to synchronize on the fd cache mutex so that our calls to receive_fd
......
......@@ -1480,6 +1480,9 @@ NTSTATUS WINAPI NtSignalAndWaitForSingleObject( HANDLE signal, HANDLE wait,
select_op_t select_op;
UINT flags = SELECT_INTERRUPTIBLE;
if (do_esync())
return esync_signal_and_wait( signal, wait, alertable, timeout );
if (!signal) return STATUS_INVALID_HANDLE;
if (alertable) flags |= SELECT_ALERTABLE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment