public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: POSIX msg queues: destroy msg queue fhandler in case of error Date: Fri, 21 May 2021 13:34:38 +0000 (GMT) [thread overview] Message-ID: <20210521133438.05C23398B8B7@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bce3563e988137a23a6867d749b727825a2ad96a commit bce3563e988137a23a6867d749b727825a2ad96a Author: Corinna Vinschen <corinna@vinschen.de> Date: Fri May 21 15:26:51 2021 +0200 Cygwin: POSIX msg queues: destroy msg queue fhandler in case of error ...and don't leave a descriptor dangling Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/posix_ipc.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc index fc483bdc8..8101a28f9 100644 --- a/winsup/cygwin/posix_ipc.cc +++ b/winsup/cygwin/posix_ipc.cc @@ -392,7 +392,6 @@ mq_open (const char *name, int oflag, ...) fh = (fhandler_mqueue *) build_fh_dev (*mqueue_dev, name); if (!fh) __leave; - fdm = fh; mqinfo = fh->mqinfo_create ((HANDLE) _get_osfhandle (fd), filesize, mode, nonblock); @@ -426,6 +425,7 @@ mq_open (const char *name, int oflag, ...) if (fchmod (fd, mode) == -1) __leave; close (fd); + fdm = fh; return (mqd_t) fdm; } @@ -468,7 +468,6 @@ mq_open (const char *name, int oflag, ...) fh = (fhandler_mqueue *) build_fh_dev (*mqueue_dev, name); if (!fh) __leave; - fdm = fh; mqinfo = fh->mqinfo_open ((HANDLE) _get_osfhandle (fd), statbuff.st_size, statbuff.st_mode, nonblock); @@ -476,6 +475,7 @@ mq_open (const char *name, int oflag, ...) __leave; close (fd); + fdm = fh; return (mqd_t) fdm; } __except (EFAULT) {} @@ -486,6 +486,11 @@ mq_open (const char *name, int oflag, ...) unlink (mqname); if (fd >= 0) close (fd); + if (fh) + { + fh->close (); + delete fh; + } return (mqd_t) -1; }
reply other threads:[~2021-05-21 13:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210521133438.05C23398B8B7@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).