aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2021-05-11 12:04:38 -0400
committerKen Brown <kbrown@cornell.edu>2021-06-04 12:36:45 -0400
commit6172419ed2bc64c6ac3972ab05f17ac3d2952baf (patch)
treecf523f04fe4a25a60ecfffe0bb2777b04f3c7412
parent61116b051a08c49d0ecf972fdc10ec0a91f5314f (diff)
Cygwin: AF_UNIX: adapt close to mqueues
-rw-r--r--winsup/cygwin/fhandler_socket_unix.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc
index 07594d4b8..109cad4ba 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -1719,6 +1719,8 @@ fhandler_socket_unix::open (int flags, mode_t mode)
int
fhandler_socket_unix::close ()
{
+ int ret = 0;
+
if (get_flags () & O_PATH)
return fhandler_base::close ();
@@ -1747,7 +1749,15 @@ fhandler_socket_unix::close ()
param = InterlockedExchangePointer ((PVOID *) &shmem, NULL);
if (param)
NtUnmapViewOfSection (NtCurrentProcess (), param);
- return 0;
+ if (get_mqd_in () != (mqd_t) -1)
+ ret = mq_close (get_mqd_in ());
+ if (get_mqd_out () != (mqd_t) -1)
+ ret |= mq_close (get_mqd_out ());
+ /* FIXME: Maybe we should keep a reference count on the mqueues and
+ unlink it after the last one is close. OTOH, this will become
+ unnecessary if the mqueue implementation is changed to use
+ Windows shared memory. */
+ return ret;
}
int