gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (ede33803 -> 2475030d)


From: gnunet
Subject: [libmicrohttpd] branch master updated (ede33803 -> 2475030d)
Date: Thu, 09 Nov 2023 17:51:46 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from ede33803 Fixed merge conflict introduced by 
32eae456fddba5b48d08f44dda956a0ea1ffffea
     new a0de9d33 Added use of the new internal macro MHD_D_IS_USING_THREADS_()
     new 2475030d Added use of the new internal macro 
MHD_D_IS_USING_THREAD_PER_CONN_

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/microhttpd/connection.c |  30 +++++------
 src/microhttpd/daemon.c     | 124 ++++++++++++++++++++++----------------------
 src/microhttpd/mhd_send.c   |   3 +-
 src/microhttpd/response.c   |   4 +-
 4 files changed, 79 insertions(+), 82 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 3f11b4eb..78d7d5df 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1249,7 +1249,7 @@ MHD_connection_close_ (struct MHD_Connection *connection,
 
   mhd_assert (! connection->suspended);
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
   if ( (NULL != daemon->notify_completed) &&
@@ -1292,15 +1292,15 @@ MHD_connection_finish_forward_ (struct MHD_Connection 
*connection)
   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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
+               MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
   if (0 == (daemon->options & MHD_USE_TLS))
     return; /* Nothing to do with non-TLS connection. */
 
-  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     DLL_remove (daemon->urh_head,
                 daemon->urh_tail,
                 urh);
@@ -3465,7 +3465,7 @@ handle_recv_no_space (struct MHD_Connection *c,
     {
       /* The connection must not be in MHD_EVENT_LOOP_INFO_READ state
          when external polling is used and some data left unprocessed. */
-      mhd_assert (0 != (c->daemon->options & MHD_USE_INTERNAL_POLLING_THREAD));
+      mhd_assert (MHD_D_IS_USING_THREADS_ (c->daemon));
       /* failed to grow the read buffer, and the
          client which is supposed to handle the
          received data in a *blocking* fashion
@@ -3616,7 +3616,7 @@ check_and_grow_read_buffer_space (struct MHD_Connection 
*c)
      space in the read buffer must be available. */
   mhd_assert (0 == (MHD_EVENT_LOOP_INFO_PROCESS & c->event_loop_info));
 
-  if ((0 == (c->daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
+  if ((! MHD_D_IS_USING_THREADS_ (c->daemon))
       && (MHD_CONNECTION_BODY_RECEIVING == c->state)
       && has_unprocessed_upload_body_data_in_buffer (c))
   {
@@ -4629,7 +4629,7 @@ process_request_body (struct MHD_Connection *connection)
         /* client did not process any upload data, complain if
            the setup was incorrect, which may prevent us from
            handling the rest of the request */
-        if (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
+        if (MHD_D_IS_USING_THREADS_ (daemon))
           MHD_DLOG (daemon,
                     _ ("WARNING: Access Handler Callback has not processed " \
                        "any upload data and connection is not suspended. " \
@@ -6351,7 +6351,7 @@ MHD_update_last_activity_ (struct MHD_Connection 
*connection)
     return;  /* no activity on suspended connections */
 
   connection->last_activity = MHD_monotonic_msec_counter ();
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     return; /* each connection has personal timeout */
 
   if (connection->connection_timeout_ms != daemon->connection_timeout_ms)
@@ -6948,7 +6948,7 @@ 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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (connection->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
@@ -6973,7 +6973,7 @@ cleanup_connection (struct MHD_Connection *connection)
   }
   else
   {
-    if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+    if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     {
       if (connection->connection_timeout_ms == daemon->connection_timeout_ms)
         XDLL_remove (daemon->normal_timeout_head,
@@ -6996,7 +6996,7 @@ cleanup_connection (struct MHD_Connection *connection)
 #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 (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
   {
     /* if we were at the connection limit before and are in
        thread-per-connection mode, signal the main thread
@@ -7155,7 +7155,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
   struct MHD_Daemon *daemon = connection->daemon;
   enum MHD_Result ret;
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
   /* 'daemon' is not used if epoll is not available and asserts are disabled */
@@ -7738,7 +7738,7 @@ MHD_set_connection_option (struct MHD_Connection 
*connection,
       ui_val = UINT64_MAX / 4000 - 1;
     }
 #endif /* (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT */
-    if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+    if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     {
 #if defined(MHD_USE_THREADS)
       MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -7832,7 +7832,7 @@ MHD_queue_response (struct MHD_Connection *connection,
 
   daemon = connection->daemon;
   if ((! connection->in_access_handler) && (! connection->suspended) &&
-      (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)))
+      MHD_D_IS_USING_THREADS_ (daemon))
     return MHD_NO;
 
   reply_icy = (0 != (status_code & MHD_ICY_FLAG));
@@ -7840,7 +7840,7 @@ MHD_queue_response (struct MHD_Connection *connection,
 
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   if ( (! connection->suspended) &&
-       (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+       MHD_D_IS_USING_THREADS_ (daemon) &&
        (! MHD_thread_handle_ID_is_current_thread_ (connection->tid)) )
   {
 #ifdef HAVE_MESSAGES
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 9fc7ac0b..a53ba0d5 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1145,7 +1145,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
   if ( (NULL == daemon) ||
        (NULL == read_fd_set) ||
        (NULL == write_fd_set) ||
-       (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ||
+       MHD_D_IS_USING_THREADS_ (daemon) ||
        MHD_D_IS_USING_POLL_ (daemon))
     return MHD_NO;
 
@@ -1333,7 +1333,7 @@ call_handlers (struct MHD_Connection *con,
    * TLS read-ready connection in 'read info' state as connection
    * without space in read buffer will be marked as 'info block'. */
   if ( (! con->daemon->data_already_pending) &&
-       (0 == (con->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) )
+       (! MHD_D_IS_USING_THREAD_PER_CONN_ (con->daemon)) )
   {
     if (0 != (MHD_EVENT_LOOP_INFO_PROCESS & con->event_loop_info))
       con->daemon->data_already_pending = true;
@@ -1407,7 +1407,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
   bool was_closed;
 
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
   if (daemon->shutdown)
@@ -1708,7 +1708,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
    * and incoming forward buffer have some space. */
   if ( (connection->tls_read_ready) &&
        (urh->in_buffer_used < urh->in_buffer_size) &&
-       (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) )
+       (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) )
     daemon->data_already_pending = true;
 
   if ( (daemon->shutdown) &&
@@ -1753,7 +1753,7 @@ thread_main_connection_upgrade (struct MHD_Connection 
*con)
   struct MHD_UpgradeResponseHandle *urh = con->urh;
   struct MHD_Daemon *daemon = con->daemon;
 
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (con->tid) );
   /* Here, we need to bi-directionally forward
      until the application tells us that it is done
@@ -2830,7 +2830,7 @@ new_connection_process_ (struct MHD_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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
@@ -2875,7 +2875,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
       DLL_insert (daemon->connections_head,
                   daemon->connections_tail,
                   connection);
-      if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+      if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
       {
         XDLL_insert (daemon->normal_timeout_head,
                      daemon->normal_timeout_tail,
@@ -2891,7 +2891,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
                                    &connection->socket_context,
                                    MHD_CONNECTION_NOTIFY_STARTED);
 #ifdef MHD_USE_THREADS
-      if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+      if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
       {
         mhd_assert (! MHD_D_IS_USING_EPOLL_ (daemon));
         if (! MHD_create_named_thread_ (&connection->tid,
@@ -2978,7 +2978,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
                                    &connection->socket_context,
                                    MHD_CONNECTION_NOTIFY_CLOSED);
       MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-      if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+      if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
       {
         XDLL_remove (daemon->normal_timeout_head,
                      daemon->normal_timeout_tail,
@@ -3101,7 +3101,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
     return MHD_NO;
 
   if ((external_add) &&
-      (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)))
+      MHD_D_IS_USING_THREADS_ (daemon))
   {
     /* Connection is added externally and MHD is handling its own threads. */
     MHD_mutex_lock_chk_ (&daemon->new_connections_mutex);
@@ -3135,7 +3135,7 @@ new_connections_list_process_ (struct MHD_Daemon *daemon)
   struct MHD_Connection *local_head;
   struct MHD_Connection *local_tail;
   mhd_assert (daemon->have_new);
-  mhd_assert (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD));
+  mhd_assert (MHD_D_IS_USING_THREADS_ (daemon));
 
   /* Detach DL-list of new connections from the daemon for
    * following local processing. */
@@ -3188,8 +3188,8 @@ internal_suspend_connection_ (struct MHD_Connection 
*connection)
   mhd_assert (NULL == daemon->worker_pool);
 
 #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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
+               MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 #endif
@@ -3202,7 +3202,7 @@ internal_suspend_connection_ (struct MHD_Connection 
*connection)
 #endif
     return;
   }
-  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
   {
     if (connection->connection_timeout_ms == daemon->connection_timeout_ms)
       XDLL_remove (daemon->normal_timeout_head,
@@ -3285,8 +3285,8 @@ 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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
+               MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
@@ -3410,7 +3410,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
                                    & MHD_USE_THREAD_PER_CONNECTION));
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   mhd_assert (NULL == daemon->worker_pool);
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
 #endif
 
@@ -3496,7 +3496,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
        * Insert connection into cleanup list. */
 
       if ( (NULL != daemon->notify_completed) &&
-           (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+           (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) &&
            (pos->rq.client_aware) )
       {
         daemon->notify_completed (daemon->notify_completed_cls,
@@ -3571,12 +3571,12 @@ MHD_add_connection (struct MHD_Daemon *daemon,
   struct sockaddr_storage addrstorage;
 
   /* NOT thread safe with internal thread. TODO: fix thread safety. */
-  if ((0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+  if ((! MHD_D_IS_USING_THREADS_ (daemon)) &&
       (daemon->connection_limit <= daemon->connections))
     MHD_cleanup_connections (daemon);
 
 #ifdef HAVE_MESSAGES
-  if ((0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+  if (MHD_D_IS_USING_THREADS_ (daemon) &&
       (0 == (daemon->options & MHD_USE_ITC)))
   {
     MHD_DLOG (daemon,
@@ -3751,7 +3751,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
 #endif /* ! USE_ACCEPT4 && ! _DEBUG */
 
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
@@ -3975,7 +3975,7 @@ 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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 
@@ -3988,9 +3988,9 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
                 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_thread_handle_ID_join_thread_ (pos->tid)) )
+    if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) &&
+        (! pos->thread_joined) &&
+        (! MHD_thread_handle_ID_join_thread_ (pos->tid)) )
       MHD_PANIC (_ ("Failed to join a thread.\n"));
 #endif
 #ifdef UPGRADE_SUPPORT
@@ -4162,11 +4162,11 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon,
   struct MHD_Connection *earliest_tmot_conn; /**< the connection with earliest 
timeout */
 
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
   {
 #ifdef HAVE_MESSAGES
     MHD_DLOG (daemon,
@@ -4579,7 +4579,7 @@ MHD_run_from_select2 (struct MHD_Daemon *daemon,
                       unsigned int fd_setsize)
 {
   if (MHD_D_IS_USING_POLL_ (daemon) ||
-      (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)))
+      MHD_D_IS_USING_THREADS_ (daemon))
     return MHD_NO;
   if ((NULL == read_fd_set) || (NULL == write_fd_set))
     return MHD_NO;
@@ -4741,10 +4741,10 @@ MHD_select (struct MHD_Daemon *daemon,
   err_state = MHD_NO;
   if ( (0 != (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME)) &&
        (MHD_NO != resume_suspended_connections (daemon)) &&
-       (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) )
+       (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) )
     millisec = 0;
 
-  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
   {
     /* single-threaded, go over everything */
     if (MHD_NO ==
@@ -4842,7 +4842,7 @@ MHD_select (struct MHD_Daemon *daemon,
     uint64_t mhd_tmo;
     uint64_t select_tmo;
 
-    if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+    if ( (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)) &&
          (MHD_NO != MHD_get_timeout64 (daemon, &mhd_tmo)) )
     {
       if ( (0 < millisec) &&
@@ -5234,7 +5234,7 @@ static enum MHD_Result
 MHD_poll (struct MHD_Daemon *daemon,
           int may_block)
 {
-  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     return MHD_poll_all (daemon,
                          may_block ? -1 : 0);
   return MHD_poll_listen_socket (daemon,
@@ -5313,7 +5313,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon)
   struct MHD_UpgradeResponseHandle *prev;
 
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
@@ -5765,7 +5765,7 @@ _MHD_EXTERN enum MHD_Result
 MHD_run (struct MHD_Daemon *daemon)
 {
   if ( (daemon->shutdown) ||
-       (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) )
+       MHD_D_IS_USING_THREADS_ (daemon) )
     return MHD_NO;
 
   (void) MHD_run_wait (daemon, 0);
@@ -5817,7 +5817,7 @@ MHD_run_wait (struct MHD_Daemon *daemon,
 {
   enum MHD_Result res;
   if ( (daemon->shutdown) ||
-       (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) )
+       MHD_D_IS_USING_THREADS_ (daemon) )
     return MHD_NO;
 
   mhd_assert (! MHD_thread_handle_ID_is_valid_handle_ (daemon->tid));
@@ -5881,12 +5881,12 @@ 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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
 
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+  if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
   {
     MHD_connection_mark_closed_ (pos);
     return;   /* must let thread to do the rest */
@@ -6097,7 +6097,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
   if (MHD_INVALID_SOCKET == ret)
     return MHD_INVALID_SOCKET;
   if ( (0 == (daemon->options & (MHD_USE_ITC))) &&
-       (0 != (daemon->options & (MHD_USE_INTERNAL_POLLING_THREAD))) )
+       MHD_D_IS_USING_THREADS_ (daemon) )
   {
 #ifdef HAVE_MESSAGES
     MHD_DLOG (daemon,
@@ -6662,7 +6662,7 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif /* SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) */
       else
       {
-        if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
+        if (! MHD_D_IS_USING_THREADS_ (daemon))
         {
 #ifdef HAVE_MESSAGES
           MHD_DLOG (daemon,
@@ -6671,7 +6671,7 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif
           return MHD_NO;
         }
-        if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+        if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
         {
 #ifdef HAVE_MESSAGES
           MHD_DLOG (daemon,
@@ -7167,7 +7167,7 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif
 #endif /* HTTPS_SUPPORT */
     case MHD_OPTION_SIGPIPE_HANDLED_BY_APP:
-      if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
+      if (! MHD_D_IS_USING_THREADS_ (daemon))
         daemon->sigpipe_blocked = ( (va_arg (ap,
                                              int)) != 0);
       else
@@ -7284,7 +7284,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
 
   mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon));
   mhd_assert (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION));
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) || \
                MHD_ITC_IS_VALID_ (daemon->itc) );
   daemon->epoll_fd = setup_epoll_fd (daemon);
@@ -7665,9 +7665,9 @@ MHD_start_daemon_va (unsigned int flags,
   }
 #endif
 
-  if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-       && ((NULL != daemon->notify_completed)
-           || (NULL != daemon->notify_connection)) )
+  if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon)
+      && ((NULL != daemon->notify_completed)
+          || (NULL != daemon->notify_connection)) )
     *pflags |= MHD_USE_ITC; /* requires ITC */
 
 #ifdef _DEBUG
@@ -7792,7 +7792,7 @@ MHD_start_daemon_va (unsigned int flags,
 
   /* Thread polling currently works only with internal select thread mode */
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
-  if ( (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) &&
+  if ( (! MHD_D_IS_USING_THREADS_ (daemon)) &&
        (daemon->worker_pool_size > 0) )
   {
 #ifdef HAVE_MESSAGES
@@ -8185,7 +8185,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
       )
   {
-    if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))
+    if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     {
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -8231,7 +8231,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif /* HTTPS_SUPPORT */
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   /* Start threads if requested by parameters */
-  if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD))
+  if (MHD_D_IS_USING_THREADS_ (daemon))
   {
     /* Internal thread (or threads) is used.
      * Make sure that MHD will be able to communicate with threads. */
@@ -8271,8 +8271,7 @@ MHD_start_daemon_va (unsigned int flags,
         goto free_and_fail;
       }
       if (! MHD_create_named_thread_ (&daemon->tid,
-                                      (*pflags
-                                       & MHD_USE_THREAD_PER_CONNECTION) ?
+                                      MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) 
?
                                       "MHD-listen" : "MHD-single",
                                       daemon->thread_stack_size,
                                       &MHD_polling_thread,
@@ -8569,8 +8568,7 @@ static void
 close_all_connections (struct MHD_Daemon *daemon)
 {
   struct MHD_Connection *pos;
-  const bool used_thr_p_c = (0 != (daemon->options
-                                   & MHD_USE_THREAD_PER_CONNECTION));
+  const bool used_thr_p_c = MHD_D_IS_USING_THREAD_PER_CONN_ (daemon);
 #ifdef UPGRADE_SUPPORT
   const bool upg_allowed = (0 != (daemon->options & MHD_ALLOW_UPGRADE));
 #endif /* UPGRADE_SUPPORT */
@@ -8581,8 +8579,8 @@ close_all_connections (struct MHD_Daemon *daemon)
 #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_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
+               MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) || \
                MHD_thread_handle_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
@@ -8593,7 +8591,7 @@ close_all_connections (struct MHD_Daemon *daemon)
    * not processed by the daemon thread. */
   while (NULL != (pos = daemon->new_connections_tail))
   {
-    mhd_assert (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD));
+    mhd_assert (MHD_D_IS_USING_THREADS_ (daemon));
     DLL_remove (daemon->new_connections_head,
                 daemon->new_connections_tail,
                 pos);
@@ -8710,9 +8708,9 @@ close_all_connections (struct MHD_Daemon *daemon)
     shutdown (pos->socket_fd,
               SHUT_RDWR);
 #ifdef MHD_WINSOCK_SOCKETS
-    if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-         (MHD_ITC_IS_VALID_ (daemon->itc)) &&
-         (! MHD_itc_activate_ (daemon->itc, "e")) )
+    if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) &&
+        (MHD_ITC_IS_VALID_ (daemon->itc)) &&
+        (! MHD_itc_activate_ (daemon->itc, "e")) )
       MHD_PANIC (_ ("Failed to signal shutdown via inter-thread " \
                     "communication channel.\n"));
 #endif
@@ -8760,8 +8758,8 @@ close_all_connections (struct MHD_Daemon *daemon)
   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) )
+    if (MHD_D_IS_USING_THREAD_PER_CONN_ (daemon) &&
+        (! pos->thread_joined) )
       MHD_PANIC (_ ("Failed to join a thread.\n"));
 #endif
     close_connection (pos);
@@ -8809,7 +8807,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
   if (NULL != daemon->worker_pool)
   {   /* Master daemon with worker pool. */
     mhd_assert (1 < daemon->worker_pool_size);
-    mhd_assert (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD));
+    mhd_assert (MHD_D_IS_USING_THREADS_ (daemon));
 
     /* Let workers shutdown in parallel. */
     for (i = 0; i < daemon->worker_pool_size; ++i)
@@ -8849,7 +8847,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
 #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))
+    if (MHD_D_IS_USING_THREADS_ (daemon))
     {     /* Worker daemon or single daemon with internal thread(s). */
       mhd_assert (0 == daemon->worker_pool_size);
       /* Separate thread(s) is used for polling sockets. */
@@ -8997,7 +8995,7 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon,
     return NULL;
 #endif /* ! EPOLL_SUPPORT */
   case MHD_DAEMON_INFO_CURRENT_CONNECTIONS:
-    if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
+    if (! MHD_D_IS_USING_THREADS_ (daemon))
     {
       /* Assume that MHD_run() in not called in other thread
        * at the same time. */
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index fc1aaa00..c74415c6 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -1201,8 +1201,7 @@ MHD_send_sendfile_ (struct MHD_Connection *connection)
 #ifdef HAVE_DARWIN_SENDFILE
   off_t len;
 #endif /* HAVE_DARWIN_SENDFILE */
-  const bool used_thr_p_c = (0 != (connection->daemon->options
-                                   & MHD_USE_THREAD_PER_CONNECTION));
+  const bool used_thr_p_c = MHD_D_IS_USING_THREAD_PER_CONN_ (daemon);
   const size_t chunk_size = used_thr_p_c ? MHD_SENFILE_CHUNK_THR_P_C_ :
                             MHD_SENFILE_CHUNK_;
   size_t send_size = 0;
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 78e874d0..9e9c0d73 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -1940,7 +1940,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response 
*response,
   size_t rbo;
 
 #ifdef MHD_USE_THREADS
-  mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
+  mhd_assert ( (! MHD_D_IS_USING_THREADS_ (daemon)) || \
                MHD_thread_handle_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
 
@@ -2112,7 +2112,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response 
*response,
       urh->in_eready_list = true;
     }
 #endif /* EPOLL_SUPPORT */
-    if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION) )
+    if (! MHD_D_IS_USING_THREAD_PER_CONN_ (daemon))
     {
       /* This takes care of further processing for most event loops:
          simply add to DLL for bi-direcitonal processing */

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



reply via email to

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