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:
parent
4fc922b2c8
commit
6c901b928f
winsup/cygwin
|
@ -30,13 +30,12 @@ struct mq_hdr
|
||||||
int32_t mqh_free; /* index of first free message */
|
int32_t mqh_free; /* index of first free message */
|
||||||
int32_t mqh_nwait; /* #threads blocked in mq_receive() */
|
int32_t mqh_nwait; /* #threads blocked in mq_receive() */
|
||||||
pid_t mqh_pid; /* nonzero PID if mqh_event set */
|
pid_t mqh_pid; /* nonzero PID if mqh_event set */
|
||||||
char mqh_uname[36]; /* unique name used to identify synchronization
|
char __mqh_ext[36]; /* free for extensions */
|
||||||
objects connected to this queue */
|
|
||||||
union {
|
union {
|
||||||
struct sigevent mqh_event; /* for mq_notify() */
|
struct sigevent mqh_event; /* for mq_notify() */
|
||||||
uint64_t __mqh_dummy[4];
|
uint64_t __mqh_dummy[4];
|
||||||
};
|
};
|
||||||
uint64_t __mgh_ext[4]; /* Free for extensions. */
|
uint64_t __mgh_ext2[4]; /* free for extensions */
|
||||||
uint32_t mqh_magic; /* Expect MQI_MAGIC here, otherwise it's
|
uint32_t mqh_magic; /* Expect MQI_MAGIC here, otherwise it's
|
||||||
an old-style message queue. */
|
an old-style message queue. */
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,7 +102,7 @@ ipc_mutex_init (HANDLE *pmtx, const char *name)
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
__small_swprintf (buf, L"mqueue/mtx_%s", name);
|
__small_swprintf (buf, L"mqueue/mtx%s", name);
|
||||||
RtlInitUnicodeString (&uname, buf);
|
RtlInitUnicodeString (&uname, buf);
|
||||||
InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
|
InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
|
||||||
get_shared_parent_dir (),
|
get_shared_parent_dir (),
|
||||||
|
@ -148,7 +148,7 @@ ipc_cond_init (HANDLE *pevt, const char *name, char sr)
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
NTSTATUS status;
|
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);
|
RtlInitUnicodeString (&uname, buf);
|
||||||
InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
|
InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
|
||||||
get_shared_parent_dir (),
|
get_shared_parent_dir (),
|
||||||
|
@ -422,7 +422,6 @@ mq_open (const char *name, int oflag, ...)
|
||||||
struct msg_hdr *msghdr;
|
struct msg_hdr *msghdr;
|
||||||
struct mq_attr *attr;
|
struct mq_attr *attr;
|
||||||
struct mq_info *mqinfo = NULL;
|
struct mq_info *mqinfo = NULL;
|
||||||
LUID luid;
|
|
||||||
|
|
||||||
size_t len = strlen (name);
|
size_t len = strlen (name);
|
||||||
char mqname[ipc_names[mqueue].prefix_len + len];
|
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);
|
mqinfo = fh->mqinfo (name, mptr, secth, filesize, mode, nonblock);
|
||||||
|
|
||||||
/* Initialize mutex & condition variables */
|
/* Initialize mutex & condition variables */
|
||||||
i = _mq_ipc_init (mqinfo, mqhdr->mqh_uname);
|
i = _mq_ipc_init (mqinfo, fh->get_name ());
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
set_errno (i);
|
set_errno (i);
|
||||||
|
@ -508,10 +507,6 @@ mq_open (const char *name, int oflag, ...)
|
||||||
mqhdr->mqh_attr.mq_curmsgs = 0;
|
mqhdr->mqh_attr.mq_curmsgs = 0;
|
||||||
mqhdr->mqh_nwait = 0;
|
mqhdr->mqh_nwait = 0;
|
||||||
mqhdr->mqh_pid = 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_head = 0;
|
||||||
mqhdr->mqh_magic = MQI_MAGIC;
|
mqhdr->mqh_magic = MQI_MAGIC;
|
||||||
index = sizeof (struct mq_hdr);
|
index = sizeof (struct mq_hdr);
|
||||||
|
@ -596,7 +591,7 @@ mq_open (const char *name, int oflag, ...)
|
||||||
nonblock);
|
nonblock);
|
||||||
|
|
||||||
/* Initialize mutex & condition variable */
|
/* Initialize mutex & condition variable */
|
||||||
i = _mq_ipc_init (mqinfo, mqhdr->mqh_uname);
|
i = _mq_ipc_init (mqinfo, fh->get_name ());
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
set_errno (i);
|
set_errno (i);
|
||||||
|
|
Loading…
Reference in New Issue