Notify master waiter when all replicas are closed.

Fixes #9951
Fixes #9333

PiperOrigin-RevId: 605462571
This commit is contained in:
Ayush Ranjan
2024-02-08 16:41:01 -08:00
committed by gVisor bot
parent ca695a9e08
commit cdededb792
2 changed files with 58 additions and 4 deletions
+13 -4
View File
@@ -180,9 +180,14 @@ func (l *lineDiscipline) setWindowSize(t *kernel.Task, args arch.SyscallArgument
}
func (l *lineDiscipline) masterReadiness() waiter.EventMask {
// We don't have to lock a termios because the default master termios
// is immutable.
return l.inQueue.writeReadiness(&linux.MasterTermios) | l.outQueue.readReadiness(&linux.MasterTermios)
// The master termios is immutable so termiosMu is not needed.
res := l.inQueue.writeReadiness(&linux.MasterTermios) | l.outQueue.readReadiness(&linux.MasterTermios)
l.termiosMu.RLock()
if l.numReplicas == 0 {
res |= waiter.EventHUp
}
l.termiosMu.RUnlock()
return res
}
func (l *lineDiscipline) replicaReadiness() waiter.EventMask {
@@ -285,8 +290,12 @@ func (l *lineDiscipline) replicaOpen() {
// replicaClose is called when a replica file descriptor is closed.
func (l *lineDiscipline) replicaClose() {
l.termiosMu.Lock()
defer l.termiosMu.Unlock()
l.numReplicas--
notify := l.numReplicas == 0
l.termiosMu.Unlock()
if notify {
l.masterWaiter.Notify(waiter.EventHUp)
}
}
// transformer is a helper interface to make it easier to stateify queue.