aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-06-22 11:46:49 -0400
committerKen Brown <kbrown@cornell.edu>2019-06-23 10:16:33 -0400
commita9b6d328823abaea1b94af95866fbe4eccdd8960 (patch)
tree66502a73330cdc32cb95c189b07e3da4ea1862ac
parent724c18ff7e05545555689854571ea27ed73e8f0b (diff)
downloadnewlib-a9b6d328823abaea1b94af95866fbe4eccdd8960.zip
newlib-a9b6d328823abaea1b94af95866fbe4eccdd8960.tar.gz
newlib-a9b6d328823abaea1b94af95866fbe4eccdd8960.tar.bz2
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.
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_fifo.cc13
2 files changed, 11 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index f244f34..156baed 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1271,7 +1271,7 @@ class fhandler_fifo: public fhandler_base
HANDLE create_pipe_instance (bool);
NTSTATUS open_pipe (HANDLE&);
int add_client_handler ();
- void delete_client_handler (int);
+ int delete_client_handler (int);
bool listen_client ();
int stop_listen_client ();
int check_listen_client_thread ();
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index f63787f..4568ea0 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -257,13 +257,14 @@ out:
return ret;
}
-void
+int
fhandler_fifo::delete_client_handler (int i)
{
- fc_handler[i].close ();
+ int ret = fc_handler[i].close ();
if (i < --nhandlers)
memmove (fc_handler + i, fc_handler + i + 1,
(nhandlers - i) * sizeof (fc_handler[i]));
+ return ret;
}
/* Just hop to the listen_client_thread method. */
@@ -324,7 +325,13 @@ fhandler_fifo::listen_client_thread ()
while (i < nhandlers)
{
if (fc_handler[i].state == fc_invalid)
- delete_client_handler (i);
+ {
+ if (delete_client_handler (i) < 0)
+ {
+ fifo_client_unlock ();
+ goto out;
+ }
+ }
else
i++;
}