Cygwin: FIFO: add some error checking

Change the return type of fhandler_fifo::delete_client_handler from
void to int so that we can report errors.
This commit is contained in:
Ken Brown 2019-06-22 11:46:49 -04:00
parent 724c18ff7e
commit a9b6d32882
2 changed files with 11 additions and 4 deletions

View File

@ -1271,7 +1271,7 @@ class fhandler_fifo: public fhandler_base
HANDLE create_pipe_instance (bool); HANDLE create_pipe_instance (bool);
NTSTATUS open_pipe (HANDLE&); NTSTATUS open_pipe (HANDLE&);
int add_client_handler (); int add_client_handler ();
void delete_client_handler (int); int delete_client_handler (int);
bool listen_client (); bool listen_client ();
int stop_listen_client (); int stop_listen_client ();
int check_listen_client_thread (); int check_listen_client_thread ();

View File

@ -257,13 +257,14 @@ out:
return ret; return ret;
} }
void int
fhandler_fifo::delete_client_handler (int i) fhandler_fifo::delete_client_handler (int i)
{ {
fc_handler[i].close (); int ret = fc_handler[i].close ();
if (i < --nhandlers) if (i < --nhandlers)
memmove (fc_handler + i, fc_handler + i + 1, memmove (fc_handler + i, fc_handler + i + 1,
(nhandlers - i) * sizeof (fc_handler[i])); (nhandlers - i) * sizeof (fc_handler[i]));
return ret;
} }
/* Just hop to the listen_client_thread method. */ /* Just hop to the listen_client_thread method. */
@ -324,7 +325,13 @@ fhandler_fifo::listen_client_thread ()
while (i < nhandlers) while (i < nhandlers)
{ {
if (fc_handler[i].state == fc_invalid) if (fc_handler[i].state == fc_invalid)
delete_client_handler (i); {
if (delete_client_handler (i) < 0)
{
fifo_client_unlock ();
goto out;
}
}
else else
i++; i++;
} }