Cygwin: FIFO: minor change - use NtClose

Replace CloseHandle by NtClose since all handles are created by NT
functions.
This commit is contained in:
Ken Brown 2020-03-17 10:36:34 -04:00
parent 72865dc2a3
commit d05124dc6b

View File

@ -319,7 +319,7 @@ fhandler_fifo::listen_client ()
__seterrno (); __seterrno ();
HANDLE evt = InterlockedExchangePointer (&lct_termination_evt, NULL); HANDLE evt = InterlockedExchangePointer (&lct_termination_evt, NULL);
if (evt) if (evt)
CloseHandle (evt); NtClose (evt);
return false; return false;
} }
return true; return true;
@ -441,7 +441,7 @@ fhandler_fifo::listen_client_thread ()
ret = -1; ret = -1;
} }
if (ph) if (ph)
CloseHandle (ph); NtClose (ph);
fifo_client_unlock (); fifo_client_unlock ();
goto out; goto out;
default: default:
@ -462,7 +462,7 @@ fhandler_fifo::listen_client_thread ()
} }
out: out:
if (evt) if (evt)
CloseHandle (evt); NtClose (evt);
ResetEvent (read_ready); ResetEvent (read_ready);
if (ret < 0) if (ret < 0)
debug_printf ("exiting with error, %E"); debug_printf ("exiting with error, %E");
@ -617,16 +617,16 @@ out:
{ {
if (read_ready) if (read_ready)
{ {
CloseHandle (read_ready); NtClose (read_ready);
read_ready = NULL; read_ready = NULL;
} }
if (write_ready) if (write_ready)
{ {
CloseHandle (write_ready); NtClose (write_ready);
write_ready = NULL; write_ready = NULL;
} }
if (get_handle ()) if (get_handle ())
CloseHandle (get_handle ()); NtClose (get_handle ());
if (listen_client_thr) if (listen_client_thr)
stop_listen_client (); stop_listen_client ();
} }
@ -775,7 +775,7 @@ fhandler_fifo::raw_write (const void *ptr, size_t len)
ret = nbytes; ret = nbytes;
} }
if (evt) if (evt)
CloseHandle (evt); NtClose (evt);
if (status == STATUS_THREAD_SIGNALED && ret < 0) if (status == STATUS_THREAD_SIGNALED && ret < 0)
set_errno (EINTR); set_errno (EINTR);
else if (status == STATUS_THREAD_CANCELED) else if (status == STATUS_THREAD_CANCELED)
@ -819,7 +819,7 @@ fhandler_fifo::check_listen_client_thread ()
switch (waitret) switch (waitret)
{ {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
CloseHandle (listen_client_thr); NtClose (listen_client_thr);
break; break;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
ret = 1; ret = 1;
@ -828,7 +828,7 @@ fhandler_fifo::check_listen_client_thread ()
debug_printf ("WaitForSingleObject failed, %E"); debug_printf ("WaitForSingleObject failed, %E");
ret = -1; ret = -1;
__seterrno (); __seterrno ();
CloseHandle (listen_client_thr); NtClose (listen_client_thr);
break; break;
} }
} }
@ -1001,11 +1001,11 @@ fhandler_fifo::stop_listen_client ()
ret = -1; ret = -1;
debug_printf ("listen_client_thread exited with error"); debug_printf ("listen_client_thread exited with error");
} }
CloseHandle (thr); NtClose (thr);
} }
evt = InterlockedExchangePointer (&lct_termination_evt, NULL); evt = InterlockedExchangePointer (&lct_termination_evt, NULL);
if (evt) if (evt)
CloseHandle (evt); NtClose (evt);
return ret; return ret;
} }
@ -1017,9 +1017,9 @@ fhandler_fifo::close ()
fifo_client_unlock (); fifo_client_unlock ();
int ret = stop_listen_client (); int ret = stop_listen_client ();
if (read_ready) if (read_ready)
CloseHandle (read_ready); NtClose (read_ready);
if (write_ready) if (write_ready)
CloseHandle (write_ready); NtClose (write_ready);
fifo_client_lock (); fifo_client_lock ();
for (int i = 0; i < nhandlers; i++) for (int i = 0; i < nhandlers; i++)
if (fc_handler[i].close () < 0) if (fc_handler[i].close () < 0)
@ -1070,7 +1070,7 @@ fhandler_fifo::dup (fhandler_base *child, int flags)
GetCurrentProcess (), &fhf->write_ready, GetCurrentProcess (), &fhf->write_ready,
0, true, DUPLICATE_SAME_ACCESS)) 0, true, DUPLICATE_SAME_ACCESS))
{ {
CloseHandle (fhf->read_ready); NtClose (fhf->read_ready);
fhf->close (); fhf->close ();
__seterrno (); __seterrno ();
goto out; goto out;
@ -1084,8 +1084,8 @@ fhandler_fifo::dup (fhandler_base *child, int flags)
0, true, DUPLICATE_SAME_ACCESS)) 0, true, DUPLICATE_SAME_ACCESS))
{ {
fifo_client_unlock (); fifo_client_unlock ();
CloseHandle (fhf->read_ready); NtClose (fhf->read_ready);
CloseHandle (fhf->write_ready); NtClose (fhf->write_ready);
fhf->close (); fhf->close ();
__seterrno (); __seterrno ();
goto out; goto out;