diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-09-21 13:49:26 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-09-21 13:49:26 +0000 |
commit | 90355ef7a8f04f4c6e4f37793c1026b14eb5bdda (patch) | |
tree | e0409ce34355aeee7d2fe88006a92b0db32a311e /sys | |
parent | 2248ad4f8fa66aca15ff41f562668761b48f9659 (diff) |
Move code inside exit1() to better spots.
- PS_PROFIL bit is moved into the process cleanup block where it belongs
- The proc read-only limit cache cleanup is moved up right after clearing
p->p_fd cache. lim_free() can potentially sleep and so needs to be
above the line where p_stat is set to SDEAD.
With and OK jca@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_exit.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 4d7bfd5fddb..f57d48415ef 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.215 2023/09/13 14:25:49 claudio Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.216 2023/09/21 13:49:25 claudio Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -165,8 +165,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags) /* main thread gotta wait because it has the pid, et al */ while (pr->ps_threadcnt > 1) tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP); - if (pr->ps_flags & PS_PROFIL) - stopprofclock(pr); } rup = pr->ps_ru; @@ -190,6 +188,9 @@ exit1(struct proc *p, int xexit, int xsig, int flags) #endif if ((p->p_flag & P_THREAD) == 0) { + if (pr->ps_flags & PS_PROFIL) + stopprofclock(pr); + sigio_freelist(&pr->ps_sigiolst); /* close open files and release open-file table */ @@ -224,6 +225,15 @@ exit1(struct proc *p, int xexit, int xsig, int flags) p->p_fd = NULL; /* zap the thread's copy */ + /* Release the thread's read reference of resource limit structure. */ + if (p->p_limit != NULL) { + struct plimit *limit; + + limit = p->p_limit; + p->p_limit = NULL; + lim_free(limit); + } + /* * Remove proc from pidhash chain and allproc so looking * it up won't work. We will put the proc on the @@ -342,15 +352,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags) KASSERT(pr->ps_threadcnt > 0); } - /* Release the thread's read reference of resource limit structure. */ - if (p->p_limit != NULL) { - struct plimit *limit; - - limit = p->p_limit; - p->p_limit = NULL; - lim_free(limit); - } - /* * Other substructures are freed from reaper and wait(). */ |