]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: FIFO: update clone and dup
authorKen Brown <kbrown@cornell.edu>
Fri, 22 Mar 2019 19:30:39 +0000 (19:30 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 27 Mar 2019 13:01:45 +0000 (14:01 +0100)
Deal with all clients.

winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_fifo.cc

index af5f500bf25e44be0116296f7b5f7809581196f2..0ebc44e0ddf36dbb3e9212a85390f855131144c4 100644 (file)
@@ -1309,9 +1309,11 @@ public:
   fhandler_fifo *clone (cygheap_types malloc_type = HEAP_FHANDLER)
   {
     void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_fifo));
-    fhandler_fifo *fh = new (ptr) fhandler_fifo (ptr);
-    copyto (fh);
-    return fh;
+    fhandler_fifo *fhf = new (ptr) fhandler_fifo (ptr);
+    copyto (fhf);
+    for (int i = 0; i < nclients; i++)
+      fhf->client[i].fh = client[i].fh->fhandler_base::clone ();
+    return fhf;
   }
 };
 
index 1dcb3b3df3ed4f1a953957ef9a4d1f0cb31950f9..c295c2393c784f6c8b7b4e1bcac8355caa62341a 100644 (file)
@@ -816,6 +816,31 @@ fhandler_fifo::dup (fhandler_base *child, int flags)
       __seterrno ();
       return -1;
     }
+  for (int i = 0; i < nclients; i++)
+    {
+      if (!DuplicateHandle (GetCurrentProcess (), client[i].fh->get_handle (),
+                           GetCurrentProcess (),
+                           &fhf->client[i].fh->get_handle (),
+                           0, true, DUPLICATE_SAME_ACCESS)
+         || !DuplicateHandle (GetCurrentProcess (), client[i].connect_evt,
+                              GetCurrentProcess (),
+                              &fhf->client[i].connect_evt,
+                              0, true, DUPLICATE_SAME_ACCESS)
+         || !DuplicateHandle (GetCurrentProcess (), client[i].dummy_evt,
+                              GetCurrentProcess (),
+                              &fhf->client[i].dummy_evt,
+                              0, true, DUPLICATE_SAME_ACCESS))
+       {
+         CloseHandle (fhf->read_ready);
+         CloseHandle (fhf->write_ready);
+         fhf->close ();
+         __seterrno ();
+         return -1;
+       }
+    }
+  fhf->listen_client_thr = NULL;
+  fhf->lct_termination_evt = NULL;
+  fhf->fifo_client_unlock ();
   return 0;
 }
 
This page took 0.042505 seconds and 5 git commands to generate.