summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2009-04-03 04:22:50 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2009-04-03 04:22:50 +0000
commit3bc37cc8a8f123ba0ea675f851176b968296c53b (patch)
treed355faa7975ee42ec4a5bed62265629ec3b3d34d
parent0dd1a5b0d292dc56d5805f1a8b1b8e7295436846 (diff)
Fix SEM_UNDO handling for rthreads: use the struct process* instead
of the struct proc* as the identifier for SEM_UNDO tracking and only call semexit() from the original thread, once the process as a whole is exiting ok tedu@
-rw-r--r--sys/kern/kern_exit.c8
-rw-r--r--sys/kern/sysv_sem.c23
-rw-r--r--sys/sys/sem.h6
3 files changed, 18 insertions, 19 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index acb41b059d4..e69c45f2a6a 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.83 2009/03/26 17:24:33 oga Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.84 2009/04/03 04:22:49 guenther Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -60,9 +60,6 @@
#include <sys/ktrace.h>
#include <sys/pool.h>
#include <sys/mutex.h>
-#ifdef SYSVSHM
-#include <sys/shm.h>
-#endif
#ifdef SYSVSEM
#include <sys/sem.h>
#endif
@@ -183,7 +180,8 @@ exit1(struct proc *p, int rv, int flags)
fdfree(p);
#ifdef SYSVSEM
- semexit(p);
+ if ((p->p_flag & P_THREAD) == 0)
+ semexit(p->p_p);
#endif
if (SESS_LEADER(p)) {
struct session *sp = p->p_session;
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 16404a980cb..65183bde21a 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.37 2009/01/15 22:54:21 oga Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.38 2009/04/03 04:22:49 guenther Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -54,7 +54,7 @@ struct pool sema_pool; /* pool for struct semid_ds */
struct pool semu_pool; /* pool for struct sem_undo (SEMUSZ) */
unsigned short *semseqs; /* array of sem sequence numbers */
-struct sem_undo *semu_alloc(struct proc *);
+struct sem_undo *semu_alloc(struct process *);
int semundo_adjust(struct proc *, struct sem_undo **, int, int, int);
void semundo_clear(int, int);
@@ -78,7 +78,7 @@ seminit(void)
* (returns ptr to structure or NULL if no more room)
*/
struct sem_undo *
-semu_alloc(struct proc *p)
+semu_alloc(struct process *pr)
{
struct sem_undo *suptr, *sutmp;
@@ -88,13 +88,13 @@ semu_alloc(struct proc *p)
/*
* Allocate a semu w/o waiting if possible.
* If we do have to wait, we must check to verify that a semu
- * with un_proc == p has not been allocated in the meantime.
+ * with un_proc == pr has not been allocated in the meantime.
*/
semutot++;
if ((suptr = pool_get(&semu_pool, 0)) == NULL) {
sutmp = pool_get(&semu_pool, PR_WAITOK);
SLIST_FOREACH(suptr, &semu_list, un_next) {
- if (suptr->un_proc == p) {
+ if (suptr->un_proc == pr) {
pool_put(&semu_pool, sutmp);
semutot--;
return (suptr);
@@ -103,7 +103,7 @@ semu_alloc(struct proc *p)
suptr = sutmp;
}
suptr->un_cnt = 0;
- suptr->un_proc = p;
+ suptr->un_proc = pr;
SLIST_INSERT_HEAD(&semu_list, suptr, un_next);
return (suptr);
}
@@ -115,6 +115,7 @@ int
semundo_adjust(struct proc *p, struct sem_undo **supptr, int semid, int semnum,
int adjval)
{
+ struct process *pr = p->p_p;
struct sem_undo *suptr;
struct undo *sunptr;
int i;
@@ -125,7 +126,7 @@ semundo_adjust(struct proc *p, struct sem_undo **supptr, int semid, int semnum,
suptr = *supptr;
if (suptr == NULL) {
SLIST_FOREACH(suptr, &semu_list, un_next) {
- if (suptr->un_proc == p) {
+ if (suptr->un_proc == pr) {
*supptr = suptr;
break;
}
@@ -133,7 +134,7 @@ semundo_adjust(struct proc *p, struct sem_undo **supptr, int semid, int semnum,
if (suptr == NULL) {
if (adjval == 0)
return (0);
- suptr = semu_alloc(p);
+ suptr = semu_alloc(p->p_p);
if (suptr == NULL)
return (ENOSPC);
*supptr = suptr;
@@ -740,7 +741,7 @@ done2:
* semaphores.
*/
void
-semexit(struct proc *p)
+semexit(struct process *pr)
{
struct sem_undo *suptr;
struct sem_undo **supptr;
@@ -750,7 +751,7 @@ semexit(struct proc *p)
* this process.
*/
SLIST_FOREACH_PREVPTR(suptr, supptr, &semu_list, un_next) {
- if (suptr->un_proc == p)
+ if (suptr->un_proc == pr)
break;
}
@@ -763,7 +764,7 @@ semexit(struct proc *p)
/*
* We now have an undo vector for this process.
*/
- DPRINTF(("proc @%p has undo structure with %d entries\n", p,
+ DPRINTF(("process @%p has undo structure with %d entries\n", pr,
suptr->un_cnt));
/*
diff --git a/sys/sys/sem.h b/sys/sys/sem.h
index f686d689864..e42deabb050 100644
--- a/sys/sys/sem.h
+++ b/sys/sys/sem.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.h,v 1.19 2005/12/13 00:35:23 millert Exp $ */
+/* $OpenBSD: sem.h,v 1.20 2009/04/03 04:22:49 guenther Exp $ */
/* $NetBSD: sem.h,v 1.8 1996/02/09 18:25:29 christos Exp $ */
/*
@@ -143,7 +143,7 @@ union semun {
*/
struct sem_undo {
SLIST_ENTRY(sem_undo) un_next; /* ptr to next active undo structure */
- struct proc *un_proc; /* owner of this structure */
+ struct process *un_proc; /* owner of this structure */
short un_cnt; /* # of active entries */
struct undo {
short un_adjval; /* adjust on exit values */
@@ -215,7 +215,7 @@ int semconfig(int);
__END_DECLS
#else
void seminit(void);
-void semexit(struct proc *);
+void semexit(struct process *);
int sysctl_sysvsem(int *, u_int, void *, size_t *, void *, size_t);
int semctl1(struct proc *, int, int, int, union semun *, register_t *,
int (*)(const void *, void *, size_t),