[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 01/02: add build option to compile MHD with
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 01/02: add build option to compile MHD without threads |
Date: |
Fri, 07 Dec 2018 12:43:17 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository libmicrohttpd.
commit 0eefd20ba370509d93fb7b0220e6d1c5739efac5
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Dec 7 12:40:32 2018 +0100
add build option to compile MHD without threads
---
ChangeLog | 4 +
configure.ac | 36 ++++---
doc/libmicrohttpd.texi | 3 +
src/include/microhttpd.h | 9 +-
src/microhttpd/Makefile.am | 28 ++++-
src/microhttpd/connection.c | 44 +++++++-
src/microhttpd/daemon.c | 174 +++++++++++++++++++++++++++----
src/microhttpd/digestauth.c | 10 ++
src/microhttpd/internal.h | 17 ++-
src/microhttpd/response.c | 18 ++++
src/microhttpd/test_start_stop.c | 26 +++--
src/testcurl/Makefile.am | 68 +++++++-----
src/testcurl/https/Makefile.am | 43 ++++----
src/testcurl/https/tls_test_common.c | 4 +-
src/testcurl/perf_get.c | 33 +++---
src/testcurl/test_delete.c | 9 +-
src/testcurl/test_get.c | 51 +++++----
src/testcurl/test_get_chunked.c | 9 +-
src/testcurl/test_get_response_cleanup.c | 9 +-
src/testcurl/test_get_sendfile.c | 11 +-
src/testcurl/test_large_put.c | 63 +++++------
src/testcurl/test_post.c | 11 +-
src/testcurl/test_post_loop.c | 63 +++++------
src/testcurl/test_postform.c | 9 +-
src/testcurl/test_process_headers.c | 9 +-
src/testcurl/test_put.c | 9 +-
src/testcurl/test_put_chunked.c | 9 +-
src/testcurl/test_quiesce.c | 33 +++---
src/testzzuf/Makefile.am | 16 ++-
src/testzzuf/test_get.c | 7 +-
src/testzzuf/test_get_chunked.c | 7 +-
src/testzzuf/test_post.c | 7 +-
src/testzzuf/test_post_form.c | 7 +-
src/testzzuf/test_put.c | 7 +-
src/testzzuf/test_put_chunked.c | 7 +-
src/testzzuf/test_put_large.c | 7 +-
36 files changed, 622 insertions(+), 255 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9d7df977..ee824d98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Dec 7 12:37:17 CET 2018
+ Add option to build MHD without any threads
+ and MHD_FEATURE_THREADS to test for it. -CG
+
Thu Dec 6 13:25:08 BRT 2018
Renamed all occurrences from _model(s)_ to _mode(s)_. -SC
diff --git a/configure.ac b/configure.ac
index 3e840234..d2d2bfb7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -361,13 +361,14 @@ AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows"
= "xyes" && \
test "x${os_is_native_w32}" != "xyes"]])
AC_ARG_WITH([threads],
- [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32,
auto) [auto]])],
+ [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32,
auto, none) [auto]])],
[], [with_threads='auto'])
AS_CASE([[$with_threads]],
[[win32]], [[with_threads='w32']],
[[pthreads]], [[with_threads='posix']],
[[posix]], [[:]],
[[w32]], [[:]],
+ [[none]], [[with_threads='none']],
[[auto]], [[:]],
[AC_MSG_ERROR([[incorrect parameter "$with_threads" specified for
--with-threads]])]
)
@@ -398,41 +399,44 @@ AS_IF([[test "x$with_threads" = "xauto"]],
]
)
-AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd]])
-AS_IF([[test "x$with_threads" = "xposix"]],
+AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd
($with_threads)]])
+AS_IF([test "x$with_threads" = "xposix"],
[ # forced posix threads
- AS_IF([[test "x$mhd_have_posix_threads" = "xyes"]], [[ USE_THREADS='posix'
]],
+ AS_IF([test "x$mhd_have_posix_threads" = "xyes"], [USE_THREADS='posix'],
[ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
[ AC_MSG_ERROR([[Posix threads are not available. Try to configure
--with-threads=auto]])],
[ AC_MSG_ERROR([[No threading lib is available. Consider installing
pthreads]])] )
])
- ] ,
- [[ test "x$with_threads" = "xw32" ]] ,
+ ])
+AS_IF([test "x$with_threads" = "xw32"],
[ # forced w32 threads
AS_IF([[test "x$mhd_have_w32_threads" = "xyes"]],
[[ USE_THREADS='w32' ]],
[ AC_MSG_ERROR([[W32 threads are not available. Try to configure
--with-threads=auto]])])
- ] ,
- [ # automatic threads lib selection
- AS_IF([[test "x$os_is_native_w32" = "xyes" && test
"x$mhd_have_w32_threads" = "xyes"]] ,
+ ])
+AS_IF([test "x$with_threads" = "xauto"],
+ [# automatic threads lib selection
+ AS_IF([[test "x$os_is_native_w32" = "xyes" && test
"x$mhd_have_w32_threads" = "xyes"]] ,
[[ USE_THREADS='w32' ]] ,
[[ test "x$mhd_have_posix_threads" = "xyes" ]], [[ USE_THREADS='posix'
]],
[[ test "x$mhd_have_w32_threads" = "xyes" ]], [[ USE_THREADS='w32' ]],
[ AC_MSG_ERROR([[No threading lib is available. Consider installing
pthreads]]) ]
- )
- ]
- )
+ )])
+AS_IF([test "x$with_threads" = "xnone"],
+ [USE_THREADS='none'])
+
AS_IF([test "x$USE_THREADS" = "xposix"],
[CC="$PTHREAD_CC"
AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
MHD_LIB_CFLAGS="$MHD_LIB_CFLAGS $PTHREAD_CFLAGS"
MHD_LIBDEPS="$PTHREAD_LIBS $MHD_LIBDEPS"
- MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"
-elif test "x$USE_THREADS" = "xw32"; then
- AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])
+ MHD_LIBDEPS_PKGCFG="$PTHREAD_LIBS $MHD_LIBDEPS_PKGCFG"],
+ [AS_IF([test "x$USE_THREADS" = "xw32"],
+ [AC_DEFINE([MHD_USE_W32_THREADS],[1],[define to use W32 threads])])])
AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
-AC_MSG_RESULT([[$USE_THREADS]])
+AM_CONDITIONAL([DISABLE_THREADS], [test "x$USE_THREADS" = "xnone"])
+AC_MSG_RESULT([$USE_THREADS])
AC_ARG_ENABLE([[thread-names]],
[AS_HELP_STRING([--disable-thread-names [auto] ],[do not set names on MHD
generated threads])],
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi
index 7c573736..0776dace 100644
--- a/doc/libmicrohttpd.texi
+++ b/doc/libmicrohttpd.texi
@@ -277,6 +277,9 @@ do not include epoll support, even if it supported
(minimally smaller binary siz
@item ``--enable-coverage''
set flags for analysis of code-coverage with gcc/gcov (results in slow, large
binaries)
address@hidden ``--with-threads={posix,w32,none,auto}''
+sets threading library to use. With use ``none'' to not support threads. In
this case, MHD will only support the ``external'' threading modes and not
perform any locking of data structures! Use
@code{MHD_is_feature_supported(MHD_FEATURE_THREADS)} to test if threads are
available. Default is ``auto''.
+
@item ``--with-gcrypt=PATH''
specifies path to libgcrypt installation
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 61d1edef..b9a9bcf9 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -126,7 +126,7 @@ typedef intptr_t ssize_t;
* Current version of the library.
* 0x01093001 = 1.9.30-1.
*/
-#define MHD_VERSION 0x00096100
+#define MHD_VERSION 0x00096101
/**
* MHD-internal return code for "YES".
@@ -3574,7 +3574,12 @@ enum MHD_FEATURE
* file-FD based responses over non-TLS connections.
* @note Since v0.9.56
*/
- MHD_FEATURE_SENDFILE = 21
+ MHD_FEATURE_SENDFILE = 21,
+
+ /**
+ * Get whether MHD supports threads.
+ */
+ MHD_FEATURE_THREADS
};
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index f303b3f9..2c59876a 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -62,13 +62,23 @@ libmicrohttpd_la_SOURCES = \
mhd_limits.h mhd_byteorder.h \
sysfdsetsize.c sysfdsetsize.h \
mhd_str.c mhd_str.h \
- mhd_threads.c mhd_threads.h \
- mhd_locks.h mhd_assert.h \
+ mhd_assert.h \
mhd_sockets.c mhd_sockets.h \
mhd_itc.c mhd_itc.h mhd_itc_types.h \
mhd_compat.c mhd_compat.h \
response.c response.h
+if USE_POSIX_THREADS
+libmicrohttpd_la_SOURCES += \
+ mhd_threads.c mhd_threads.h \
+ mhd_locks.h
+endif
+if USE_W32_THREADS
+libmicrohttpd_la_SOURCES += \
+ mhd_threads.c mhd_threads.h \
+ mhd_locks.h
+endif
+
libmicrohttpd_la_CPPFLAGS = \
$(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS) \
-DBUILDING_MHD_LIB=1
@@ -150,9 +160,19 @@ check_PROGRAMS = \
if HAVE_POSIX_THREADS
if ENABLE_UPGRADE
+if USE_POSIX_THREADS
+ check_PROGRAMS += test_upgrade
+endif
+if USE_W32_THREADS
check_PROGRAMS += test_upgrade
+endif
if ENABLE_HTTPS
- check_PROGRAMS += test_upgrade_tls
+if USE_POSIX_THREADS
+check_PROGRAMS += test_upgrade_tls
+endif
+if USE_W32_THREADS
+check_PROGRAMS += test_upgrade_tls
+endif
endif
endif
endif
@@ -170,6 +190,7 @@ TESTS = $(check_PROGRAMS)
# on Cygwin as this ability is deliberately ignored on Cygwin
# to improve compatibility with core OS.
if !CYGWIN_TARGET
+if USE_POSIX_THREADS
if HAVE_LISTEN_SHUTDOWN
check_PROGRAMS += \
test_shutdown_select \
@@ -180,6 +201,7 @@ check_PROGRAMS += \
test_shutdown_poll_ignore
endif
endif
+endif
test_start_stop_SOURCES = \
test_start_stop.c
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index cd4e8257..542c5a40 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -32,7 +32,9 @@
#include "response.h"
#include "mhd_mono_clock.h"
#include "mhd_str.h"
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#include "mhd_locks.h"
+#endif
#include "mhd_sockets.h"
#include "mhd_compat.h"
#include "mhd_itc.h"
@@ -1104,7 +1106,9 @@ try_ready_normal_body (struct MHD_Connection *connection)
{
/* either error or http 1.0 transfer, close socket! */
response->total_size = connection->response_write_position;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
if ( ((ssize_t)MHD_CONTENT_READER_END_OF_STREAM) == ret)
MHD_connection_close_ (connection,
MHD_REQUEST_TERMINATED_COMPLETED_OK);
@@ -1118,7 +1122,9 @@ try_ready_normal_body (struct MHD_Connection *connection)
if (0 == ret)
{
connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
return MHD_NO;
}
return MHD_YES;
@@ -1156,7 +1162,9 @@ try_ready_chunked_body (struct MHD_Connection *connection)
size /= 2;
if (size < 128)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
/* not enough memory */
CONNECTION_CLOSE_ERROR (connection,
_("Closing connection (out of
memory)\n"));
@@ -1202,7 +1210,9 @@ try_ready_chunked_body (struct MHD_Connection *connection)
{
/* error, close socket! */
response->total_size = connection->response_write_position;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
CONNECTION_CLOSE_ERROR (connection,
_("Closing connection (application error
generating response)\n"));
return MHD_NO;
@@ -1222,7 +1232,9 @@ try_ready_chunked_body (struct MHD_Connection *connection)
if (0 == ret)
{
connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
return MHD_NO;
}
if (ret > 0xFFFFFF)
@@ -2861,8 +2873,9 @@ MHD_update_last_activity_ (struct MHD_Connection
*connection)
if (connection->connection_timeout != daemon->connection_timeout)
return; /* custom timeout, no need to move it in "normal" DLL */
-
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
/* move connection to head of timeout list (by remove + add operation) */
XDLL_remove (daemon->normal_timeout_head,
daemon->normal_timeout_tail,
@@ -2870,7 +2883,9 @@ MHD_update_last_activity_ (struct MHD_Connection
*connection)
XDLL_insert (daemon->normal_timeout_head,
daemon->normal_timeout_tail,
connection);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
}
@@ -3088,8 +3103,10 @@ MHD_connection_handle_write (struct MHD_Connection
*connection)
{
uint64_t data_write_offset;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != response->crc)
MHD_mutex_lock_chk_ (&response->mutex);
+#endif
if (MHD_YES != try_ready_normal_body (connection))
{
/* mutex was already unlocked by try_ready_normal_body */
@@ -3124,8 +3141,10 @@ MHD_connection_handle_write (struct MHD_Connection
*connection)
response->data_start]);
#endif
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != response->crc)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
if (ret < 0)
{
if (MHD_ERR_AGAIN_ == ret)
@@ -3239,7 +3258,9 @@ cleanup_connection (struct MHD_Connection *connection)
MHD_destroy_response (connection->response);
connection->response = NULL;
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if (connection->suspended)
{
DLL_remove (daemon->suspended_connections_head,
@@ -3269,7 +3290,9 @@ cleanup_connection (struct MHD_Connection *connection)
connection);
connection->resuming = false;
connection->in_idle = false;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex);
+#endif
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
/* if we were at the connection limit before and are in
@@ -3610,19 +3633,25 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
/* nothing to do here */
break;
case MHD_CONNECTION_NORMAL_BODY_UNREADY:
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != connection->response->crc)
MHD_mutex_lock_chk_ (&connection->response->mutex);
+#endif
if (0 == connection->response->total_size)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != connection->response->crc)
MHD_mutex_unlock_chk_ (&connection->response->mutex);
+#endif
connection->state = MHD_CONNECTION_BODY_SENT;
continue;
}
if (MHD_YES == try_ready_normal_body (connection))
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != connection->response->crc)
MHD_mutex_unlock_chk_ (&connection->response->mutex);
+#endif
connection->state = MHD_CONNECTION_NORMAL_BODY_READY;
/* Buffering for flushable socket was already enabled*/
if (MHD_NO == socket_flush_possible (connection))
@@ -3636,21 +3665,27 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
/* nothing to do here */
break;
case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != connection->response->crc)
MHD_mutex_lock_chk_ (&connection->response->mutex);
+#endif
if ( (0 == connection->response->total_size) ||
(connection->response_write_position ==
connection->response->total_size) )
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != connection->response->crc)
MHD_mutex_unlock_chk_ (&connection->response->mutex);
+#endif
connection->state = MHD_CONNECTION_BODY_SENT;
continue;
}
if (MHD_YES == try_ready_chunked_body (connection))
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != connection->response->crc)
MHD_mutex_unlock_chk_ (&connection->response->mutex);
+#endif
connection->state = MHD_CONNECTION_CHUNKED_BODY_READY;
/* Buffering for flushable socket was already enabled */
if (MHD_NO == socket_flush_possible (connection))
@@ -3937,8 +3972,9 @@ MHD_set_connection_option (struct MHD_Connection
*connection,
case MHD_CONNECTION_OPTION_TIMEOUT:
if (0 == connection->connection_timeout)
connection->last_activity = MHD_monotonic_sec_counter();
-
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
(! connection->suspended) )
{
@@ -3967,7 +4003,9 @@ MHD_set_connection_option (struct MHD_Connection
*connection,
daemon->manual_timeout_tail,
connection);
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
return MHD_YES;
default:
return MHD_NO;
@@ -4005,6 +4043,7 @@ MHD_queue_response (struct MHD_Connection *connection,
return MHD_YES; /* If daemon was shut down in parallel,
* response will be aborted now or on later stage. */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if ( (!connection->suspended) &&
(0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
(!MHD_thread_ID_match_current_(connection->pid.ID)) )
@@ -4015,6 +4054,7 @@ MHD_queue_response (struct MHD_Connection *connection,
#endif
return MHD_NO;
}
+#endif
#ifdef UPGRADE_SUPPORT
if ( (NULL != response->upgrade_handler) &&
(0 == (daemon->options & MHD_ALLOW_UPGRADE)) )
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 7a310c1f..926a983e 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -26,7 +26,9 @@
* @author Karlson2k (Evgeny Grin)
*/
#include "platform.h"
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#include "mhd_threads.h"
+#endif
#include "internal.h"
#include "response.h"
#include "connection.h"
@@ -34,7 +36,9 @@
#include "mhd_limits.h"
#include "autoinit_funcs.h"
#include "mhd_mono_clock.h"
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#include "mhd_locks.h"
+#endif
#include "mhd_sockets.h"
#include "mhd_itc.h"
#include "mhd_compat.h"
@@ -181,12 +185,17 @@ static int mhd_winsock_inited_ = 0;
* Track global initialisation
*/
volatile int global_init_count = 0;
+
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#ifdef MHD_MUTEX_STATIC_DEFN_INIT_
/**
* Global initialisation mutex
*/
MHD_MUTEX_STATIC_DEFN_INIT_(global_init_mutex_);
#endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */
+#endif
+
+
/**
* Check whether global initialisation was performed
* and call initialiser if necessary.
@@ -194,14 +203,18 @@ MHD_MUTEX_STATIC_DEFN_INIT_(global_init_mutex_);
void
MHD_check_global_init_ (void)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#ifdef MHD_MUTEX_STATIC_DEFN_INIT_
MHD_mutex_lock_chk_(&global_init_mutex_);
#endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */
+#endif
if (0 == global_init_count++)
MHD_init ();
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#ifdef MHD_MUTEX_STATIC_DEFN_INIT_
MHD_mutex_unlock_chk_(&global_init_mutex_);
#endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */
+#endif
}
#endif /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */
@@ -263,7 +276,11 @@ struct MHD_IPCount
static void
MHD_ip_count_lock (struct MHD_Daemon *daemon)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_(&daemon->per_ip_connection_mutex);
+#else
+ (void) daemon;
+#endif
}
@@ -275,7 +292,11 @@ MHD_ip_count_lock (struct MHD_Daemon *daemon)
static void
MHD_ip_count_unlock (struct MHD_Daemon *daemon)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_(&daemon->per_ip_connection_mutex);
+#else
+ (void) daemon;
+#endif
}
@@ -1177,7 +1198,7 @@ call_handlers (struct MHD_Connection *con,
/* Note: no need to check for read buffer availability for
* TLS read-ready connection in 'read info' state as connection
* without space in read buffer will be market as 'info block'. */
- if ( (!con->daemon->data_already_pending) &&
+ if ( (! con->daemon->data_already_pending) &&
(0 == (con->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) )
{
if (MHD_EVENT_LOOP_INFO_BLOCK == con->event_loop_info)
@@ -1230,7 +1251,7 @@ cleanup_upgraded_connection (struct MHD_Connection
*connection)
/**
* Performs bi-directional forwarding on upgraded HTTPS connections
* based on the readyness state stored in the @a urh handle.
- * @remark To be called only from thread that process
+ * @remark To be called only from thread that processes
* connection's recv(), send() and response.
*
* @param urh handle to process
@@ -1573,7 +1594,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
}
#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
-
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#ifdef UPGRADE_SUPPORT
/**
* Main function of the thread that handles an individual connection
@@ -2108,6 +2129,7 @@ exit:
}
return (MHD_THRD_RTRN_TYPE_) 0;
}
+#endif
/**
@@ -2253,10 +2275,13 @@ internal_add_connection (struct MHD_Daemon *daemon,
bool non_blck)
{
struct MHD_Connection *connection;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
unsigned int i;
+#endif
int eno = 0;
/* Direct add to master daemon could happen only with "external" add mode. */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
mhd_assert ((NULL == daemon->worker_pool) || (external_add));
if ((external_add) && (NULL != daemon->worker_pool))
{
@@ -2282,6 +2307,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
#endif
return MHD_NO;
}
+#endif
if ( (! MHD_SCKT_FD_FITS_FDSET_(client_socket,
NULL)) &&
@@ -2502,11 +2528,15 @@ internal_add_connection (struct MHD_Daemon *daemon,
#endif /* ! HTTPS_SUPPORT */
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
/* Firm check under lock. */
if (daemon->connections >= daemon->connection_limit)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
/* above connection limit - reject */
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
@@ -2527,14 +2557,15 @@ internal_add_connection (struct MHD_Daemon *daemon,
DLL_insert (daemon->connections_head,
daemon->connections_tail,
connection);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
-
+#endif
if (NULL != daemon->notify_connection)
daemon->notify_connection (daemon->notify_connection_cls,
connection,
&connection->socket_context,
MHD_CONNECTION_NOTIFY_STARTED);
-
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/* attempt to create handler thread */
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
@@ -2555,6 +2586,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
}
else
connection->pid = daemon->pid;
+#endif
#ifdef EPOLL_SUPPORT
if (0 != (daemon->options & MHD_USE_EPOLL))
{
@@ -2615,7 +2647,9 @@ internal_add_connection (struct MHD_Daemon *daemon,
MHD_ip_limit_del (daemon,
addr,
addrlen);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
XDLL_remove (daemon->normal_timeout_head,
@@ -2625,7 +2659,9 @@ internal_add_connection (struct MHD_Daemon *daemon,
DLL_remove (daemon->connections_head,
daemon->connections_tail,
connection);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
MHD_pool_destroy (connection->pool);
free (connection->addr);
free (connection);
@@ -2651,12 +2687,16 @@ internal_suspend_connection_ (struct MHD_Connection
*connection)
{
struct MHD_Daemon *daemon = connection->daemon;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if (connection->resuming)
{
/* suspending again while we didn't even complete resuming yet */
connection->resuming = false;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
return;
}
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
@@ -2700,7 +2740,9 @@ internal_suspend_connection_ (struct MHD_Connection
*connection)
connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED;
}
#endif
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
}
@@ -2771,10 +2813,14 @@ MHD_resume_connection (struct MHD_Connection
*connection)
if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
MHD_PANIC (_("Cannot resume connections without enabling
MHD_ALLOW_SUSPEND_RESUME!\n"));
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
connection->resuming = true;
daemon->resuming = true;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if ( (MHD_ITC_IS_VALID_(daemon->itc)) &&
(! MHD_itc_activate_ (daemon->itc, "r")) )
{
@@ -2802,11 +2848,13 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
struct MHD_Connection *prev = NULL;
int ret;
const bool used_thr_p_c = (0 != (daemon->options &
MHD_USE_THREAD_PER_CONNECTION));
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
mhd_assert (NULL == daemon->worker_pool);
-
+#endif
ret = MHD_NO;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-
+#endif
if (daemon->resuming)
{
prev = daemon->suspended_connections_tail;
@@ -2899,7 +2947,9 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
#endif /* UPGRADE_SUPPORT */
pos->resuming = false;
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if ( (used_thr_p_c) &&
(MHD_NO != ret) )
{ /* Wake up suspended connections. */
@@ -3062,9 +3112,13 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
}
else
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
daemon->at_limit = true;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
_("Hit process or system resource limit at %u
connections, temporarily suspending accept(). Consider setting a lower
MHD_OPTION_CONNECTION_LIMIT.\n"),
@@ -3126,18 +3180,21 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
{
struct MHD_Connection *pos;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
while (NULL != (pos = daemon->cleanup_tail))
{
DLL_remove (daemon->cleanup_head,
daemon->cleanup_tail,
pos);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
-
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
(! pos->thread_joined) &&
(! MHD_join_thread_ (pos->pid.handle)) )
MHD_PANIC (_("Failed to join a thread\n"));
+#endif
#ifdef UPGRADE_SUPPORT
cleanup_upgraded_connection (pos);
#endif /* UPGRADE_SUPPORT */
@@ -3195,11 +3252,15 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
free (pos->addr);
free (pos);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
daemon->connections--;
daemon->at_limit = false;
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
}
@@ -4489,9 +4550,9 @@ close_connection (struct MHD_Connection *pos)
}
MHD_connection_close_ (pos,
MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN);
-
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-
+#endif
mhd_assert (! pos->suspended);
mhd_assert (! pos->resuming);
if (pos->connection_timeout == daemon->connection_timeout)
@@ -4508,11 +4569,13 @@ close_connection (struct MHD_Connection *pos)
DLL_insert (daemon->cleanup_head,
daemon->cleanup_tail,
pos);
-
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* Thread that runs the polling loop until the daemon
* is explicitly shut down.
@@ -4548,6 +4611,7 @@ MHD_polling_thread (void *cls)
return (MHD_THRD_RTRN_TYPE_)0;
}
+#endif
/**
@@ -4567,6 +4631,7 @@ unescape_wrapper (void *cls,
char *val)
{
(void) cls; /* Mute compiler warning. */
+
(void) connection; /* Mute compiler warning. */
return MHD_http_unescape (val);
}
@@ -4640,7 +4705,9 @@ MHD_start_daemon (unsigned int flags,
MHD_socket
MHD_quiesce_daemon (struct MHD_Daemon *daemon)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
unsigned int i;
+#endif
MHD_socket ret;
ret = daemon->listen_fd;
@@ -4655,7 +4722,8 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
#endif
return MHD_INVALID_SOCKET;
}
-
+
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != daemon->worker_pool)
for (i = 0; i < daemon->worker_pool_size; i++)
{
@@ -4680,6 +4748,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
MHD_PANIC (_("Failed to signal quiesce via inter-thread
communication channel"));
}
}
+#endif
daemon->was_quiesced = true;
#ifdef EPOLL_SUPPORT
if ( (0 != (daemon->options & MHD_USE_EPOLL)) &&
@@ -4839,6 +4908,7 @@ parse_options_va (struct MHD_Daemon *daemon,
daemon->uri_log_callback_cls = va_arg (ap,
void *);
break;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
case MHD_OPTION_THREAD_POOL_SIZE:
daemon->worker_pool_size = va_arg (ap,
unsigned int);
@@ -4893,6 +4963,7 @@ parse_options_va (struct MHD_Daemon *daemon,
}
}
break;
+#endif
#ifdef HTTPS_SUPPORT
case MHD_OPTION_HTTPS_MEM_KEY:
pstr = va_arg (ap,
@@ -5071,10 +5142,12 @@ parse_options_va (struct MHD_Daemon *daemon,
void *);
#endif
break;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
case MHD_OPTION_THREAD_STACK_SIZE:
daemon->thread_stack_size = va_arg (ap,
size_t);
break;
+#endif
#ifdef TCP_FASTOPEN
case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE:
daemon->fastopen_queue_size = va_arg (ap,
@@ -5400,7 +5473,9 @@ MHD_start_daemon_va (unsigned int flags,
#endif
const struct sockaddr *servaddr = NULL;
socklen_t addrlen;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
unsigned int i;
+#endif
enum MHD_FLAG eflags; /* same type as in MHD_Daemon */
enum MHD_FLAG *pflags;
@@ -5580,8 +5655,11 @@ MHD_start_daemon_va (unsigned int flags,
#endif /* HAVE_MESSAGES */
#endif /* ! NDEBUG */
- if ( (0 != (*pflags & MHD_USE_ITC)) &&
- (0 == daemon->worker_pool_size) )
+ if ( (0 != (*pflags & MHD_USE_ITC))
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+ && (0 == daemon->worker_pool_size)
+#endif
+ )
{
if (! MHD_itc_init_ (daemon->itc))
{
@@ -5649,6 +5727,7 @@ MHD_start_daemon_va (unsigned int flags,
}
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (! MHD_mutex_init_ (&daemon->nnc_lock))
{
#ifdef HAVE_MESSAGES
@@ -5664,10 +5743,16 @@ MHD_start_daemon_va (unsigned int flags,
return NULL;
}
#endif
+#endif
+<<<<<<< HEAD
/* Thread pooling currently works only with internal select thread mode */
+=======
+ /* Thread pooling currently works only with internal select thread model */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+>>>>>>> add build option to compile MHD without threads
if ( (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
- (daemon->worker_pool_size > 0) )
+ (daemon->worker_pool_size > 0) )
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
@@ -5675,7 +5760,7 @@ MHD_start_daemon_va (unsigned int flags,
#endif
goto free_and_fail;
}
-
+#endif
if ( (MHD_INVALID_SOCKET == daemon->listen_fd) &&
(0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
{
@@ -6000,8 +6085,11 @@ MHD_start_daemon_va (unsigned int flags,
_("Failed to set nonblocking mode on listening socket: %s\n"),
MHD_socket_last_strerr_());
#endif
- if (0 != (*pflags & MHD_USE_EPOLL) ||
- daemon->worker_pool_size > 0)
+ if (0 != (*pflags & MHD_USE_EPOLL)
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+ || (daemon->worker_pool_size > 0)
+#endif
+ )
{
/* Accept must be non-blocking. Multiple children may wake up
* to handle a new connection, but only one will win the race.
@@ -6026,8 +6114,11 @@ MHD_start_daemon_va (unsigned int flags,
}
#ifdef EPOLL_SUPPORT
- if ( (0 != (*pflags & MHD_USE_EPOLL)) &&
- (0 == daemon->worker_pool_size) )
+ if ( (0 != (*pflags & MHD_USE_EPOLL))
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+ && (0 == daemon->worker_pool_size)
+#endif
+ )
{
if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))
{
@@ -6042,6 +6133,7 @@ MHD_start_daemon_va (unsigned int flags,
}
#endif /* EPOLL_SUPPORT */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (! MHD_mutex_init_ (&daemon->per_ip_connection_mutex))
{
#ifdef HAVE_MESSAGES
@@ -6061,12 +6153,15 @@ MHD_start_daemon_va (unsigned int flags,
MHD_DLOG (daemon,
_("MHD failed to initialize IP connection limit mutex\n"));
#endif
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex);
+#endif
if (MHD_INVALID_SOCKET != listen_fd)
MHD_socket_close_chk_ (listen_fd);
goto free_and_fail;
}
}
+#endif
#ifdef HTTPS_SUPPORT
/* initialize HTTPS daemon certificate aspects & send / recv functions */
@@ -6079,12 +6174,15 @@ MHD_start_daemon_va (unsigned int flags,
#endif
if (MHD_INVALID_SOCKET != listen_fd)
MHD_socket_close_chk_ (listen_fd);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (0 == daemon->worker_pool_size)
MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex);
MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex);
+#endif
goto free_and_fail;
}
#endif /* HTTPS_SUPPORT */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if ( (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
(0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
{
@@ -6208,6 +6306,7 @@ MHD_start_daemon_va (unsigned int flags,
}
}
}
+#endif
#ifdef HTTPS_SUPPORT
/* API promises to never use the password after initialization,
so we additionally NULL it here to not deref a dangling pointer. */
@@ -6216,6 +6315,7 @@ MHD_start_daemon_va (unsigned int flags,
return daemon;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
thread_failed:
/* If no worker threads created, then shut down normally. Calling
MHD_stop_daemon (as we do below) doesn't work here since it
@@ -6238,6 +6338,7 @@ thread_failed:
daemon->worker_pool_size = i;
MHD_stop_daemon (daemon);
return NULL;
+#endif
free_and_fail:
/* clean up basic memory state in 'daemon' and return NULL to
@@ -6263,8 +6364,10 @@ thread_failed:
#endif /* EPOLL_SUPPORT */
#ifdef DAUTH_SUPPORT
free (daemon->nnc);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_destroy_chk_ (&daemon->nnc_lock);
#endif
+#endif
#ifdef HTTPS_SUPPORT
if (0 != (*pflags & MHD_USE_TLS))
gnutls_priority_deinit (daemon->priority_cache);
@@ -6297,7 +6400,9 @@ close_all_connections (struct MHD_Daemon *daemon)
struct MHD_UpgradeResponseHandle *urhn;
const bool used_tls = (0 != (daemon->options & MHD_USE_TLS));
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
mhd_assert (NULL == daemon->worker_pool);
+#endif
mhd_assert (daemon->shutdown);
/* give upgraded HTTPS connections a chance to finish */
/* 'daemon->urh_head' is not used in thread-per-connection mode. */
@@ -6325,7 +6430,9 @@ close_all_connections (struct MHD_Daemon *daemon)
}
/* first, make sure all threads are aware of shutdown; need to
traverse DLLs in peace... */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
#ifdef UPGRADE_SUPPORT
if (upg_allowed)
{
@@ -6379,6 +6486,7 @@ close_all_connections (struct MHD_Daemon *daemon)
#endif
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/* now, collect per-connection threads */
if (used_thr_p_c)
{
@@ -6401,6 +6509,7 @@ close_all_connections (struct MHD_Daemon *daemon)
}
}
MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+#endif
#ifdef UPGRADE_SUPPORT
/* Finished threads with "upgraded" connections need to be moved
@@ -6417,9 +6526,11 @@ close_all_connections (struct MHD_Daemon *daemon)
/* now that we're alone, move everyone to cleanup */
while (NULL != (pos = daemon->connections_tail))
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
(! pos->thread_joined) )
MHD_PANIC (_("Failed to join a thread\n"));
+#endif
close_connection (pos);
}
MHD_cleanup_connections (daemon);
@@ -6436,8 +6547,10 @@ void
MHD_stop_daemon (struct MHD_Daemon *daemon)
{
MHD_socket fd;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
unsigned int i;
-
+#endif
+
if (NULL == daemon)
return;
@@ -6447,6 +6560,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
else
fd = daemon->listen_fd;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (NULL != daemon->worker_pool)
{ /* Master daemon with worker pool. */
mhd_assert (1 < daemon->worker_pool_size);
@@ -6486,7 +6600,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
#endif /* EPOLL_SUPPORT */
}
else
+#endif
{ /* Worker daemon or single daemon. */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
{ /* Worker daemon or single daemon with internal thread(s). */
mhd_assert (0 == daemon->worker_pool_size);
@@ -6518,6 +6634,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
/* close_all_connections() was called in daemon thread. */
}
else
+#endif
{
/* No internal threads are used for polling sockets. */
close_all_connections (daemon);
@@ -6536,7 +6653,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
#endif /* EPOLL_SUPPORT */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_destroy_chk_ (&daemon->cleanup_connection_mutex);
+#endif
}
if (NULL == daemon->master)
@@ -6565,10 +6684,13 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
#ifdef DAUTH_SUPPORT
free (daemon->nnc);
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_destroy_chk_ (&daemon->nnc_lock);
#endif
+#endif
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_destroy_chk_ (&daemon->per_ip_connection_mutex);
-
+#endif
free (daemon);
}
}
@@ -6611,6 +6733,7 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon,
* at the same time. */
MHD_cleanup_connections (daemon);
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
else if (daemon->worker_pool)
{
unsigned int i;
@@ -6622,6 +6745,7 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon,
daemon->connections += daemon->worker_pool[i].connections;
}
}
+#endif
return (const union MHD_DaemonInfo *) &daemon->connections;
case MHD_DAEMON_INFO_FLAGS:
return (const union MHD_DaemonInfo *) &daemon->options;
@@ -6833,6 +6957,12 @@ MHD_is_feature_supported(enum MHD_FEATURE feature)
#else
return MHD_NO;
#endif
+ case MHD_FEATURE_THREADS:
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+ return MHD_YES;
+#else
+ return MHD_NO;
+#endif
}
return MHD_NO;
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 33352bc7..80cba836 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -448,7 +448,9 @@ check_nonce_nc (struct MHD_Connection *connection,
* then only increase the nonce counter by one.
*/
nn = &daemon->nnc[off];
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->nnc_lock);
+#endif
if (0 == nc)
{
/* Fresh nonce, reinitialize array */
@@ -457,7 +459,9 @@ check_nonce_nc (struct MHD_Connection *connection,
noncelen);
nn->nc = 0;
nn->nmask = 0;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->nnc_lock);
+#endif
return MHD_YES;
}
/* Note that we use 64 here, as we do not store the
@@ -469,7 +473,9 @@ check_nonce_nc (struct MHD_Connection *connection,
{
/* Out-of-order nonce, but within 64-bit bitmask, set bit */
nn->nmask |= (1LLU << (nn->nc - nc - 1));
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->nnc_lock);
+#endif
return MHD_YES;
}
@@ -478,7 +484,9 @@ check_nonce_nc (struct MHD_Connection *connection,
nonce)) )
{
/* Nonce does not match, fail */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->nnc_lock);
+#endif
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
_("Stale nonce received. If this happens a lot, you should
probably increase the size of the nonce array.\n"));
@@ -491,7 +499,9 @@ check_nonce_nc (struct MHD_Connection *connection,
else
nn->nmask = 0; /* big jump, unset all bits in the mask */
nn->nc = nc;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&daemon->nnc_lock);
+#endif
return MHD_YES;
}
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 4ae577de..aa6af5e8 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -65,8 +65,10 @@
#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__,
NULL); BUILTIN_NOT_REACHED; } while (0)
#endif
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#include "mhd_threads.h"
#include "mhd_locks.h"
+#endif
#include "mhd_sockets.h"
#include "mhd_itc_types.h"
@@ -333,11 +335,13 @@ struct MHD_Response
void *upgrade_handler_cls;
#endif /* UPGRADE_SUPPORT */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* Mutex to synchronize access to @e data, @e size and
* @e reference_count.
*/
MHD_mutex_ mutex;
+#endif
/**
* Set to #MHD_SIZE_UNKNOWN if size is not known.
@@ -746,11 +750,13 @@ struct MHD_Connection
*/
struct sockaddr *addr;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* Thread handle for this connection (if we are using
* one thread per connection).
*/
MHD_thread_handle_ID_ pid;
+#endif
/**
* Size of @e read_buffer (in bytes). This value indicates
@@ -864,10 +870,12 @@ struct MHD_Connection
*/
bool read_closed;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* Set to `true` if the thread has been joined.
*/
bool thread_joined;
+#endif
/**
* Are we currently inside the "idle" handler (to avoid recursively
@@ -1404,10 +1412,12 @@ struct MHD_Daemon
*/
struct MHD_Daemon *master;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* Worker daemons (one per thread)
*/
struct MHD_Daemon *worker_pool;
+#endif
/**
* Table storing number of connections per IP
@@ -1424,6 +1434,7 @@ struct MHD_Daemon
*/
size_t pool_increment;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* Size of threads created by MHD.
*/
@@ -1449,6 +1460,7 @@ struct MHD_Daemon
* "manual_timeout" DLLs.
*/
MHD_mutex_ cleanup_connection_mutex;
+#endif
/**
* Listen socket.
@@ -1495,7 +1507,8 @@ struct MHD_Daemon
#endif
/**
- * Inter-thread communication channel.
+ * Inter-thread communication channel (also used to unblock
+ * select() in non-threaded code).
*/
struct MHD_itc_ itc;
@@ -1678,10 +1691,12 @@ struct MHD_Daemon
*/
struct MHD_NonceNc *nnc;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
/**
* A rw-lock for synchronizing access to @e nnc.
*/
MHD_mutex_ nnc_lock;
+#endif
/**
* Size of `digest_auth_random.
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 29edef4f..263f8303 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -350,11 +350,13 @@ MHD_create_response_from_callback (uint64_t size,
response->fd = -1;
response->data = (void *) &response[1];
response->data_buffer_size = block_size;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (! MHD_mutex_init_ (&response->mutex))
{
free (response);
return NULL;
}
+#endif
response->crc = crc;
response->crfc = crfc;
response->crc_cls = crc_cls;
@@ -649,16 +651,20 @@ MHD_create_response_from_data (size_t size,
if (NULL == (response = MHD_calloc_ (1, sizeof (struct MHD_Response))))
return NULL;
response->fd = -1;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (! MHD_mutex_init_ (&response->mutex))
{
free (response);
return NULL;
}
+#endif
if ((must_copy) && (size > 0))
{
if (NULL == (tmp = malloc (size)))
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_destroy_chk_ (&response->mutex);
+#endif
free (response);
return NULL;
}
@@ -1084,11 +1090,13 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler
upgrade_handler,
response = MHD_calloc_ (1, sizeof (struct MHD_Response));
if (NULL == response)
return NULL;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (! MHD_mutex_init_ (&response->mutex))
{
free (response);
return NULL;
}
+#endif
response->upgrade_handler = upgrade_handler;
response->upgrade_handler_cls = upgrade_handler_cls;
response->total_size = MHD_SIZE_UNKNOWN;
@@ -1122,14 +1130,20 @@ MHD_destroy_response (struct MHD_Response *response)
if (NULL == response)
return;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&response->mutex);
+#endif
if (0 != --(response->reference_count))
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
return;
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
MHD_mutex_destroy_chk_ (&response->mutex);
+#endif
if (NULL != response->crfc)
response->crfc (response->crc_cls);
while (NULL != response->first_header)
@@ -1152,9 +1166,13 @@ MHD_destroy_response (struct MHD_Response *response)
void
MHD_increment_response_rc (struct MHD_Response *response)
{
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&response->mutex);
+#endif
(response->reference_count)++;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_unlock_chk_ (&response->mutex);
+#endif
}
diff --git a/src/microhttpd/test_start_stop.c b/src/microhttpd/test_start_stop.c
index d2e160b0..d27291b8 100644
--- a/src/microhttpd/test_start_stop.c
+++ b/src/microhttpd/test_start_stop.c
@@ -52,6 +52,7 @@ ahc_echo (void *cls,
}
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
static int
testInternalGet (int poll_flag)
{
@@ -78,6 +79,7 @@ testMultithreadedGet (int poll_flag)
return 0;
}
+
static int
testMultithreadedPoolGet (int poll_flag)
{
@@ -91,6 +93,8 @@ testMultithreadedPoolGet (int poll_flag)
MHD_stop_daemon (d);
return 0;
}
+#endif
+
static int
testExternalGet ()
@@ -98,8 +102,10 @@ testExternalGet ()
struct MHD_Daemon *d;
d = MHD_start_daemon (MHD_USE_ERROR_LOG,
- 0, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
- if (d == NULL)
+ 0, NULL, NULL,
+ &ahc_echo, "GET",
+ MHD_OPTION_END);
+ if (NULL == d)
return 8;
MHD_stop_daemon (d);
return 0;
@@ -107,15 +113,20 @@ testExternalGet ()
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
unsigned int errorCount = 0;
- (void)argc; (void)argv; /* Unused. Silent compiler warning. */
+ (void) argc;
+ (void) argv; /* Unused. Silence compiler warning. */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
errorCount += testInternalGet (0);
errorCount += testMultithreadedGet (0);
errorCount += testMultithreadedPoolGet (0);
+#endif
errorCount += testExternalGet ();
+#if defined (MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
{
errorCount += testInternalGet(MHD_USE_POLL);
@@ -127,7 +138,10 @@ main (int argc, char *const *argv)
errorCount += testInternalGet(MHD_USE_EPOLL);
errorCount += testMultithreadedPoolGet(MHD_USE_EPOLL);
}
- if (errorCount != 0)
- fprintf (stderr, "Error (code: %u)\n", errorCount);
+#endif
+ if (0 != errorCount)
+ fprintf (stderr,
+ "Error (code: %u)\n",
+ errorCount);
return errorCount != 0; /* 0 == pass */
}
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index 796ea9e2..3e703772 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -16,11 +16,39 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/include \
$(LIBCURL_CPPFLAGS)
+
+THREAD_ONLY_TESTS = \
+ test_urlparse \
+ test_long_header \
+ test_long_header11 \
+ test_iplimit11 \
+ test_termination \
+ test_timeout
+
+
+
+if HAVE_POSIX_THREADS
+THREAD_ONLY_TESTS += \
+ test_quiesce \
+ test_concurrent_stop \
+ perf_get_concurrent
+
+if HAVE_CURL_BINARY
+THREAD_ONLY_TESTS += \
+ test_quiesce_stream
+endif
+endif
+
+if ENABLE_DAUTH
+ THREAD_ONLY_TESTS += \
+ test_digestauth \
+ test_digestauth_with_arguments
+endif
+
if HAVE_CURL
check_PROGRAMS = \
test_get \
test_get_sendfile \
- test_urlparse \
test_delete \
test_put \
test_process_headers \
@@ -32,33 +60,11 @@ check_PROGRAMS = \
test_put11 \
test_large_put11 \
test_large_put_inc11 \
- test_long_header \
- test_long_header11 \
test_get_chunked \
test_put_chunked \
- test_iplimit11 \
- test_termination \
- test_timeout \
test_callback \
perf_get
-if HAVE_FORK_WAITPID
-if HAVE_CURL_BINARY
-check_PROGRAMS += test_get_response_cleanup
-endif
-endif
-
-if HAVE_POSIX_THREADS
-check_PROGRAMS += \
- test_quiesce \
- test_concurrent_stop \
- perf_get_concurrent
-
-if HAVE_CURL_BINARY
-check_PROGRAMS += test_quiesce_stream
-endif
-endif
-
if HAVE_POSTPROCESSOR
check_PROGRAMS += \
test_post \
@@ -69,9 +75,19 @@ if HAVE_POSTPROCESSOR
test_post_loop11
endif
-if ENABLE_DAUTH
- check_PROGRAMS += \
- test_digestauth test_digestauth_with_arguments
+if HAVE_FORK_WAITPID
+if HAVE_CURL_BINARY
+check_PROGRAMS += test_get_response_cleanup
+endif
+endif
+
+if USE_POSIX_THREADS
+check_PROGRAMS +=
+ $(THREAD_ONLY_TESTS)
+endif
+if USE_W32_THREADS
+check_PROGRAMS +=
+ $(THREAD_ONLY_TESTS)
endif
TESTS = $(check_PROGRAMS)
diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am
index 239ce2ca..7454ab06 100644
--- a/src/testcurl/https/Makefile.am
+++ b/src/testcurl/https/Makefile.am
@@ -10,8 +10,9 @@ if HAVE_GNUTLS_SNI
endif
if HAVE_POSIX_THREADS
- HTTPS_PARALLEL_TESTS = test_https_get_parallel \
- test_https_get_parallel_threads
+ HTTPS_PARALLEL_TESTS = \
+ test_https_get_parallel \
+ test_https_get_parallel_threads
endif
CPU_COUNT_DEF = -DCPU_COUNT=$(CPU_COUNT)
@@ -22,32 +23,36 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/platform \
$(LIBCURL_CPPFLAGS) $(MHD_TLS_LIB_CPPFLAGS)
-check_PROGRAMS = \
+THREAD_ONLY_TESTS = \
test_tls_options \
test_tls_authentication \
- test_https_multi_daemon \
- test_https_get \
- $(TEST_HTTPS_SNI) \
- test_https_get_select \
$(HTTPS_PARALLEL_TESTS) \
+ $(TEST_HTTPS_SNI) \
test_https_session_info \
test_https_time_out \
+ test_https_multi_daemon \
+ test_https_get \
test_empty_response
-EXTRA_DIST = cert.pem key.pem \
- host1.crt host1.key host2.crt host2.key
+check_PROGRAMS = \
+ test_https_get_select
+
+if USE_POSIX_THREADS
+check_PROGRAMS +=
+ $(THREAD_ONLY_TESTS)
+endif
+if USE_W32_THREADS
+check_PROGRAMS +=
+ $(THREAD_ONLY_TESTS)
+endif
+
+EXTRA_DIST = \
+ cert.pem key.pem \
+ host1.crt host1.key \
+ host2.crt host2.key
TESTS = \
- test_tls_options \
- test_https_multi_daemon \
- test_https_get \
- $(TEST_HTTPS_SNI) \
- test_https_get_select \
- $(HTTPS_PARALLEL_TESTS) \
- test_https_session_info \
- test_https_time_out \
- test_tls_authentication \
- test_empty_response
+ $(check_PROGRAMS)
test_https_time_out_SOURCES = \
diff --git a/src/testcurl/https/tls_test_common.c
b/src/testcurl/https/tls_test_common.c
index a3a7df24..3641f098 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -526,7 +526,9 @@ test_wrap (const char *test_name, int
return ret;
}
-int testsuite_curl_global_init (void)
+
+int
+testsuite_curl_global_init (void)
{
CURLcode res;
#if LIBCURL_VERSION_NUM >= 0x073800
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c
index ac6a23f3..b5d754a8 100644
--- a/src/testcurl/perf_get.c
+++ b/src/testcurl/perf_get.c
@@ -589,22 +589,25 @@ main (int argc, char *const *argv)
"/hello_world",
MHD_RESPMEM_MUST_COPY);
errorCount += testExternalGet (port++);
- errorCount += testInternalGet (port++, MHD_USE_AUTO);
- errorCount += testMultithreadedGet (port++, MHD_USE_AUTO);
- errorCount += testMultithreadedPoolGet (port++, MHD_USE_AUTO);
- errorCount += testInternalGet (port++, 0);
- errorCount += testMultithreadedGet (port++, 0);
- errorCount += testMultithreadedPoolGet (port++, 0);
- if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
{
- errorCount += testInternalGet(port++, MHD_USE_POLL);
- errorCount += testMultithreadedGet(port++, MHD_USE_POLL);
- errorCount += testMultithreadedPoolGet(port++, MHD_USE_POLL);
- }
- if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
- {
- errorCount += testInternalGet(port++, MHD_USE_EPOLL);
- errorCount += testMultithreadedPoolGet(port++, MHD_USE_EPOLL);
+ errorCount += testInternalGet (port++, MHD_USE_AUTO);
+ errorCount += testMultithreadedGet (port++, MHD_USE_AUTO);
+ errorCount += testMultithreadedPoolGet (port++, MHD_USE_AUTO);
+ errorCount += testInternalGet (port++, 0);
+ errorCount += testMultithreadedGet (port++, 0);
+ errorCount += testMultithreadedPoolGet (port++, 0);
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
+ {
+ errorCount += testInternalGet(port++, MHD_USE_POLL);
+ errorCount += testMultithreadedGet(port++, MHD_USE_POLL);
+ errorCount += testMultithreadedPoolGet(port++, MHD_USE_POLL);
+ }
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
+ {
+ errorCount += testInternalGet(port++, MHD_USE_EPOLL);
+ errorCount += testMultithreadedPoolGet(port++, MHD_USE_EPOLL);
+ }
}
MHD_destroy_response (response);
if (errorCount != 0)
diff --git a/src/testcurl/test_delete.c b/src/testcurl/test_delete.c
index 70f0f509..35f7f6a2 100644
--- a/src/testcurl/test_delete.c
+++ b/src/testcurl/test_delete.c
@@ -512,9 +512,12 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalDelete ();
- errorCount += testMultithreadedDelete ();
- errorCount += testMultithreadedPoolDelete ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalDelete ();
+ errorCount += testMultithreadedDelete ();
+ errorCount += testMultithreadedPoolDelete ();
+ }
errorCount += testExternalDelete ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index 1c9796f7..cb81283f 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -739,38 +739,43 @@ int
main (int argc, char *const *argv)
{
unsigned int errorCount = 0;
- (void)argc; /* Unused. Silent compiler warning. */
+ (void) argc; /* Unused. Silence compiler warning. */
oneone = (NULL != strrchr (argv[0], (int) '/')) ?
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
global_port = 0;
- errorCount += testInternalGet (0);
- errorCount += testMultithreadedGet (0);
- errorCount += testMultithreadedPoolGet (0);
- errorCount += testUnknownPortGet (0);
- errorCount += testStopRace (0);
errorCount += testExternalGet ();
- errorCount += testEmptyGet (0);
- if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
{
- errorCount += testInternalGet(MHD_USE_POLL);
- errorCount += testMultithreadedGet(MHD_USE_POLL);
- errorCount += testMultithreadedPoolGet(MHD_USE_POLL);
- errorCount += testUnknownPortGet(MHD_USE_POLL);
- errorCount += testStopRace(MHD_USE_POLL);
- errorCount += testEmptyGet(MHD_USE_POLL);
+ errorCount += testInternalGet (0);
+ errorCount += testMultithreadedGet (0);
+ errorCount += testMultithreadedPoolGet (0);
+ errorCount += testUnknownPortGet (0);
+ errorCount += testStopRace (0);
+ errorCount += testEmptyGet (0);
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
+ {
+ errorCount += testInternalGet(MHD_USE_POLL);
+ errorCount += testMultithreadedGet(MHD_USE_POLL);
+ errorCount += testMultithreadedPoolGet(MHD_USE_POLL);
+ errorCount += testUnknownPortGet(MHD_USE_POLL);
+ errorCount += testStopRace(MHD_USE_POLL);
+ errorCount += testEmptyGet(MHD_USE_POLL);
+ }
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
+ {
+ errorCount += testInternalGet(MHD_USE_EPOLL);
+ errorCount += testMultithreadedPoolGet(MHD_USE_EPOLL);
+ errorCount += testUnknownPortGet(MHD_USE_EPOLL);
+ errorCount += testEmptyGet(MHD_USE_EPOLL);
+ }
}
- if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
- {
- errorCount += testInternalGet(MHD_USE_EPOLL);
- errorCount += testMultithreadedPoolGet(MHD_USE_EPOLL);
- errorCount += testUnknownPortGet(MHD_USE_EPOLL);
- errorCount += testEmptyGet(MHD_USE_EPOLL);
- }
- if (errorCount != 0)
- fprintf (stderr, "Error (code: %u)\n", errorCount);
+ if (0 != errorCount)
+ fprintf (stderr,
+ "Error (code: %u)\n",
+ errorCount);
curl_global_cleanup ();
return errorCount != 0; /* 0 == pass */
}
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c
index d813566c..66a9fbde 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -506,9 +506,12 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalGet ();
- errorCount += testMultithreadedGet ();
- errorCount += testMultithreadedPoolGet ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalGet ();
+ errorCount += testMultithreadedGet ();
+ errorCount += testMultithreadedPoolGet ();
+ }
errorCount += testExternalGet ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_get_response_cleanup.c
b/src/testcurl/test_get_response_cleanup.c
index d3d45d2f..457c646f 100644
--- a/src/testcurl/test_get_response_cleanup.c
+++ b/src/testcurl/test_get_response_cleanup.c
@@ -417,9 +417,12 @@ main (int argc, char *const *argv)
oneone = (NULL != strrchr (argv[0], (int) '/')) ?
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
- errorCount += testInternalGet ();
- errorCount += testMultithreadedGet ();
- errorCount += testMultithreadedPoolGet ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalGet ();
+ errorCount += testMultithreadedGet ();
+ errorCount += testMultithreadedPoolGet ();
+ }
errorCount += testExternalGet ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c
index c7e94945..3d820fc8 100644
--- a/src/testcurl/test_get_sendfile.c
+++ b/src/testcurl/test_get_sendfile.c
@@ -603,11 +603,14 @@ main (int argc, char *const *argv)
fclose (f);
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalGet ();
- errorCount += testMultithreadedGet ();
- errorCount += testMultithreadedPoolGet ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalGet ();
+ errorCount += testMultithreadedGet ();
+ errorCount += testMultithreadedPoolGet ();
+ errorCount += testUnknownPortGet ();
+ }
errorCount += testExternalGet ();
- errorCount += testUnknownPortGet ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
curl_global_cleanup ();
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c
index b7a87c8f..f4c767cc 100644
--- a/src/testcurl/test_large_put.c
+++ b/src/testcurl/test_large_put.c
@@ -605,47 +605,50 @@ main (int argc, char *const *argv)
put_buffer = alloc_init (PUT_SIZE);
if (NULL == put_buffer)
return 99;
- lastErr = testPutInternalThread (0);
- if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with internal thread with
select().\n");
- errorCount += lastErr;
- lastErr = testPutThreadPerConn (0);
- if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with internal thread per connection
with select().\n");
- errorCount += lastErr;
- lastErr = testPutThreadPool (0);
- if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with thread pool per connection
with select().\n");
- errorCount += lastErr;
lastErr = testPutExternal ();
if (verbose && 0 != lastErr)
fprintf (stderr, "Error during testing with external select().\n");
errorCount += lastErr;
- if (MHD_is_feature_supported(MHD_FEATURE_POLL))
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
{
- lastErr = testPutInternalThread (MHD_USE_POLL);
+ lastErr = testPutInternalThread (0);
if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with internal thread with
poll().\n");
+ fprintf (stderr, "Error during testing with internal thread with
select().\n");
errorCount += lastErr;
- lastErr = testPutThreadPerConn (MHD_USE_POLL);
- if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with internal thread per
connection with poll().\n");
- errorCount += lastErr;
- lastErr = testPutThreadPool (MHD_USE_POLL);
- if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with thread pool per connection
with poll().\n");
- errorCount += lastErr;
- }
- if (MHD_is_feature_supported(MHD_FEATURE_EPOLL))
- {
- lastErr = testPutInternalThread (MHD_USE_EPOLL);
+ lastErr = testPutThreadPerConn (0);
if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with internal thread with
epoll.\n");
+ fprintf (stderr, "Error during testing with internal thread per
connection with select().\n");
errorCount += lastErr;
- lastErr = testPutThreadPool (MHD_USE_EPOLL);
+ lastErr = testPutThreadPool (0);
if (verbose && 0 != lastErr)
- fprintf (stderr, "Error during testing with thread pool per connection
with epoll.\n");
+ fprintf (stderr, "Error during testing with thread pool per connection
with select().\n");
errorCount += lastErr;
+ if (MHD_is_feature_supported(MHD_FEATURE_POLL))
+ {
+ lastErr = testPutInternalThread (MHD_USE_POLL);
+ if (verbose && 0 != lastErr)
+ fprintf (stderr, "Error during testing with internal thread with
poll().\n");
+ errorCount += lastErr;
+ lastErr = testPutThreadPerConn (MHD_USE_POLL);
+ if (verbose && 0 != lastErr)
+ fprintf (stderr, "Error during testing with internal thread per
connection with poll().\n");
+ errorCount += lastErr;
+ lastErr = testPutThreadPool (MHD_USE_POLL);
+ if (verbose && 0 != lastErr)
+ fprintf (stderr, "Error during testing with thread pool per
connection with poll().\n");
+ errorCount += lastErr;
+ }
+ if (MHD_is_feature_supported(MHD_FEATURE_EPOLL))
+ {
+ lastErr = testPutInternalThread (MHD_USE_EPOLL);
+ if (verbose && 0 != lastErr)
+ fprintf (stderr, "Error during testing with internal thread with
epoll.\n");
+ errorCount += lastErr;
+ lastErr = testPutThreadPool (MHD_USE_EPOLL);
+ if (verbose && 0 != lastErr)
+ fprintf (stderr, "Error during testing with thread pool per
connection with epoll.\n");
+ errorCount += lastErr;
+ }
}
free (put_buffer);
if (errorCount != 0)
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c
index 6b91b9cc..cfef2c46 100644
--- a/src/testcurl/test_post.c
+++ b/src/testcurl/test_post.c
@@ -774,10 +774,13 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testMultithreadedPostCancel ();
- errorCount += testInternalPost ();
- errorCount += testMultithreadedPost ();
- errorCount += testMultithreadedPoolPost ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testMultithreadedPostCancel ();
+ errorCount += testInternalPost ();
+ errorCount += testMultithreadedPost ();
+ errorCount += testMultithreadedPoolPost ();
+ }
errorCount += testExternalPost ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 6da06b45..aae297d4 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -583,36 +583,39 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- start_time = now();
- errorCount += testInternalPost ();
- fprintf (stderr,
- oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential
POSTs (http/1.0) %f/s\n",
- "internal select",
- (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
- GAUGER ("internal select",
- oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
- (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
- "requests/s");
- start_time = now();
- errorCount += testMultithreadedPost ();
- fprintf (stderr,
- oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential
POSTs (http/1.0) %f/s\n",
- "multithreaded post",
- (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
- GAUGER ("Multithreaded select",
- oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
- (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
- "requests/s");
- start_time = now();
- errorCount += testMultithreadedPoolPost ();
- fprintf (stderr,
- oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s: Sequential
POSTs (http/1.0) %f/s\n",
- "thread with pool",
- (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
- GAUGER ("thread with pool",
- oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
- (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
- "requests/s");
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ start_time = now();
+ errorCount += testInternalPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s:
Sequential POSTs (http/1.0) %f/s\n",
+ "internal select",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("internal select",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
+ start_time = now();
+ errorCount += testMultithreadedPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s:
Sequential POSTs (http/1.0) %f/s\n",
+ "multithreaded post",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("Multithreaded select",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
+ start_time = now();
+ errorCount += testMultithreadedPoolPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s\n" : "%s:
Sequential POSTs (http/1.0) %f/s\n",
+ "thread with pool",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("thread with pool",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
+ }
start_time = now();
errorCount += testExternalPost ();
fprintf (stderr,
diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c
index f94ed1f8..746d6baa 100644
--- a/src/testcurl/test_postform.c
+++ b/src/testcurl/test_postform.c
@@ -589,9 +589,12 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPost ();
- errorCount += testMultithreadedPost ();
- errorCount += testMultithreadedPoolPost ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPost ();
+ errorCount += testMultithreadedPost ();
+ errorCount += testMultithreadedPoolPost ();
+ }
errorCount += testExternalPost ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_process_headers.c
b/src/testcurl/test_process_headers.c
index d123c441..f9c7cd03 100644
--- a/src/testcurl/test_process_headers.c
+++ b/src/testcurl/test_process_headers.c
@@ -520,9 +520,12 @@ main (int argc, char *const *argv)
oneone = (NULL != strrchr (argv[0], (int) '/')) ?
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
- errorCount += testInternalGet ();
- errorCount += testMultithreadedGet ();
- errorCount += testMultithreadedPoolGet ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalGet ();
+ errorCount += testMultithreadedGet ();
+ errorCount += testMultithreadedPoolGet ();
+ }
errorCount += testExternalGet ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c
index eba7afa0..3df97526 100644
--- a/src/testcurl/test_put.c
+++ b/src/testcurl/test_put.c
@@ -525,9 +525,12 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPut ();
- errorCount += testMultithreadedPut ();
- errorCount += testMultithreadedPoolPut ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPut ();
+ errorCount += testMultithreadedPut ();
+ errorCount += testMultithreadedPoolPut ();
+ }
errorCount += testExternalPut ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_put_chunked.c b/src/testcurl/test_put_chunked.c
index 71e10b77..017bff99 100644
--- a/src/testcurl/test_put_chunked.c
+++ b/src/testcurl/test_put_chunked.c
@@ -518,9 +518,12 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPut ();
- errorCount += testMultithreadedPut ();
- errorCount += testMultithreadedPoolPut ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPut ();
+ errorCount += testMultithreadedPut ();
+ errorCount += testMultithreadedPoolPut ();
+ }
errorCount += testExternalPut ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c
index f9fd9690..5795898a 100644
--- a/src/testcurl/test_quiesce.c
+++ b/src/testcurl/test_quiesce.c
@@ -530,23 +530,28 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0, 0);
- errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION |
MHD_USE_INTERNAL_POLLING_THREAD, 0, 0);
- errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, CPU_COUNT, 0);
errorCount += testExternalGet ();
- if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
{
- errorCount += testGet(MHD_USE_INTERNAL_POLLING_THREAD, 0, MHD_USE_POLL);
- errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION |
MHD_USE_INTERNAL_POLLING_THREAD, 0, MHD_USE_POLL);
- errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, CPU_COUNT,
MHD_USE_POLL);
+ errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0, 0);
+ errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION |
MHD_USE_INTERNAL_POLLING_THREAD, 0, 0);
+ errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, CPU_COUNT, 0);
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
+ {
+ errorCount += testGet(MHD_USE_INTERNAL_POLLING_THREAD, 0,
MHD_USE_POLL);
+ errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION |
MHD_USE_INTERNAL_POLLING_THREAD, 0, MHD_USE_POLL);
+ errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, CPU_COUNT,
MHD_USE_POLL);
+ }
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
+ {
+ errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0,
MHD_USE_EPOLL);
+ errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, CPU_COUNT,
MHD_USE_EPOLL);
+ }
}
- if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
- {
- errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, 0,
MHD_USE_EPOLL);
- errorCount += testGet (MHD_USE_INTERNAL_POLLING_THREAD, CPU_COUNT,
MHD_USE_EPOLL);
- }
- if (errorCount != 0)
- fprintf (stderr, "Error (code: %u)\n", errorCount);
+ if (0 != errorCount)
+ fprintf (stderr,
+ "Error (code: %u)\n",
+ errorCount);
curl_global_cleanup ();
return errorCount != 0; /* 0 == pass */
}
diff --git a/src/testzzuf/Makefile.am b/src/testzzuf/Makefile.am
index 329fe04d..be31bad2 100644
--- a/src/testzzuf/Makefile.am
+++ b/src/testzzuf/Makefile.am
@@ -11,6 +11,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include \
EXTRA_DIST = README socat.c
+THREAD_ONLY_TESTS = \
+ test_long_header
+
check_PROGRAMS = \
test_get \
test_get_chunked \
@@ -23,8 +26,17 @@ check_PROGRAMS = \
test_post11 \
test_post_form11 \
test_put11 \
- test_put_large11 \
- test_long_header
+ test_put_large11
+
+if USE_POSIX_THREADS
+check_PROGRAMS +=
+ $(THREAD_ONLY_TESTS)
+endif
+if USE_W32_THREADS
+check_PROGRAMS +=
+ $(THREAD_ONLY_TESTS)
+endif
+
TESTS = $(check_PROGRAMS)
diff --git a/src/testzzuf/test_get.c b/src/testzzuf/test_get.c
index 7e116d09..223b85e5 100644
--- a/src/testzzuf/test_get.c
+++ b/src/testzzuf/test_get.c
@@ -306,8 +306,11 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalGet ();
- errorCount += testMultithreadedGet ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalGet ();
+ errorCount += testMultithreadedGet ();
+ }
errorCount += testExternalGet ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testzzuf/test_get_chunked.c b/src/testzzuf/test_get_chunked.c
index a74b5d9f..44828853 100644
--- a/src/testzzuf/test_get_chunked.c
+++ b/src/testzzuf/test_get_chunked.c
@@ -335,8 +335,11 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalGet ();
- errorCount += testMultithreadedGet ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalGet ();
+ errorCount += testMultithreadedGet ();
+ }
errorCount += testExternalGet ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testzzuf/test_post.c b/src/testzzuf/test_post.c
index 9a4a8e9c..836f3395 100644
--- a/src/testzzuf/test_post.c
+++ b/src/testzzuf/test_post.c
@@ -389,8 +389,11 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPost ();
- errorCount += testMultithreadedPost ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPost ();
+ errorCount += testMultithreadedPost ();
+ }
errorCount += testExternalPost ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testzzuf/test_post_form.c b/src/testzzuf/test_post_form.c
index d4e01c2b..571c9d99 100644
--- a/src/testzzuf/test_post_form.c
+++ b/src/testzzuf/test_post_form.c
@@ -405,8 +405,11 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPost ();
- errorCount += testMultithreadedPost ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPost ();
+ errorCount += testMultithreadedPost ();
+ }
errorCount += testExternalPost ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testzzuf/test_put.c b/src/testzzuf/test_put.c
index cfe12dee..63518ba8 100644
--- a/src/testzzuf/test_put.c
+++ b/src/testzzuf/test_put.c
@@ -353,8 +353,11 @@ main (int argc, char *const *argv)
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPut ();
- errorCount += testMultithreadedPut ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPut ();
+ errorCount += testMultithreadedPut ();
+ }
errorCount += testExternalPut ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testzzuf/test_put_chunked.c b/src/testzzuf/test_put_chunked.c
index 72a9f316..642e968a 100644
--- a/src/testzzuf/test_put_chunked.c
+++ b/src/testzzuf/test_put_chunked.c
@@ -363,8 +363,11 @@ main (int argc, char *const *argv)
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
- errorCount += testInternalPut ();
- errorCount += testMultithreadedPut ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPut ();
+ errorCount += testMultithreadedPut ();
+ }
errorCount += testExternalPut ();
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
diff --git a/src/testzzuf/test_put_large.c b/src/testzzuf/test_put_large.c
index 540c37f9..40861b87 100644
--- a/src/testzzuf/test_put_large.c
+++ b/src/testzzuf/test_put_large.c
@@ -373,8 +373,11 @@ main (int argc, char *const *argv)
return 2;
put_buffer = malloc (PUT_SIZE);
memset (put_buffer, 1, PUT_SIZE);
- errorCount += testInternalPut ();
- errorCount += testMultithreadedPut ();
+ if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS))
+ {
+ errorCount += testInternalPut ();
+ errorCount += testMultithreadedPut ();
+ }
errorCount += testExternalPut ();
free (put_buffer);
if (errorCount != 0)
--
To stop receiving notification emails like this one, please contact
address@hidden