mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix data race in tty.queue.readableSize.
We were setting queue.readable without holding the lock. PiperOrigin-RevId: 290306922
This commit is contained in:
committed by
gVisor bot
parent
8e8d0f96f6
commit
80d0f93044
@@ -140,8 +140,10 @@ func (l *lineDiscipline) setTermios(ctx context.Context, io usermem.IO, args arc
|
||||
// buffer to its read buffer. Anything already in the read buffer is
|
||||
// now readable.
|
||||
if oldCanonEnabled && !l.termios.LEnabled(linux.ICANON) {
|
||||
l.inQueue.pushWaitBuf(l)
|
||||
l.inQueue.mu.Lock()
|
||||
l.inQueue.pushWaitBufLocked(l)
|
||||
l.inQueue.readable = true
|
||||
l.inQueue.mu.Unlock()
|
||||
l.slaveWaiter.Notify(waiter.EventIn)
|
||||
}
|
||||
|
||||
|
||||
@@ -197,16 +197,9 @@ func (q *queue) writeBytes(b []byte, l *lineDiscipline) {
|
||||
q.pushWaitBufLocked(l)
|
||||
}
|
||||
|
||||
// pushWaitBuf fills the queue's read buffer with data from the wait buffer.
|
||||
// pushWaitBufLocked fills the queue's read buffer with data from the wait
|
||||
// buffer.
|
||||
//
|
||||
// Preconditions:
|
||||
// * l.termiosMu must be held for reading.
|
||||
func (q *queue) pushWaitBuf(l *lineDiscipline) int {
|
||||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
return q.pushWaitBufLocked(l)
|
||||
}
|
||||
|
||||
// Preconditions:
|
||||
// * l.termiosMu must be held for reading.
|
||||
// * q.mu must be locked.
|
||||
|
||||
Reference in New Issue
Block a user