public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: POSIX msg queues: improve error output in fixup_after_fork
@ 2021-05-22 16:03 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2021-05-22 16:03 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=49b84cb264c3be68d8e15f8ccde28a92410a7c0c

commit 49b84cb264c3be68d8e15f8ccde28a92410a7c0c
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Fri May 21 17:47:14 2021 +0200

    Cygwin: POSIX msg queues: improve error output in fixup_after_fork
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler_mqueue.cc | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/winsup/cygwin/fhandler_mqueue.cc b/winsup/cygwin/fhandler_mqueue.cc
index 06ccf2f1e..6fc17c28c 100644
--- a/winsup/cygwin/fhandler_mqueue.cc
+++ b/winsup/cygwin/fhandler_mqueue.cc
@@ -136,28 +136,35 @@ fhandler_mqueue::fixup_after_fork (HANDLE parent)
       SIZE_T filesize = mqinfo ()->mqi_sectsize;
       NTSTATUS status;
 
-      DuplicateHandle (parent, mqinfo ()->mqi_sect,
-		       GetCurrentProcess (), &mqinfo ()->mqi_sect,
-		       0, FALSE, DUPLICATE_SAME_ACCESS);
+      if (!DuplicateHandle (parent, mqinfo ()->mqi_sect,
+			    GetCurrentProcess (), &mqinfo ()->mqi_sect,
+			    0, FALSE, DUPLICATE_SAME_ACCESS))
+	__leave;
       status = NtMapViewOfSection (mqinfo ()->mqi_sect, NtCurrentProcess (),
 				   &mptr, 0, filesize, NULL, &filesize,
 				   ViewShare, 0, PAGE_READWRITE);
       if (!NT_SUCCESS (status))
-	api_fatal ("Mapping message queue failed in fork\n");
-      else
-	mqinfo ()->mqi_hdr = (struct mq_hdr *) mptr;
-      DuplicateHandle (parent, mqinfo ()->mqi_waitsend,
-		       GetCurrentProcess (), &mqinfo ()->mqi_waitsend,
-		       0, FALSE, DUPLICATE_SAME_ACCESS);
-      DuplicateHandle (parent, mqinfo ()->mqi_waitrecv,
-		       GetCurrentProcess (), &mqinfo ()->mqi_waitrecv,
-		       0, FALSE, DUPLICATE_SAME_ACCESS);
-      DuplicateHandle (parent, mqinfo ()->mqi_lock,
-		       GetCurrentProcess (), &mqinfo ()->mqi_lock,
-		       0, FALSE, DUPLICATE_SAME_ACCESS);
+	api_fatal ("Mapping message queue failed in fork, status 0x%x\n",
+		   status);
+
+      mqinfo ()->mqi_hdr = (struct mq_hdr *) mptr;
+      if (!DuplicateHandle (parent, mqinfo ()->mqi_waitsend,
+			    GetCurrentProcess (), &mqinfo ()->mqi_waitsend,
+			    0, FALSE, DUPLICATE_SAME_ACCESS))
+	__leave;
+      if (!DuplicateHandle (parent, mqinfo ()->mqi_waitrecv,
+			    GetCurrentProcess (), &mqinfo ()->mqi_waitrecv,
+			    0, FALSE, DUPLICATE_SAME_ACCESS))
+	__leave;
+      if (!DuplicateHandle (parent, mqinfo ()->mqi_lock,
+			    GetCurrentProcess (), &mqinfo ()->mqi_lock,
+			    0, FALSE, DUPLICATE_SAME_ACCESS))
+	__leave;
+      return;
     }
   __except (EFAULT) {}
   __endtry
+  api_fatal ("Creating IPC object failed in fork, %E");
 }
 
 int


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-22 16:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-22 16:03 [newlib-cygwin] Cygwin: POSIX msg queues: improve error output in fixup_after_fork Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).