mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Epsocket has incorrect recv(2) behavior after SHUT_RD.
After shutdown(SHUT_RD) calls to recv /w MSG_DONTWAIT or with O_NONBLOCK should result in a EAGAIN and not 0. Blocking sockets should return 0 as they would have otherwise blocked indefinitely. PiperOrigin-RevId: 201271123 Change-Id: If589b69c17fa5b9ff05bcf9e44024da9588c8876
This commit is contained in:
@@ -952,6 +952,12 @@ func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
|
||||
senderRequested = false
|
||||
}
|
||||
n, senderAddr, senderAddrLen, controlMessages, err = s.nonBlockingRead(t, dst, peek, trunc, senderRequested)
|
||||
|
||||
if err == syserr.ErrClosedForReceive && flags&linux.MSG_DONTWAIT != 0 {
|
||||
// In this situation we should return EAGAIN.
|
||||
return 0, nil, 0, socket.ControlMessages{}, syserr.ErrTryAgain
|
||||
}
|
||||
|
||||
if err != syserr.ErrWouldBlock || flags&linux.MSG_DONTWAIT != 0 {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user