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 <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2021-05-21 12:54:49 +02:00
parent 4fc922b2c8
commit 6c901b928f
2 changed files with 8 additions and 14 deletions

View File

@ -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)

View File

@ -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);