diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-03-17 18:04:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-03-17 18:04:09 +0000 |
commit | 16c62b9c50eb76c44512c14b3d1b9f19e833ffd2 (patch) | |
tree | 2a00b9387355c30ce1c23425120b03f801c43a0c /sys | |
parent | dba0b8b3079550b1215eebbba61c1c712662d174 (diff) |
Adjust the number of processes waiting on a semaphore properly if we're
woken up in the middle of sleeping; cperciva@freebsd.org. OK deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/sysv_sem.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index a499b27a73f..66afb4ee348 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysv_sem.c,v 1.26 2004/03/13 07:17:39 tedu Exp $ */ +/* $OpenBSD: sysv_sem.c,v 1.27 2004/03/17 18:04:08 millert Exp $ */ /* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */ /* @@ -643,12 +643,6 @@ sys_semop(struct proc *p, void *v, register_t *retval) suptr = NULL; /* sem_undo may have been reallocated */ - if (error != 0) { - error = EINTR; - goto done2; - } - DPRINTF(("semop: good morning!\n")); - /* * Make sure that the semaphore still exists */ @@ -666,6 +660,17 @@ sys_semop(struct proc *p, void *v, register_t *retval) semptr->semzcnt--; else semptr->semncnt--; + + /* + * Is it really morning, or was our sleep interrupted? + * Delayed check of tsleep() return code because we + * need to decrement sem[nz]cnt either way.) + */ + if (error != 0) { + error = EINTR; + goto done2; + } + DPRINTF(("semop: good morning!\n")); } done: |