aboutsummaryrefslogtreecommitdiff
path: root/console
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2021-08-05 19:12:42 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-10 22:13:56 +0200
commita7e36189261bc1a8dc08744cea976c88fbe4c27c (patch)
tree0eb394ddb27ad70971519533007963e348ddf013 /console
parentf589b48217e6593714e80e2a043fb8fd382acff8 (diff)
downloadhurd-a7e36189261bc1a8dc08744cea976c88fbe4c27c.tar.gz
hurd-a7e36189261bc1a8dc08744cea976c88fbe4c27c.tar.bz2
hurd-a7e36189261bc1a8dc08744cea976c88fbe4c27c.zip
console: Simplify code with ports_request_dead_name_notification ()
We can't use it to *request* notifications here, since we need to use a custom per-display port (and not libports' notify_port), but we can still use it to *cancel* notifications with a lot less boilerplate.
Diffstat (limited to 'console')
-rw-r--r--console/display.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/console/display.c b/console/display.c
index cff99be3..f137a7a4 100644
--- a/console/display.c
+++ b/console/display.c
@@ -298,18 +298,11 @@ 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. */
- 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);
+ ports_request_dead_name_notification (NULL, mr->port, NULL);
/* Deallocate the user's port. */
mach_port_deallocate (mach_task_self (), mr->port);
@@ -440,19 +433,11 @@ 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. */
- 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);
+ ports_request_dead_name_notification (NULL, req->port, NULL);
mach_port_deallocate (mach_task_self (), req->port);
free (req);
@@ -569,15 +554,8 @@ display_notice_filechange (display_t display)
}
else
{
- error_t e;
- mach_port_t old;
-
/* Cancel the dead-name notification. */
- 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);
+ ports_request_dead_name_notification (NULL, req->port, NULL);
mach_port_deallocate (mach_task_self (), req->port);
free (req);
}