[spice-server,2/2] test-websocket: Reuse red_socket_set_non_blocking

Submitted by Frediano Ziglio on July 17, 2019, 9:48 a.m.

Details

Message ID 20190717094851.14923-2-fziglio@redhat.com
State Accepted
Commit 32ee52df1658a0ebb597f8904b36af85ea94253a
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 17, 2019, 9:48 a.m.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/tests/test-websocket.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

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;