[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 31/37: console: fix error and notification port handling
From: |
Samuel Thibault |
Subject: |
[hurd] 31/37: console: fix error and notification port handling |
Date: |
Mon, 09 Feb 2015 09:59:11 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to annotated tag upstream/hurd/0.5.git20150208
in repository hurd.
commit 508221b49ae825501882e228b18e4586e59e88b0
Author: Justus Winter <address@hidden>
Date: Tue Jan 20 20:01:43 2015 +0100
console: fix error and notification port handling
This fixes a deallocation of an invalid port notably seen on system
shutdown.
* console/display.c (free_modreqs): Handle errors of
`mach_port_request_notification' and check whether the old
notification port was valid.
(do_mach_notify_msg_accepted): Likewise.
(display_notice_filechange): Likewise.
---
console/display.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/console/display.c b/console/display.c
index 09add5c..eb420fd 100644
--- a/console/display.c
+++ b/console/display.c
@@ -298,16 +298,18 @@ nowait_file_changed (mach_port_t notify_port, natural_t
tickno,
static void
free_modreqs (struct modreq *mr)
{
+ error_t err;
struct modreq *tmp;
for (; mr; mr = tmp)
{
mach_port_t old;
/* Cancel the dead-name notification. */
- mach_port_request_notification (mach_task_self (), mr->port,
- MACH_NOTIFY_DEAD_NAME, 0,
- MACH_PORT_NULL,
- MACH_MSG_TYPE_MAKE_SEND_ONCE, &old);
- mach_port_deallocate (mach_task_self (), old);
+ err = mach_port_request_notification (mach_task_self (), mr->port,
+ MACH_NOTIFY_DEAD_NAME, 0,
+ MACH_PORT_NULL,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE, &old);
+ if (! err && MACH_PORT_VALID (old))
+ mach_port_deallocate (mach_task_self(), old);
/* Deallocate the user's port. */
mach_port_deallocate (mach_task_self (), mr->port);
@@ -438,16 +440,19 @@ do_mach_notify_msg_accepted (struct port_info *pi,
mach_port_t send)
notify_port->pi.port_right);
if (err && err != MACH_SEND_WILL_NOTIFY)
{
+ error_t e;
mach_port_t old;
*preq = req->next;
pthread_mutex_unlock (&display->lock);
- /* Cancel the dead-name notification. */
- mach_port_request_notification (mach_task_self (), req->port,
- MACH_NOTIFY_DEAD_NAME, 0,
- MACH_PORT_NULL,
- MACH_MSG_TYPE_MAKE_SEND_ONCE, &old);
- mach_port_deallocate (mach_task_self (), old);
+ /* Cancel the dead-name notification. */
+ e = mach_port_request_notification (mach_task_self (), req->port,
+ MACH_NOTIFY_DEAD_NAME, 0,
+ MACH_PORT_NULL,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE,
+ &old);
+ if (! e && MACH_PORT_VALID (old))
+ mach_port_deallocate (mach_task_self(), old);
mach_port_deallocate (mach_task_self (), req->port);
free (req);
@@ -564,13 +569,15 @@ display_notice_filechange (display_t display)
}
else
{
+ error_t e;
mach_port_t old;
/* Cancel the dead-name notification. */
- mach_port_request_notification (mach_task_self (), req->port,
- MACH_NOTIFY_DEAD_NAME, 0,
- MACH_PORT_NULL, 0, &old);
- mach_port_deallocate (mach_task_self (), old);
+ e = mach_port_request_notification (mach_task_self (), req->port,
+ MACH_NOTIFY_DEAD_NAME, 0,
+ MACH_PORT_NULL, 0, &old);
+ if (! e && MACH_PORT_VALID (old))
+ mach_port_deallocate (mach_task_self(), old);
mach_port_deallocate (mach_task_self (), req->port);
free (req);
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 12/37: Avoid ./ components in mtab output, (continued)
- [hurd] 12/37: Avoid ./ components in mtab output, Samuel Thibault, 2015/02/09
- [hurd] 10/37: Fix inclusion loop between hurd_types.defs and hurd/signal.h>, Samuel Thibault, 2015/02/09
- [hurd] 35/37: Explicit the keymap compatibility flags, Samuel Thibault, 2015/02/09
- [hurd] 03/37: proc: implement `proc_make_task_namespace', Samuel Thibault, 2015/02/09
- [hurd] 28/37: auth: simplify expression, Samuel Thibault, 2015/02/09
- [hurd] 29/37: auth: remove implicit assumption about the bootstrap process, Samuel Thibault, 2015/02/09
- [hurd] 22/37: Backport Linux changes for proper TCP EOF handling, Samuel Thibault, 2015/02/09
- [hurd] 05/37: libpager: remove the `seqno' parameters, Samuel Thibault, 2015/02/09
- [hurd] 06/37: libpager: use libports notification functions, Samuel Thibault, 2015/02/09
- [hurd] 09/37: Replace `bcopy' with `memcpy' or `memmove' as appropriate, Samuel Thibault, 2015/02/09
- [hurd] 31/37: console: fix error and notification port handling,
Samuel Thibault <=
- [hurd] 08/37: Replace `bzero' with `memset', Samuel Thibault, 2015/02/09
- [hurd] 04/37: hurd: add `proc_make_task_namespace', Samuel Thibault, 2015/02/09