mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix select call in socket utils
From the `select` manpage:
```
nfds This argument should be set to the highest-numbered file
descriptor in any of the three sets, plus 1...
```
PiperOrigin-RevId: 595697728
This commit is contained in:
@@ -771,7 +771,8 @@ PosixErrorOr<int> RecvTimeout(int sock, char buf[], int buf_size, int timeout) {
|
||||
FD_ZERO(&rfd);
|
||||
FD_SET(sock, &rfd);
|
||||
int ret;
|
||||
RETURN_ERROR_IF_SYSCALL_FAIL(ret = select(1, &rfd, NULL, NULL, to_ptr));
|
||||
RETURN_ERROR_IF_SYSCALL_FAIL(ret =
|
||||
select(sock + 1, &rfd, NULL, NULL, to_ptr));
|
||||
RETURN_ERROR_IF_SYSCALL_FAIL(
|
||||
ret = RetryEINTR(recv)(sock, buf, buf_size, MSG_DONTWAIT));
|
||||
return ret;
|
||||
@@ -785,7 +786,8 @@ PosixErrorOr<int> RecvMsgTimeout(int sock, struct msghdr* msg, int timeout) {
|
||||
FD_SET(sock, &rfd);
|
||||
|
||||
int ret;
|
||||
RETURN_ERROR_IF_SYSCALL_FAIL(ret = select(1, &rfd, NULL, NULL, to_ptr));
|
||||
RETURN_ERROR_IF_SYSCALL_FAIL(ret =
|
||||
select(sock + 1, &rfd, NULL, NULL, to_ptr));
|
||||
RETURN_ERROR_IF_SYSCALL_FAIL(
|
||||
ret = RetryEINTR(recvmsg)(sock, msg, MSG_DONTWAIT));
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user