aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-09-21 11:24:30 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2020-09-21 11:24:30 +0300
commit035048e67676e25146e248ac7e09ea09fce3e5ea (patch)
tree980e18e8f93020df002a1698fe914d5493954279
parent33628f624579d1ecdc833e91aad3616c85623de9 (diff)
downloadlibmicrohttpd-035048e67676e25146e248ac7e09ea09fce3e5ea.tar.gz
libmicrohttpd-035048e67676e25146e248ac7e09ea09fce3e5ea.zip
test_upgrade_large.c: used portable way of inter-thread communication
-rw-r--r--src/microhttpd/Makefile.am4
-rw-r--r--src/microhttpd/test_upgrade_large.c36
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 = \
233 $(PTHREAD_LIBS) 233 $(PTHREAD_LIBS)
234 234
235test_upgrade_large_SOURCES = \ 235test_upgrade_large_SOURCES = \
236 test_upgrade_large.c test_helpers.h mhd_sockets.h 236 test_upgrade_large.c test_helpers.h mhd_sockets.h mhd_sockets.c mhd_itc.h mhd_itc_types.h mhd_itc.c
237test_upgrade_large_CPPFLAGS = \ 237test_upgrade_large_CPPFLAGS = \
238 $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) 238 $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS)
239test_upgrade_large_CFLAGS = \ 239test_upgrade_large_CFLAGS = \
@@ -259,7 +259,7 @@ test_upgrade_tls_LDADD = \
259 $(PTHREAD_LIBS) 259 $(PTHREAD_LIBS)
260 260
261test_upgrade_large_tls_SOURCES = \ 261test_upgrade_large_tls_SOURCES = \
262 test_upgrade_large.c test_helpers.h mhd_sockets.h 262 test_upgrade_large.c test_helpers.h mhd_sockets.h mhd_sockets.c mhd_itc.h mhd_itc_types.h mhd_itc.c
263test_upgrade_large_tls_CPPFLAGS = \ 263test_upgrade_large_tls_CPPFLAGS = \
264 $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) 264 $(AM_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS)
265test_upgrade_large_tls_CFLAGS = \ 265test_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 @@
48 48
49#include "platform.h" 49#include "platform.h"
50#include "microhttpd.h" 50#include "microhttpd.h"
51#include "mhd_itc.h"
51 52
52#include "test_helpers.h" 53#include "test_helpers.h"
53 54
@@ -69,7 +70,7 @@
69 70
70static int verbose = 0; 71static int verbose = 0;
71 72
72static int kicker[2] = {-1, -1}; 73static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID;
73 74
74enum tls_tool 75enum tls_tool
75{ 76{
@@ -588,9 +589,9 @@ make_blocking (MHD_socket fd)
588static void 589static void
589kick_select () 590kick_select ()
590{ 591{
591 if (-1 != kicker[1]) 592 if (MHD_ITC_IS_VALID_(kicker))
592 { 593 {
593 (void) write (kicker[1], "K", 1); 594 MHD_itc_activate_ (kicker, "K");
594 } 595 }
595} 596}
596 597
@@ -917,9 +918,8 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
917 MHD_socket max_fd; 918 MHD_socket max_fd;
918 MHD_UNSIGNED_LONG_LONG to; 919 MHD_UNSIGNED_LONG_LONG to;
919 struct timeval tv; 920 struct timeval tv;
920 char drain[128];
921 921
922 if (0 != pipe (kicker)) 922 if (!MHD_itc_init_ (kicker))
923 abort (); 923 abort ();
924 while (! done) 924 while (! done)
925 { 925 {
@@ -929,7 +929,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
929 max_fd = -1; 929 max_fd = -1;
930 to = 1000; 930 to = 1000;
931 931
932 FD_SET (kicker[0], &rs); 932 FD_SET (MHD_itc_r_fd_ (kicker), &rs);
933 if (MHD_YES != 933 if (MHD_YES !=
934 MHD_get_fdset (daemon, 934 MHD_get_fdset (daemon,
935 &rs, 935 &rs,
@@ -949,17 +949,15 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
949 &es, 949 &es,
950 &tv)) 950 &tv))
951 abort (); 951 abort ();
952 if (FD_ISSET (kicker[0], &rs)) 952 if (FD_ISSET (MHD_itc_r_fd_ (kicker), &rs))
953 (void) read (kicker[0], drain, sizeof (drain)); 953 MHD_itc_clear_ (kicker);
954 MHD_run_from_select (daemon, 954 MHD_run_from_select (daemon,
955 &rs, 955 &rs,
956 &ws, 956 &ws,
957 &es); 957 &es);
958 } 958 }
959 close (kicker[0]); 959 MHD_itc_destroy_ (kicker);
960 close (kicker[1]); 960 MHD_itc_set_invalid_ (kicker);
961 kicker[0] = -1;
962 kicker[1] = -1;
963} 961}
964 962
965 963
@@ -1001,13 +999,13 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
1001 di = MHD_get_daemon_info (daemon, 999 di = MHD_get_daemon_info (daemon,
1002 MHD_DAEMON_INFO_EPOLL_FD); 1000 MHD_DAEMON_INFO_EPOLL_FD);
1003 ep = di->listen_fd; 1001 ep = di->listen_fd;
1004 if (0 != pipe (kicker)) 1002 if (!MHD_itc_init_ (kicker))
1005 abort (); 1003 abort ();
1006 while (! done) 1004 while (! done)
1007 { 1005 {
1008 FD_ZERO (&rs); 1006 FD_ZERO (&rs);
1009 to = 1000; 1007 to = 1000;
1010 FD_SET (kicker[0], &rs); 1008 FD_SET (MHD_itc_r_fd_ (kicker), &rs);
1011 FD_SET (ep, &rs); 1009 FD_SET (ep, &rs);
1012 (void) MHD_get_timeout (daemon, 1010 (void) MHD_get_timeout (daemon,
1013 &to); 1011 &to);
@@ -1024,14 +1022,12 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
1024 (EAGAIN != errno) && 1022 (EAGAIN != errno) &&
1025 (EINTR != errno) ) 1023 (EINTR != errno) )
1026 abort (); 1024 abort ();
1027 if (FD_ISSET (kicker[0], &rs)) 1025 if (FD_ISSET (MHD_itc_r_fd_ (kicker), &rs))
1028 (void) read (kicker[0], drain, sizeof (drain)); 1026 MHD_itc_clear_ (kicker);
1029 MHD_run (daemon); 1027 MHD_run (daemon);
1030 } 1028 }
1031 close (kicker[0]); 1029 MHD_itc_destroy_ (kicker);
1032 close (kicker[1]); 1030 MHD_itc_set_invalid_ (kicker);
1033 kicker[0] = -1;
1034 kicker[1] = -1;
1035} 1031}
1036 1032
1037 1033