[Spice-devel] [PATCH spice-server 2/2] test-websocket: Reuse red_socket_set_non_blocking
Frediano Ziglio
fziglio at redhat.com
Wed Jul 17 09:48:51 UTC 2019
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
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 e74cb5497..432aeee5c 100644
--- a/server/tests/test-websocket.c
+++ b/server/tests/test-websocket.c
@@ -39,6 +39,7 @@
#include <glib.h>
#include <signal.h>
+#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;
--
2.20.1
More information about the Spice-devel
mailing list