Skip to content

Commit 2e87162

Browse files
committed
test: specify timeout as 0 to select when expecting nonblocking
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
1 parent 23a3811 commit 2e87162

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

test/sockets/test_sockets_echo_client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ void main_loop() {
6767
fd_set fdr;
6868
fd_set fdw;
6969
int res;
70+
struct timeval tv;
7071

7172
// make sure that server.fd is ready to read / write
7273
FD_ZERO(&fdr);
7374
FD_ZERO(&fdw);
7475
FD_SET(server.fd, &fdr);
7576
FD_SET(server.fd, &fdw);
76-
res = select(64, &fdr, &fdw, NULL, NULL);
77+
tv.tv_sec = 0;
78+
tv.tv_usec = 0;
79+
res = select(64, &fdr, &fdw, NULL, &tv);
7780
if (res == -1) {
7881
perror("select failed");
7982
finish(EXIT_FAILURE);

test/sockets/test_sockets_echo_server.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ void main_loop() {
7777
int res;
7878
fd_set fdr;
7979
fd_set fdw;
80+
struct timeval tv;
8081

8182
// see if there are any connections to accept or read / write from
8283
FD_ZERO(&fdr);
@@ -87,7 +88,9 @@ void main_loop() {
8788
if (client.fd) FD_SET(client.fd, &fdr);
8889
if (client.fd) FD_SET(client.fd, &fdw);
8990
#endif
90-
res = select(64, &fdr, &fdw, NULL, NULL);
91+
tv.tv_sec = 0;
92+
tv.tv_usec = 0;
93+
res = select(64, &fdr, &fdw, NULL, &tv);
9194
if (res == -1) {
9295
perror("select failed");
9396
exit(EXIT_SUCCESS);

0 commit comments

Comments
 (0)