summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpager/no-senders.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libpager/no-senders.c b/libpager/no-senders.c
index c75cb7e9..cd5e4fd3 100644
--- a/libpager/no-senders.c
+++ b/libpager/no-senders.c
@@ -23,6 +23,7 @@ pager_no_senders (struct pager *p,
{
mach_port_t old;
int ret;
+ int dealloc;
mutex_lock (&p->interlock);
_pager_wait_for_seqno (p, seqno);
@@ -31,10 +32,10 @@ pager_no_senders (struct pager *p,
if (mscount > p->mscount)
{
printf ("pager strange no senders\n");
- done_with_port (p);
+ dealloc = 1;
}
else if (mscount == p->mscount)
- done_with_port (p);
+ dealloc = 1;
else
{
/* Request a new notification. The sync value is because we might
@@ -46,7 +47,15 @@ pager_no_senders (struct pager *p,
MACH_MSG_TYPE_MAKE_SEND_ONCE, &old);
if (old)
mach_port_deallocate (mach_task_self (), old);
+ dealloc = 0;
}
+
+ mutex_unlock (&p->interlock);
+
+ if (dealloc)
+ done_with_port (p);
+
+ done_with_port (p); /* for previous check_port_type */
}