mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Yield thread group leader *Task in TaskSet.ForEachThreadGroup.
This makes this function usable from outside of the `kernel` package without needing to call `tg.Leader()` (which requires a lock that `TaskSet.ForEachThreadGroup` already acquires). PiperOrigin-RevId: 721168957
This commit is contained in:
committed by
gVisor bot
parent
8bdf76c5ca
commit
04f9204697
@@ -198,7 +198,7 @@ func (pg *ProcessGroup) handleOrphan() {
|
||||
|
||||
// See if there are any stopped jobs.
|
||||
hasStopped := false
|
||||
pg.originator.pidns.owner.forEachThreadGroupLocked(func(tg *ThreadGroup) {
|
||||
pg.originator.pidns.owner.forEachThreadGroupLocked(func(tg *ThreadGroup, _ *Task) {
|
||||
if tg.processGroup != pg {
|
||||
return
|
||||
}
|
||||
@@ -213,13 +213,13 @@ func (pg *ProcessGroup) handleOrphan() {
|
||||
}
|
||||
|
||||
// Deliver appropriate signals to all thread groups.
|
||||
pg.originator.pidns.owner.forEachThreadGroupLocked(func(tg *ThreadGroup) {
|
||||
pg.originator.pidns.owner.forEachThreadGroupLocked(func(tg *ThreadGroup, tgLeader *Task) {
|
||||
if tg.processGroup != pg {
|
||||
return
|
||||
}
|
||||
tg.signalHandlers.mu.NestedLock(signalHandlersLockTg)
|
||||
tg.leader.sendSignalLocked(SignalInfoPriv(linux.SIGHUP), true /* group */)
|
||||
tg.leader.sendSignalLocked(SignalInfoPriv(linux.SIGCONT), true /* group */)
|
||||
tgLeader.sendSignalLocked(SignalInfoPriv(linux.SIGHUP), true /* group */)
|
||||
tgLeader.sendSignalLocked(SignalInfoPriv(linux.SIGCONT), true /* group */)
|
||||
tg.signalHandlers.mu.NestedUnlock(signalHandlersLockTg)
|
||||
})
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func newTaskSet(pidns *PIDNamespace) *TaskSet {
|
||||
}
|
||||
|
||||
// ForEachThreadGroup applies f to each thread group in ts.
|
||||
func (ts *TaskSet) ForEachThreadGroup(f func(tg *ThreadGroup)) {
|
||||
func (ts *TaskSet) ForEachThreadGroup(f func(tg *ThreadGroup, tgLeader *Task)) {
|
||||
ts.mu.RLock()
|
||||
defer ts.mu.RUnlock()
|
||||
ts.forEachThreadGroupLocked(f)
|
||||
@@ -122,9 +122,9 @@ func (ts *TaskSet) ForEachThreadGroup(f func(tg *ThreadGroup)) {
|
||||
// forEachThreadGroupLocked applies f to each thread group in ts.
|
||||
//
|
||||
// Preconditions: ts.mu must be locked (for reading or writing).
|
||||
func (ts *TaskSet) forEachThreadGroupLocked(f func(tg *ThreadGroup)) {
|
||||
func (ts *TaskSet) forEachThreadGroupLocked(f func(tg *ThreadGroup, tgLeader *Task)) {
|
||||
for tg := range ts.Root.tgids {
|
||||
f(tg)
|
||||
f(tg, tg.leader)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user