* posix_ipc.cc (ipc_mutex_init): Create global object name.
(ipc_cond_init): Ditto. (struct mq_hdr): Add mqh_uname member to store synchronization object name. (mq_open): Create unique synchronization object name and store in mq_hdr->mqh_uname. Use this name in calls to ipc_mutex_init and ipc_cond_init.
This commit is contained in:
parent
868281075d
commit
93162be554
@ -1,3 +1,13 @@
|
|||||||
|
2007-02-15 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* posix_ipc.cc (ipc_mutex_init): Create global object name.
|
||||||
|
(ipc_cond_init): Ditto.
|
||||||
|
(struct mq_hdr): Add mqh_uname member to store synchronization object
|
||||||
|
name.
|
||||||
|
(mq_open): Create unique synchronization object name and store in
|
||||||
|
mq_hdr->mqh_uname. Use this name in calls to ipc_mutex_init and
|
||||||
|
ipc_cond_init.
|
||||||
|
|
||||||
2007-02-14 Corinna Vinschen <corinna@vinschen.de>
|
2007-02-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* Makefile.in (DLL_OFILES): Add posix_ipc.o.
|
* Makefile.in (DLL_OFILES): Add posix_ipc.o.
|
||||||
|
@ -90,10 +90,8 @@ static int
|
|||||||
ipc_mutex_init (HANDLE *pmtx, const char *name)
|
ipc_mutex_init (HANDLE *pmtx, const char *name)
|
||||||
{
|
{
|
||||||
char buf[CYG_MAX_PATH];
|
char buf[CYG_MAX_PATH];
|
||||||
strcpy (buf, "cyg_pmtx");
|
__small_sprintf (buf, "%scyg_pmtx/%s",
|
||||||
strcat (buf, name);
|
wincap.has_terminal_services () ? "Global\\" : "", name);
|
||||||
for (char *c = buf; c = strchr (c + 1, '\\'); ++c)
|
|
||||||
*c = '/';
|
|
||||||
*pmtx = CreateMutex (&sec_all, FALSE, buf);
|
*pmtx = CreateMutex (&sec_all, FALSE, buf);
|
||||||
if (!*pmtx)
|
if (!*pmtx)
|
||||||
debug_printf ("failed: %E\n");
|
debug_printf ("failed: %E\n");
|
||||||
@ -135,10 +133,9 @@ static int
|
|||||||
ipc_cond_init (HANDLE *pevt, const char *name)
|
ipc_cond_init (HANDLE *pevt, const char *name)
|
||||||
{
|
{
|
||||||
char buf[CYG_MAX_PATH];
|
char buf[CYG_MAX_PATH];
|
||||||
strcpy (buf, "cyg_pevt");
|
strcpy (buf, wincap.has_terminal_services () ? "Global\\" : "");
|
||||||
strcat (buf, name);
|
__small_sprintf (buf, "%scyg_pevt/%s",
|
||||||
for (char *c = buf; c = strchr (c + 1, '\\'); ++c)
|
wincap.has_terminal_services () ? "Global\\" : "", name);
|
||||||
*c = '/';
|
|
||||||
*pevt = CreateEvent (&sec_all, TRUE, FALSE, buf);
|
*pevt = CreateEvent (&sec_all, TRUE, FALSE, buf);
|
||||||
if (!*pevt)
|
if (!*pevt)
|
||||||
debug_printf ("failed: %E\n");
|
debug_printf ("failed: %E\n");
|
||||||
@ -240,28 +237,30 @@ shm_unlink (const char *name)
|
|||||||
|
|
||||||
struct mq_hdr
|
struct mq_hdr
|
||||||
{
|
{
|
||||||
struct mq_attr mqh_attr; /* the queue's attributes */
|
struct mq_attr mqh_attr; /* the queue's attributes */
|
||||||
long mqh_head; /* index of first message */
|
long mqh_head; /* index of first message */
|
||||||
long mqh_free; /* index of first free message */
|
long mqh_free; /* index of first free message */
|
||||||
long mqh_nwait; /* #threads blocked in mq_receive() */
|
long 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 */
|
||||||
struct sigevent mqh_event; /* for mq_notify() */
|
char mqh_uname[20]; /* unique name used to identify synchronization
|
||||||
|
objects connected to this queue */
|
||||||
|
struct sigevent mqh_event; /* for mq_notify() */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msg_hdr
|
struct msg_hdr
|
||||||
{
|
{
|
||||||
long msg_next; /* index of next on linked list */
|
long msg_next; /* index of next on linked list */
|
||||||
ssize_t msg_len; /* actual length */
|
ssize_t msg_len; /* actual length */
|
||||||
unsigned int msg_prio; /* priority */
|
unsigned int msg_prio; /* priority */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mq_info
|
struct mq_info
|
||||||
{
|
{
|
||||||
struct mq_hdr *mqi_hdr; /* start of mmap'ed region */
|
struct mq_hdr *mqi_hdr; /* start of mmap'ed region */
|
||||||
unsigned long mqi_magic; /* magic number if open */
|
unsigned long mqi_magic; /* magic number if open */
|
||||||
int mqi_flags; /* flags for this process */
|
int mqi_flags; /* flags for this process */
|
||||||
HANDLE mqi_lock; /* mutex lock */
|
HANDLE mqi_lock; /* mutex lock */
|
||||||
HANDLE mqi_wait; /* and condition variable */
|
HANDLE mqi_wait; /* and condition variable */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MQI_MAGIC 0x98765432UL
|
#define MQI_MAGIC 0x98765432UL
|
||||||
@ -359,6 +358,7 @@ again:
|
|||||||
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;
|
||||||
|
__small_sprintf (mqhdr->mqh_uname, "cyg%016X", hash_path_name (0,mqname));
|
||||||
mqhdr->mqh_head = 0;
|
mqhdr->mqh_head = 0;
|
||||||
index = sizeof (struct mq_hdr);
|
index = sizeof (struct mq_hdr);
|
||||||
mqhdr->mqh_free = index;
|
mqhdr->mqh_free = index;
|
||||||
@ -372,11 +372,11 @@ again:
|
|||||||
msghdr->msg_next = 0; /* end of free list */
|
msghdr->msg_next = 0; /* end of free list */
|
||||||
|
|
||||||
/* Initialize mutex & condition variable */
|
/* Initialize mutex & condition variable */
|
||||||
i = ipc_mutex_init (&mqinfo->mqi_lock, mqname);
|
i = ipc_mutex_init (&mqinfo->mqi_lock, mqhdr->mqh_uname);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
goto pthreaderr;
|
goto pthreaderr;
|
||||||
|
|
||||||
i = ipc_cond_init (&mqinfo->mqi_wait, mqname);
|
i = ipc_cond_init (&mqinfo->mqi_wait, mqhdr->mqh_uname);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
goto pthreaderr;
|
goto pthreaderr;
|
||||||
|
|
||||||
@ -432,11 +432,11 @@ exists:
|
|||||||
mqinfo->mqi_flags = nonblock;
|
mqinfo->mqi_flags = nonblock;
|
||||||
|
|
||||||
/* Initialize mutex & condition variable */
|
/* Initialize mutex & condition variable */
|
||||||
i = ipc_mutex_init (&mqinfo->mqi_lock, mqname);
|
i = ipc_mutex_init (&mqinfo->mqi_lock, mqhdr->mqh_uname);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
goto pthreaderr;
|
goto pthreaderr;
|
||||||
|
|
||||||
i = ipc_cond_init (&mqinfo->mqi_wait, mqname);
|
i = ipc_cond_init (&mqinfo->mqi_wait, mqhdr->mqh_uname);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
goto pthreaderr;
|
goto pthreaderr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user