gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 02/02: test_upgrade_large.c: used portable way of inter-


From: gnunet
Subject: [libmicrohttpd] 02/02: test_upgrade_large.c: used portable way of inter-thread communication
Date: Mon, 21 Sep 2020 10:31:48 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 035048e67676e25146e248ac7e09ea09fce3e5ea
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Sep 21 11:24:30 2020 +0300

    test_upgrade_large.c: used portable way of inter-thread communication
---
 src/microhttpd/Makefile.am          |  4 ++--
 src/microhttpd/test_upgrade_large.c | 36 ++++++++++++++++--------------------
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index 87de3c9b..5292593f 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -233,7 +233,7 @@ test_upgrade_LDADD = \
   $(PTHREAD_LIBS)
 
 test_upgrade_large_SOURCES = \
-  test_upgrade_large.c test_helpers.h mhd_sockets.h
+  test_upgrade_large.c test_helpers.h mhd_sockets.h mhd_sockets.c mhd_itc.h 
mhd_itc_types.h mhd_itc.c
 test_upgrade_large_CPPFLAGS = \
   $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS)
 test_upgrade_large_CFLAGS = \
@@ -259,7 +259,7 @@ test_upgrade_tls_LDADD = \
   $(PTHREAD_LIBS)
 
 test_upgrade_large_tls_SOURCES = \
-  test_upgrade_large.c test_helpers.h mhd_sockets.h
+  test_upgrade_large.c test_helpers.h mhd_sockets.h mhd_sockets.c mhd_itc.h 
mhd_itc_types.h mhd_itc.c
 test_upgrade_large_tls_CPPFLAGS = \
   $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS)
 test_upgrade_large_tls_CFLAGS = \
diff --git a/src/microhttpd/test_upgrade_large.c 
b/src/microhttpd/test_upgrade_large.c
index 43c04b7f..a4d339ad 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -48,6 +48,7 @@
 
 #include "platform.h"
 #include "microhttpd.h"
+#include "mhd_itc.h"
 
 #include "test_helpers.h"
 
@@ -69,7 +70,7 @@
 
 static int verbose = 0;
 
-static int kicker[2] = {-1, -1};
+static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID;
 
 enum tls_tool
 {
@@ -588,9 +589,9 @@ make_blocking (MHD_socket fd)
 static void
 kick_select ()
 {
-  if (-1 != kicker[1])
+  if (MHD_ITC_IS_VALID_(kicker))
   {
-    (void) write (kicker[1], "K", 1);
+    MHD_itc_activate_ (kicker, "K");
   }
 }
 
@@ -917,9 +918,8 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
   MHD_socket max_fd;
   MHD_UNSIGNED_LONG_LONG to;
   struct timeval tv;
-  char drain[128];
 
-  if (0 != pipe (kicker))
+  if (!MHD_itc_init_ (kicker))
     abort ();
   while (! done)
   {
@@ -929,7 +929,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
     max_fd = -1;
     to = 1000;
 
-    FD_SET (kicker[0], &rs);
+    FD_SET (MHD_itc_r_fd_ (kicker), &rs);
     if (MHD_YES !=
         MHD_get_fdset (daemon,
                        &rs,
@@ -949,17 +949,15 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
                              &es,
                              &tv))
       abort ();
-    if (FD_ISSET (kicker[0], &rs))
-      (void) read (kicker[0], drain, sizeof (drain));
+    if (FD_ISSET (MHD_itc_r_fd_ (kicker), &rs))
+      MHD_itc_clear_ (kicker);
     MHD_run_from_select (daemon,
                          &rs,
                          &ws,
                          &es);
   }
-  close (kicker[0]);
-  close (kicker[1]);
-  kicker[0] = -1;
-  kicker[1] = -1;
+  MHD_itc_destroy_ (kicker);
+  MHD_itc_set_invalid_ (kicker);
 }
 
 
@@ -1001,13 +999,13 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
   di = MHD_get_daemon_info (daemon,
                             MHD_DAEMON_INFO_EPOLL_FD);
   ep = di->listen_fd;
-  if (0 != pipe (kicker))
+  if (!MHD_itc_init_ (kicker))
     abort ();
   while (! done)
   {
     FD_ZERO (&rs);
     to = 1000;
-    FD_SET (kicker[0], &rs);
+    FD_SET (MHD_itc_r_fd_ (kicker), &rs);
     FD_SET (ep, &rs);
     (void) MHD_get_timeout (daemon,
                             &to);
@@ -1024,14 +1022,12 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
          (EAGAIN != errno) &&
          (EINTR != errno) )
       abort ();
-    if (FD_ISSET (kicker[0], &rs))
-      (void) read (kicker[0], drain, sizeof (drain));
+    if (FD_ISSET (MHD_itc_r_fd_ (kicker), &rs))
+      MHD_itc_clear_ (kicker);
     MHD_run (daemon);
   }
-  close (kicker[0]);
-  close (kicker[1]);
-  kicker[0] = -1;
-  kicker[1] = -1;
+  MHD_itc_destroy_ (kicker);
+  MHD_itc_set_invalid_ (kicker);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]