* 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:
		| @@ -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"); | ||||||
| @@ -245,6 +242,8 @@ struct mq_hdr | |||||||
|   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 */ | ||||||
|  |   char            mqh_uname[20]; /* unique name used to identify synchronization | ||||||
|  |   				    objects connected to this queue */ | ||||||
|   struct sigevent mqh_event;	 /* for mq_notify() */ |   struct sigevent mqh_event;	 /* for mq_notify() */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -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; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user