thread: tidy up r367543

"locked" variable is spurious in the committed version.
This commit is contained in:
Mateusz Guzik 2020-11-10 21:29:10 +00:00
parent d8033dc3d3
commit 40aad3e477

View File

@ -2748,7 +2748,6 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS)
struct stack *st; struct stack *st;
struct sbuf sb; struct sbuf sb;
struct proc *p; struct proc *p;
bool locked;
name = (int *)arg1; name = (int *)arg1;
error = pget((pid_t)name[0], PGET_NOTINEXEC | PGET_WANTREAD, &p); error = pget((pid_t)name[0], PGET_NOTINEXEC | PGET_WANTREAD, &p);
@ -2789,14 +2788,12 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS)
i++; i++;
} }
PROC_UNLOCK(p); PROC_UNLOCK(p);
locked = false;
numthreads = i; numthreads = i;
for (i = 0; i < numthreads; i++) { for (i = 0; i < numthreads; i++) {
td = tdfind(lwpidarray[i], p->p_pid); td = tdfind(lwpidarray[i], p->p_pid);
if (td == NULL) { if (td == NULL) {
continue; continue;
} }
locked = true;
bzero(kkstp, sizeof(*kkstp)); bzero(kkstp, sizeof(*kkstp));
(void)sbuf_new(&sb, kkstp->kkst_trace, (void)sbuf_new(&sb, kkstp->kkst_trace,
sizeof(kkstp->kkst_trace), SBUF_FIXEDLEN); sizeof(kkstp->kkst_trace), SBUF_FIXEDLEN);
@ -2810,7 +2807,6 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS)
kkstp->kkst_state = KKST_STATE_RUNNING; kkstp->kkst_state = KKST_STATE_RUNNING;
thread_unlock(td); thread_unlock(td);
PROC_UNLOCK(p); PROC_UNLOCK(p);
locked = false;
stack_sbuf_print(&sb, st); stack_sbuf_print(&sb, st);
sbuf_finish(&sb); sbuf_finish(&sb);
sbuf_delete(&sb); sbuf_delete(&sb);
@ -2818,10 +2814,7 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS)
if (error) if (error)
break; break;
} }
if (!locked) PRELE(p);
PROC_LOCK(p);
_PRELE(p);
PROC_UNLOCK(p);
if (lwpidarray != NULL) if (lwpidarray != NULL)
free(lwpidarray, M_TEMP); free(lwpidarray, M_TEMP);
stack_destroy(st); stack_destroy(st);