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

commit 6c901b928fd1a9b0e7a233912434910d74adc92d
Author: Corinna Vinschen <[email protected]>
Date:   Fri May 21 12:54:49 2021 +0200

    Cygwin: POSIX msg queues: use queue name as key
    
    Drop creating a unique ID, the queue name itself is already
    unique.  This allows to move ipc object generation into the
    fhandler in the next step.
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/mqueue_types.h |  9 ++++-----
 winsup/cygwin/posix_ipc.cc   | 13 ++++---------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/winsup/cygwin/mqueue_types.h b/winsup/cygwin/mqueue_types.h
index eab372238..2e6fd38c5 100644
--- a/winsup/cygwin/mqueue_types.h
+++ b/winsup/cygwin/mqueue_types.h
@@ -30,15 +30,14 @@ struct mq_hdr
   int32_t         mqh_free;     /* index of first free message */
   int32_t         mqh_nwait;    /* #threads blocked in mq_receive() */
   pid_t           mqh_pid;      /* nonzero PID if mqh_event set */
-  char            mqh_uname[36]; /* unique name used to identify 
synchronization
-                                   objects connected to this queue */
+  char            __mqh_ext[36]; /* free for extensions */
   union {
     struct sigevent mqh_event;  /* for mq_notify() */
     uint64_t        __mqh_dummy[4];
   };
-  uint64_t       __mgh_ext[4]; /* Free for extensions. */
-  uint32_t        mqh_magic;   /* Expect MQI_MAGIC here, otherwise it's
-                                  an old-style message queue. */
+  uint64_t       __mgh_ext2[4]; /* free for extensions */
+  uint32_t        mqh_magic;    /* Expect MQI_MAGIC here, otherwise it's
+                                   an old-style message queue. */
 };
 #pragma pack (pop)
 
diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc
index e239ca4c7..401c78dd7 100644
--- a/winsup/cygwin/posix_ipc.cc
+++ b/winsup/cygwin/posix_ipc.cc
@@ -102,7 +102,7 @@ ipc_mutex_init (HANDLE *pmtx, const char *name)
   OBJECT_ATTRIBUTES attr;
   NTSTATUS status;
 
-  __small_swprintf (buf, L"mqueue/mtx_%s", name);
+  __small_swprintf (buf, L"mqueue/mtx%s", name);
   RtlInitUnicodeString (&uname, buf);
   InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
                              get_shared_parent_dir (),
@@ -148,7 +148,7 @@ ipc_cond_init (HANDLE *pevt, const char *name, char sr)
   OBJECT_ATTRIBUTES attr;
   NTSTATUS status;
 
-  __small_swprintf (buf, L"mqueue/evt_%s%c", name, sr);
+  __small_swprintf (buf, L"mqueue/evt%s%c", name, sr);
   RtlInitUnicodeString (&uname, buf);
   InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
                              get_shared_parent_dir (),
@@ -422,7 +422,6 @@ mq_open (const char *name, int oflag, ...)
   struct msg_hdr *msghdr;
   struct mq_attr *attr;
   struct mq_info *mqinfo = NULL;
-  LUID luid;
 
   size_t len = strlen (name);
   char mqname[ipc_names[mqueue].prefix_len + len];
@@ -492,7 +491,7 @@ mq_open (const char *name, int oflag, ...)
          mqinfo = fh->mqinfo (name, mptr, secth, filesize, mode, nonblock);
 
          /* Initialize mutex & condition variables */
-         i = _mq_ipc_init (mqinfo, mqhdr->mqh_uname);
+         i = _mq_ipc_init (mqinfo, fh->get_name ());
          if (i != 0)
            {
              set_errno (i);
@@ -508,10 +507,6 @@ mq_open (const char *name, int oflag, ...)
          mqhdr->mqh_attr.mq_curmsgs = 0;
          mqhdr->mqh_nwait = 0;
          mqhdr->mqh_pid = 0;
-         NtAllocateLocallyUniqueId (&luid);
-         __small_sprintf (mqhdr->mqh_uname, "%016X%08x%08x",
-                          hash_path_name (0, mqname),
-                          luid.HighPart, luid.LowPart);
          mqhdr->mqh_head = 0;
          mqhdr->mqh_magic = MQI_MAGIC;
          index = sizeof (struct mq_hdr);
@@ -596,7 +591,7 @@ mq_open (const char *name, int oflag, ...)
                           nonblock);
 
       /* Initialize mutex & condition variable */
-      i = _mq_ipc_init (mqinfo, mqhdr->mqh_uname);
+      i = _mq_ipc_init (mqinfo, fh->get_name ());
       if (i != 0)
        {
          set_errno (i);

Reply via email to