From 32ee52df1658a0ebb597f8904b36af85ea94253a Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Tue, 16 Jul 2019 18:19:08 +0100 Subject: [PATCH] test-websocket: Reuse red_socket_set_non_blocking Signed-off-by: Frediano Ziglio Acked-by: Uri Lublin --- server/tests/test-websocket.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/server/tests/test-websocket.c b/server/tests/test-websocket.c index e74cb549..432aeee5 100644 --- a/server/tests/test-websocket.c +++ b/server/tests/test-websocket.c @@ -39,6 +39,7 @@ #include #include +#include "net-utils.h" #include "websocket.h" /* @@ -73,16 +74,6 @@ static GOptionEntry cmd_entries[] = { static void handle_client(int new_sock); -static void -set_nonblocking(int sock) -{ - unsigned int ioctl_nonblocking = 1; - - if (ioctl(sock, FIONBIO, &ioctl_nonblocking) < 0) { - err(1, "ioctl"); - } -} - static int wait_for(int sock, short events) { @@ -158,7 +149,7 @@ main(int argc, char **argv) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); if (non_blocking) { - set_nonblocking(sock); + red_socket_set_non_blocking(sock, true); } struct sockaddr_in sin; @@ -205,7 +196,7 @@ static void handle_client(int new_sock) { if (non_blocking) { - set_nonblocking(new_sock); + red_socket_set_non_blocking(new_sock, true); } int enable = 1;