* posix_ipc.cc (ipc_mutex_lock): Add bool parameter to influence if

cygwait should be in EINTR or in restart mode.  Call signal handler
	if in EINTR mode.
	(mq_getattr): Call ipc_mutex_lock in restart mode.
	(mq_setattr): Ditto.
	(mq_notify): Ditto.
	(_mq_send): Call ipc_mutex_lock in EINTR mode.
	(_mq_receive): Ditto.
This commit is contained in:
Corinna Vinschen 2015-02-26 17:00:11 +00:00
parent 31c123f982
commit c6d1382a1a
2 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2015-02-26 Corinna Vinschen <corinna@vinschen.de>
* posix_ipc.cc (ipc_mutex_lock): Add bool parameter to influence if
cygwait should be in EINTR or in restart mode. Call signal handler
if in EINTR mode.
(mq_getattr): Call ipc_mutex_lock in restart mode.
(mq_setattr): Ditto.
(mq_notify): Ditto.
(_mq_send): Call ipc_mutex_lock in EINTR mode.
(_mq_receive): Ditto.
2015-02-26 Corinna Vinschen <corinna@vinschen.de> 2015-02-26 Corinna Vinschen <corinna@vinschen.de>
* fhandler_termios.cc (fhandler_termios::line_edit): Fix condition * fhandler_termios.cc (fhandler_termios::line_edit): Fix condition

View File

@ -1,6 +1,6 @@
/* posix_ipc.cc: POSIX IPC API for Cygwin. /* posix_ipc.cc: POSIX IPC API for Cygwin.
Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014 Red Hat, Inc. Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -117,14 +117,16 @@ ipc_mutex_init (HANDLE *pmtx, const char *name)
} }
static int static int
ipc_mutex_lock (HANDLE mtx) ipc_mutex_lock (HANDLE mtx, bool eintr)
{ {
switch (cygwait (mtx, cw_infinite, cw_sig_eintr | cw_cancel | cw_cancel_self)) switch (cygwait (mtx, cw_infinite, cw_cancel | cw_cancel_self
| (eintr ? cw_sig_eintr : cw_sig_restart)))
{ {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
case WAIT_ABANDONED_0: case WAIT_ABANDONED_0:
return 0; return 0;
case WAIT_SIGNALED: case WAIT_SIGNALED:
_my_tls.call_signal_handler ();
set_errno (EINTR); set_errno (EINTR);
return 1; return 1;
default: default:
@ -662,7 +664,7 @@ mq_getattr (mqd_t mqd, struct mq_attr *mqstat)
} }
mqhdr = mqinfo->mqi_hdr; mqhdr = mqinfo->mqi_hdr;
attr = &mqhdr->mqh_attr; attr = &mqhdr->mqh_attr;
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) if ((n = ipc_mutex_lock (mqinfo->mqi_lock, false)) != 0)
{ {
errno = n; errno = n;
__leave; __leave;
@ -698,7 +700,7 @@ mq_setattr (mqd_t mqd, const struct mq_attr *mqstat, struct mq_attr *omqstat)
} }
mqhdr = mqinfo->mqi_hdr; mqhdr = mqinfo->mqi_hdr;
attr = &mqhdr->mqh_attr; attr = &mqhdr->mqh_attr;
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) if ((n = ipc_mutex_lock (mqinfo->mqi_lock, false)) != 0)
{ {
errno = n; errno = n;
__leave; __leave;
@ -742,7 +744,7 @@ mq_notify (mqd_t mqd, const struct sigevent *notification)
__leave; __leave;
} }
mqhdr = mqinfo->mqi_hdr; mqhdr = mqinfo->mqi_hdr;
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) if ((n = ipc_mutex_lock (mqinfo->mqi_lock, false)) != 0)
{ {
errno = n; errno = n;
__leave; __leave;
@ -810,7 +812,7 @@ _mq_send (mqd_t mqd, const char *ptr, size_t len, unsigned int prio,
mqhdr = mqinfo->mqi_hdr; /* struct pointer */ mqhdr = mqinfo->mqi_hdr; /* struct pointer */
mptr = (int8_t *) mqhdr; /* byte pointer */ mptr = (int8_t *) mqhdr; /* byte pointer */
attr = &mqhdr->mqh_attr; attr = &mqhdr->mqh_attr;
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) if ((n = ipc_mutex_lock (mqinfo->mqi_lock, true)) != 0)
{ {
errno = n; errno = n;
__leave; __leave;
@ -938,7 +940,7 @@ _mq_receive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop,
mqhdr = mqinfo->mqi_hdr; /* struct pointer */ mqhdr = mqinfo->mqi_hdr; /* struct pointer */
mptr = (int8_t *) mqhdr; /* byte pointer */ mptr = (int8_t *) mqhdr; /* byte pointer */
attr = &mqhdr->mqh_attr; attr = &mqhdr->mqh_attr;
if ((n = ipc_mutex_lock (mqinfo->mqi_lock)) != 0) if ((n = ipc_mutex_lock (mqinfo->mqi_lock, true)) != 0)
{ {
errno = n; errno = n;
__leave; __leave;