[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 03/03: Fixed build --without-threads
From: |
gnunet |
Subject: |
[libmicrohttpd] 03/03: Fixed build --without-threads |
Date: |
Sun, 27 Dec 2020 17:39:34 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 7bc79627ff72051d84404da0ec64db124b10b526
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Dec 27 19:38:33 2020 +0300
Fixed build --without-threads
TODO: Fully fix testsuite for builds without threads
---
src/include/mhd_options.h | 6 ++++++
src/microhttpd/connection.c | 8 ++++++++
src/microhttpd/daemon.c | 35 ++++++++++++++++++++++++++++-------
src/microhttpd/internal.h | 2 +-
src/microhttpd/mhd_locks.h | 13 +++++++++++++
src/microhttpd/mhd_threads.h | 6 ++++++
src/microhttpd/response.c | 2 ++
7 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h
index dddc336f..0e803451 100644
--- a/src/include/mhd_options.h
+++ b/src/include/mhd_options.h
@@ -74,6 +74,12 @@
#define MHD_LINUX_SOLARIS_SENDFILE 1
#endif /* HAVE_LINUX_SENDFILE || HAVE_SOLARIS_SENDFILE */
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
+# ifndef MHD_USE_THREADS
+# define MHD_USE_THREADS 1
+# endif
+#endif /* MHD_USE_POSIX_THREADS || MHD_USE_W32_THREADS */
+
#if OS390
#define _OPEN_THREADS
#define _OPEN_SYS_SOCK_IPV6
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 7562ba52..166695fb 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -646,8 +646,10 @@ MHD_connection_close_ (struct MHD_Connection *connection,
struct MHD_Daemon *daemon = connection->daemon;
struct MHD_Response *resp = connection->response;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (connection->pid) );
+#endif /* MHD_USE_THREADS */
MHD_connection_mark_closed_ (connection);
if (NULL != resp)
@@ -682,9 +684,11 @@ MHD_connection_finish_forward_ (struct MHD_Connection
*connection)
struct MHD_Daemon *daemon = connection->daemon;
struct MHD_UpgradeResponseHandle *urh = connection->urh;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
(0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
if (0 == (daemon->options & MHD_USE_TLS))
return; /* Nothing to do with non-TLS connection. */
@@ -3148,8 +3152,10 @@ static void
cleanup_connection (struct MHD_Connection *connection)
{
struct MHD_Daemon *daemon = connection->daemon;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (connection->pid) );
+#endif /* MHD_USE_THREADS */
if (connection->in_cleanup)
return; /* Prevent double cleanup. */
@@ -3229,8 +3235,10 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
char *line;
size_t line_len;
enum MHD_Result ret;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (connection->pid) );
+#endif /* MHD_USE_THREADS */
connection->in_idle = true;
while (! connection->suspended)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 6b0aec81..c70b9d7a 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1346,8 +1346,10 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
* of processing - it will be processed on next iteration. */
bool was_closed;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (connection->pid) );
+#endif /* MHD_USE_THREADS */
if (daemon->shutdown)
{
/* Daemon shutting down, application will not receive any more data. */
@@ -2609,6 +2611,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
}
+#ifdef MHD_USE_THREADS
/**
* Close prepared, but not yet processed connection.
* @param daemon the daemon
@@ -2642,6 +2645,9 @@ new_connection_close_ (struct MHD_Daemon *daemon,
}
+#endif /* MHD_USE_THREADS */
+
+
/**
* Finally insert the new connection to the list of connections
* served by the daemon and start processing.
@@ -2660,10 +2666,12 @@ new_connection_process_ (struct MHD_Daemon *daemon,
mhd_assert (connection->daemon == daemon);
+#ifdef MHD_USE_THREADS
/* Function manipulate connection and timeout DL-lists,
* must be called only within daemon thread. */
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
/* Allocate memory pool in the processing thread so
* intensively used memory area is allocated in "good"
@@ -2992,11 +3000,10 @@ 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_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
(0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
-
-#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
#endif
if (connection->resuming)
@@ -3091,9 +3098,11 @@ MHD_suspend_connection (struct MHD_Connection
*connection)
{
struct MHD_Daemon *const daemon = connection->daemon;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
(0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
MHD_PANIC (_ (
@@ -3465,8 +3474,10 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
bool sk_nonbl;
bool sk_spipe_supprs;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
addrlen = sizeof (addrstorage);
memset (addr,
@@ -3630,10 +3641,10 @@ static void
MHD_cleanup_connections (struct MHD_Daemon *daemon)
{
struct MHD_Connection *pos;
+#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
-#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))
@@ -3746,8 +3757,10 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
struct MHD_Connection *pos;
bool have_timeout;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
@@ -4558,8 +4571,10 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon)
struct MHD_UpgradeResponseHandle *pos;
struct MHD_UpgradeResponseHandle *prev;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
num_events = MAX_EVENTS;
while (0 != num_events)
@@ -5044,8 +5059,10 @@ close_connection (struct MHD_Connection *pos)
{
struct MHD_Daemon *daemon = pos->daemon;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
+#endif /* MHD_USE_THREADS */
if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
@@ -7101,16 +7118,16 @@ close_all_connections (struct MHD_Daemon *daemon)
const bool used_tls = (0 != (daemon->options & MHD_USE_TLS));
#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
(0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
MHD_thread_ID_match_current_ (daemon->pid) );
-
-#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
mhd_assert (NULL == daemon->worker_pool);
-#endif
+#endif /* MHD_USE_THREADS */
mhd_assert (daemon->shutdown);
- /* Remove externally added new connections that are
+#ifdef MHD_USE_THREADS
+/* Remove externally added new connections that are
* not processed by the daemon thread. */
while (NULL != (pos = daemon->new_connections_tail))
{
@@ -7120,6 +7137,8 @@ close_all_connections (struct MHD_Daemon *daemon)
pos);
new_connection_close_ (daemon, pos);
}
+#endif /* MHD_USE_THREADS */
+
#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
/* give upgraded HTTPS connections a chance to finish */
/* 'daemon->urh_head' is not used in thread-per-connection mode. */
@@ -7196,6 +7215,7 @@ close_all_connections (struct MHD_Daemon *daemon)
MHD_PANIC (_ (
"MHD_stop_daemon() called while we have suspended
connections.\n"));
#if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT)
+#ifdef MHD_USE_THREADS
if (upg_allowed && used_tls && used_thr_p_c)
{
/* "Upgraded" threads may be running in parallel. Connection will not be
@@ -7221,6 +7241,7 @@ close_all_connections (struct MHD_Daemon *daemon)
}
}
}
+#endif /* MHD_USE_THREADS */
#endif
for (pos = daemon->connections_tail; NULL != pos; pos = pos->prev)
{
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 1c2496d8..f3c4cb1e 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -69,8 +69,8 @@
#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
#include "mhd_threads.h"
-#include "mhd_locks.h"
#endif
+#include "mhd_locks.h"
#include "mhd_sockets.h"
#include "mhd_itc_types.h"
diff --git a/src/microhttpd/mhd_locks.h b/src/microhttpd/mhd_locks.h
index 8c9b0844..2ef7747e 100644
--- a/src/microhttpd/mhd_locks.h
+++ b/src/microhttpd/mhd_locks.h
@@ -39,6 +39,8 @@
#include "mhd_options.h"
+#ifdef MHD_USE_THREADS
+
#if defined(MHD_USE_W32_THREADS)
# define MHD_W32_MUTEX_ 1
# ifndef WIN32_LEAN_AND_MEAN
@@ -182,5 +184,16 @@ typedef CRITICAL_SECTION MHD_mutex_;
MHD_PANIC (_ ("Failed to unlock mutex.\n")); \
} while (0)
+#else /* ! MHD_USE_THREADS */
+
+#define MHD_mutex_init_(ignore) (! 0)
+#define MHD_mutex_destroy_(ignore) (! 0)
+#define MHD_mutex_destroy_chk_(ignore) (void)0
+#define MHD_mutex_lock_(ignore) (! 0)
+#define MHD_mutex_lock_chk_(ignore) (void)0
+#define MHD_mutex_unlock_(ignore) (! 0)
+#define MHD_mutex_unlock_chk_(ignore) (void)0
+
+#endif /* ! MHD_USE_THREADS */
#endif /* ! MHD_LOCKS_H */
diff --git a/src/microhttpd/mhd_threads.h b/src/microhttpd/mhd_threads.h
index 6f690893..dcc7b09a 100644
--- a/src/microhttpd/mhd_threads.h
+++ b/src/microhttpd/mhd_threads.h
@@ -47,11 +47,17 @@
# undef HAVE_CONFIG_H
# include <pthread.h>
# define HAVE_CONFIG_H 1
+# ifndef MHD_USE_THREADS
+# define MHD_USE_THREADS 1
+# endif
#elif defined(MHD_USE_W32_THREADS)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif /* !WIN32_LEAN_AND_MEAN */
# include <windows.h>
+# ifndef MHD_USE_THREADS
+# define MHD_USE_THREADS 1
+# endif
#else
# error No threading API is available.
#endif
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index a77dbe27..4ae46bf3 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -951,8 +951,10 @@ MHD_response_execute_upgrade_ (struct MHD_Response
*response,
struct MHD_UpgradeResponseHandle *urh;
size_t rbo;
+#ifdef MHD_USE_THREADS
mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
MHD_thread_ID_match_current_ (connection->pid) );
+#endif /* MHD_USE_THREADS */
if (0 == (daemon->options & MHD_ALLOW_UPGRADE))
return MHD_NO;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.