mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix TCP_LINGER2 behavior to match linux.
We still deviate a bit from linux in how long we will actually wait in FIN-WAIT-2. Linux seems to cap it with TIME_WAIT_LEN and it's not completely obvious as to why it's done that way. For now I think we can ignore that and fix it if it really is an issue. PiperOrigin-RevId: 328324922
This commit is contained in:
committed by
gVisor bot
parent
c61f6fcf6a
commit
ae332d96e4
@@ -1409,8 +1409,12 @@ func getSockOptTCP(t *kernel.Task, ep commonEndpoint, name, outLen int) (marshal
|
||||
if err := ep.GetSockOpt(&v); err != nil {
|
||||
return nil, syserr.TranslateNetstackError(err)
|
||||
}
|
||||
|
||||
lingerTimeout := primitive.Int32(time.Duration(v) / time.Second)
|
||||
var lingerTimeout primitive.Int32
|
||||
if v >= 0 {
|
||||
lingerTimeout = primitive.Int32(time.Duration(v) / time.Second)
|
||||
} else {
|
||||
lingerTimeout = -1
|
||||
}
|
||||
return &lingerTimeout, nil
|
||||
|
||||
case linux.TCP_DEFER_ACCEPT:
|
||||
@@ -1967,7 +1971,7 @@ func setSockOptTCP(t *kernel.Task, ep commonEndpoint, name int, optVal []byte) *
|
||||
return syserr.ErrInvalidArgument
|
||||
}
|
||||
|
||||
v := usermem.ByteOrder.Uint32(optVal)
|
||||
v := int32(usermem.ByteOrder.Uint32(optVal))
|
||||
return syserr.TranslateNetstackError(ep.SetSockOpt(tcpip.TCPLingerTimeoutOption(time.Second * time.Duration(v))))
|
||||
|
||||
case linux.TCP_DEFER_ACCEPT:
|
||||
|
||||
Reference in New Issue
Block a user