From 356382a974a7bfb0dcb22e644286f4546433125b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 21 Feb 1996 20:16:42 +0000 Subject: (_pager_seqnos_memory_object_lock_completed): Be picky about always releasing SEQNO. --- libpager/lock-completed.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libpager') diff --git a/libpager/lock-completed.c b/libpager/lock-completed.c index 47a55064..45dbfcbf 100644 --- a/libpager/lock-completed.c +++ b/libpager/lock-completed.c @@ -29,6 +29,7 @@ _pager_seqnos_memory_object_lock_completed (mach_port_t object, vm_offset_t offset, vm_size_t length) { + error_t err = 0; struct pager *p; struct lock_request *lr; @@ -41,18 +42,18 @@ _pager_seqnos_memory_object_lock_completed (mach_port_t object, return EOPNOTSUPP; } + mutex_lock (&p->interlock); + _pager_wait_for_seqno (p, seqno); + if (control != p->memobjcntl) { printf ("lock_completed: bad control port\n"); - ports_port_deref (p); - return EPERM; + err = EPERM; + goto out; } mach_port_deallocate (mach_task_self (), control); - mutex_lock (&p->interlock); - _pager_wait_for_seqno (p, seqno); - for (lr = p->lock_requests; lr; lr = lr->next) if (lr->start == offset && lr->end == offset + length) { @@ -67,9 +68,10 @@ _pager_seqnos_memory_object_lock_completed (mach_port_t object, barf ("orphaned lock_request: p %#x ; offset %#x; length %#x\n", (int) p, p->port.port_right, offset, length); + out: _pager_release_seqno (p, seqno); mutex_unlock (&p->interlock); ports_port_deref (p); - return 0; + return err; } -- cgit v1.2.3