gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. 53


From: gitolite
Subject: [GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. 53673f6b2174dd752abde08c0181093e9aca7b71
Date: Sun, 13 Nov 2016 18:52:47 +0100 (CET)

The branch, master has been updated
       via  53673f6b2174dd752abde08c0181093e9aca7b71 (commit)
      from  280232dc1e9a6e26b13530c5e576880151935b19 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 53673f6b2174dd752abde08c0181093e9aca7b71
Author: Christian Grothoff <address@hidden>
Date:   Sun Nov 13 18:52:33 2016 +0100

    use 'bool' for a few more internal fields

-----------------------------------------------------------------------

Summary of changes:
 src/microhttpd/connection.c        |  43 +++++++-------
 src/microhttpd/daemon.c            | 118 +++++++++++++++----------------------
 src/microhttpd/internal.h          |   8 +--
 src/testcurl/test_quiesce_stream.c |   2 +
 4 files changed, 73 insertions(+), 98 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index ac1a01e..e634d4a 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2010,7 +2010,7 @@ process_request_body (struct MHD_Connection *connection)
             handling the rest of the request */
          if ( ( (0 != (connection->daemon->options & 
MHD_USE_THREAD_PER_CONNECTION)) ||
                 (0 != (connection->daemon->options & 
MHD_USE_INTERNAL_POLLING_THREAD)) ) &&
-              (MHD_NO == connection->suspended) )
+              (! connection->suspended) )
            MHD_DLOG (connection->daemon,
                      _("WARNING: incomplete POST processing and connection not 
suspended will result in hung connection.\n"));
 #endif
@@ -2666,17 +2666,14 @@ cleanup_connection (struct MHD_Connection *connection)
   if (connection->in_cleanup)
     return; /* Prevent double cleanup. */
 
-  connection->in_cleanup = !0;
+  connection->in_cleanup = true;
   if (NULL != connection->response)
     {
       MHD_destroy_response (connection->response);
       connection->response = NULL;
     }
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    {
-      MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-    }
-  else
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
       if (connection->connection_timeout == daemon->connection_timeout)
         XDLL_remove (daemon->normal_timeout_head,
@@ -2687,7 +2684,7 @@ cleanup_connection (struct MHD_Connection *connection)
                      daemon->manual_timeout_tail,
                      connection);
     }
-  if (MHD_YES == connection->suspended)
+  if (connection->suspended)
     DLL_remove (daemon->suspended_connections_head,
                 daemon->suspended_connections_tail,
                 connection);
@@ -2698,12 +2695,12 @@ cleanup_connection (struct MHD_Connection *connection)
   DLL_insert (daemon->cleanup_head,
              daemon->cleanup_tail,
              connection);
-  connection->suspended = MHD_NO;
-  connection->resuming = MHD_NO;
-  connection->in_idle = MHD_NO;
+  connection->suspended = false;
+  connection->resuming = false;
+  connection->in_idle = false;
+  MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex);
   if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
-      MHD_mutex_unlock_chk_(&daemon->cleanup_connection_mutex);
       /* if we were at the connection limit before and are in
          thread-per-connection mode, signal the main thread
          to resume accepting connections */
@@ -2739,7 +2736,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
   size_t line_len;
   int client_close;
 
-  connection->in_idle = MHD_YES;
+  connection->in_idle = true;
   while (1)
     {
 #if DEBUG_STATES
@@ -2839,7 +2836,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           if (MHD_CONNECTION_CLOSED == connection->state)
             continue;
           connection->state = MHD_CONNECTION_HEADERS_PROCESSED;
-          if (MHD_YES == connection->suspended)
+          if (connection->suspended)
             break;
           continue;
         case MHD_CONNECTION_HEADERS_PROCESSED:
@@ -2869,7 +2866,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
             }
           connection->state = (0 == connection->remaining_upload_size)
             ? MHD_CONNECTION_FOOTERS_RECEIVED : MHD_CONNECTION_CONTINUE_SENT;
-          if (MHD_YES == connection->suspended)
+          if (connection->suspended)
             break;
           continue;
         case MHD_CONNECTION_CONTINUE_SENDING:
@@ -2902,7 +2899,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
                 connection->state = MHD_CONNECTION_BODY_RECEIVED;
               else
                 connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
-              if (MHD_YES == connection->suspended)
+              if (connection->suspended)
                 break;
               continue;
             }
@@ -2925,7 +2922,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           if (0 == line[0])
             {
               connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
-              if (MHD_YES == connection->suspended)
+              if (connection->suspended)
                 break;
               continue;
             }
@@ -2962,7 +2959,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
           if (0 == line[0])
             {
               connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
-              if (MHD_YES == connection->suspended)
+              if (connection->suspended)
                 break;
               continue;
             }
@@ -3205,7 +3202,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
     {
       MHD_connection_close_ (connection,
                              MHD_REQUEST_TERMINATED_TIMEOUT_REACHED);
-      connection->in_idle = MHD_NO;
+      connection->in_idle = false;
       return MHD_YES;
     }
   MHD_connection_update_event_loop_info (connection);
@@ -3305,7 +3302,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection 
*connection)
        }
       connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET;
     }
-  connection->in_idle = MHD_NO;
+  connection->in_idle = false;
   return MHD_YES;
 }
 #endif
@@ -3396,7 +3393,7 @@ MHD_set_connection_option (struct MHD_Connection 
*connection,
     {
     case MHD_CONNECTION_OPTION_TIMEOUT:
       if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-          (MHD_YES != connection->suspended) )
+          (! connection->suspended) )
         {
           if (connection->connection_timeout == daemon->connection_timeout)
             XDLL_remove (daemon->normal_timeout_head,
@@ -3412,7 +3409,7 @@ MHD_set_connection_option (struct MHD_Connection 
*connection,
                                                unsigned int);
       va_end (ap);
       if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-          (MHD_YES != connection->suspended) )
+          (! connection->suspended) )
         {
           if (connection->connection_timeout == daemon->connection_timeout)
             XDLL_insert (daemon->normal_timeout_head,
@@ -3504,7 +3501,7 @@ MHD_queue_response (struct MHD_Connection *connection,
       connection->read_closed = MHD_YES;
       connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
     }
-  if (MHD_NO == connection->in_idle)
+  if (! connection->in_idle)
     (void) MHD_connection_handle_idle (connection);
   return MHD_YES;
 }
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f3578c7..ffd2a5a 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1422,18 +1422,18 @@ thread_main_handle_connection (void *data)
          (MHD_CONNECTION_CLOSED != con->state) )
     {
       const unsigned int timeout = daemon->connection_timeout;
-      int was_suspended = MHD_NO;
+      bool was_suspended = false;
 #ifdef UPGRADE_SUPPORT
       struct MHD_UpgradeResponseHandle * const urh = con->urh;
 #else  /* ! UPGRADE_SUPPORT */
       static const void * const urh = NULL;
 #endif /* ! UPGRADE_SUPPORT */
 
-      if ( (MHD_NO != con->suspended) &&
+      if ( (con->suspended) &&
            (NULL == urh) )
         {
           /* Connection was suspended, wait for resume. */
-          was_suspended = MHD_YES;
+          was_suspended = true;
           if (! use_poll)
             {
               FD_ZERO (&rs);
@@ -1492,11 +1492,11 @@ thread_main_handle_connection (void *data)
           continue; /* Check again for resume. */
         } /* End of "suspended" branch. */
 
-      if ( (MHD_YES == was_suspended) &&
+      if ( (was_suspended) &&
            (0 != con->connection_timeout) )
         {
           con->last_activity = MHD_monotonic_sec_counter(); /* Reset timeout 
timer. */
-          was_suspended = MHD_NO;
+          was_suspended = false;
         }
 
       tvp = NULL;
@@ -2198,21 +2198,17 @@ internal_add_connection (struct MHD_Daemon *daemon,
     }
 
 
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-  {
-    MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-  }
-  else
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
   {
-   XDLL_insert (daemon->normal_timeout_head,
-                daemon->normal_timeout_tail,
-                connection);
+    XDLL_insert (daemon->normal_timeout_head,
+                 daemon->normal_timeout_tail,
+                 connection);
   }
   DLL_insert (daemon->connections_head,
              daemon->connections_tail,
              connection);
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 
   if (NULL != daemon->notify_connection)
     daemon->notify_connection (daemon->notify_connection_cls,
@@ -2294,11 +2290,8 @@ internal_add_connection (struct MHD_Daemon *daemon,
   MHD_ip_limit_del (daemon,
                     addr,
                     addrlen);
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    {
-      MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-    }
-  else
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
       XDLL_remove (daemon->normal_timeout_head,
                    daemon->normal_timeout_tail,
@@ -2307,8 +2300,7 @@ internal_add_connection (struct MHD_Daemon *daemon,
   DLL_remove (daemon->connections_head,
              daemon->connections_tail,
              connection);
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
   MHD_pool_destroy (connection->pool);
   free (connection->addr);
   free (connection);
@@ -2356,11 +2348,8 @@ MHD_suspend_connection (struct MHD_Connection 
*connection)
   daemon = connection->daemon;
   if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME))
     MHD_PANIC (_("Cannot suspend connections without enabling 
MHD_ALLOW_SUSPEND_RESUME!\n"));
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    {
-      MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-    }
-  else
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
       if (connection->connection_timeout == daemon->connection_timeout)
         XDLL_remove (daemon->normal_timeout_head,
@@ -2399,9 +2388,8 @@ MHD_suspend_connection (struct MHD_Connection *connection)
       connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED;
     }
 #endif
-  connection->suspended = MHD_YES;
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  connection->suspended = true;
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 }
 
 
@@ -2421,12 +2409,10 @@ MHD_resume_connection (struct MHD_Connection 
*connection)
   daemon = connection->daemon;
   if (MHD_ALLOW_SUSPEND_RESUME != (daemon->options & MHD_ALLOW_SUSPEND_RESUME))
     MHD_PANIC (_("Cannot resume connections without enabling 
MHD_ALLOW_SUSPEND_RESUME!\n"));
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
-  connection->resuming = MHD_YES;
-  daemon->resuming = MHD_YES;
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  connection->resuming = true;
+  daemon->resuming = true;
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
   if ( (MHD_ITC_IS_VALID_(daemon->itc)) &&
        (! MHD_itc_activate_ (daemon->itc, "r")) )
     {
@@ -2455,10 +2441,9 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
   int ret;
 
   ret = MHD_NO;
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 
-  if (MHD_NO != daemon->resuming)
+  if (daemon->resuming)
     next = daemon->suspended_connections_head;
   /* Clear the flag *only* if connections will be resumed otherwise
      it may accidentally clear flag that was set at the same time in
@@ -2469,7 +2454,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
      function at this time so clearing flag at end will clear it without
      actually resuming of new connection. */
   if (NULL != next)
-    daemon->resuming = MHD_NO;
+    daemon->resuming = false;
   while (NULL != (pos = next))
     {
 #ifdef UPGRADE_SUPPORT
@@ -2478,7 +2463,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
       static const void * const urh = NULL;
 #endif /* ! UPGRADE_SUPPORT */
       next = pos->next;
-      if ( (MHD_NO == pos->resuming)
+      if ( (! pos->resuming)
 #ifdef UPGRADE_SUPPORT
           || ( (NULL != urh) &&
                ( (MHD_NO == urh->was_closed) ||
@@ -2533,21 +2518,19 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
 
         }
 #endif /* UPGRADE_SUPPORT */
-      pos->suspended = MHD_NO;
-      pos->resuming = MHD_NO;
-    }
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    {
-      MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
-      if (MHD_NO != ret)
-        { /* Wake up suspended connections. */
-          if (! MHD_itc_activate_(daemon->itc,
-                                  "w"))
+      pos->suspended = false;
+      pos->resuming = false;
+    }
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+       (MHD_NO != ret) )
+    { /* Wake up suspended connections. */
+      if (! MHD_itc_activate_(daemon->itc,
+                              "w"))
 #ifdef HAVE_MESSAGES
-            MHD_DLOG (daemon,
-                      _("Failed to signal resume of connection via 
inter-thread communication channel."));
+        MHD_DLOG (daemon,
+                  _("Failed to signal resume of connection via inter-thread 
communication channel."));
 #endif
-        }
     }
   return ret;
 }
@@ -2763,16 +2746,13 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
 {
   struct MHD_Connection *pos;
 
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
   while (NULL != (pos = daemon->cleanup_head))
     {
       DLL_remove (daemon->cleanup_head,
                  daemon->cleanup_tail,
                  pos);
-
-      if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-        MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+      MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 
       if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
           (MHD_NO == pos->thread_joined) &&
@@ -2838,11 +2818,9 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
        free (pos->addr);
       free (pos);
 
-      if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-        MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+      MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
     }
-  if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 }
 
 
@@ -5525,13 +5503,12 @@ close_all_connections (struct MHD_Daemon *daemon)
      resumed connection. */
   if (0 != (MHD_ALLOW_SUSPEND_RESUME & daemon->options))
     {
-      daemon->resuming = MHD_YES; /* Force check for pending resume. */
+      daemon->resuming = true; /* Force check for pending resume. */
       resume_suspended_connections (daemon);
     }
   /* first, make sure all threads are aware of shutdown; need to
      traverse DLLs in peace... */
-  if (used_thr_p_c)
-    MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 #ifdef UPGRADE_SUPPORT
   if (upg_allowed)
     {
@@ -5563,8 +5540,8 @@ close_all_connections (struct MHD_Daemon *daemon)
                 MHD_connection_finish_forward_ (susp);
               /* Do not use MHD_resume_connection() as mutex is
                * already locked. */
-              susp->resuming = MHD_YES;
-              daemon->resuming = MHD_YES;
+              susp->resuming = true;
+              daemon->resuming = true;
             }
           susp = susp->next;
         }
@@ -5584,8 +5561,7 @@ close_all_connections (struct MHD_Daemon *daemon)
         MHD_PANIC (_("Failed to signal shutdown via inter-thread communication 
channel"));
 #endif
     }
-  if (used_thr_p_c)
-    MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+  MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
 
   /* now, collect per-connection threads */
   if (used_thr_p_c)
@@ -5614,7 +5590,7 @@ close_all_connections (struct MHD_Daemon *daemon)
    * application should be moved to cleanup list too. */
   if (upg_allowed)
     {
-      daemon->resuming = MHD_YES; /* Force check for pending resume. */
+      daemon->resuming = true; /* Force check for pending resume. */
       resume_suspended_connections (daemon);
     }
 #endif /* UPGRADE_SUPPORT */
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index b6426df..a58d85a 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -811,7 +811,7 @@ struct MHD_Connection
    * Are we currently inside the "idle" handler (to avoid recursively
    * invoking it).
    */
-  int in_idle;
+  bool in_idle;
 
   /**
    * Are we currently inside the "idle" handler (to avoid recursively
@@ -941,12 +941,12 @@ struct MHD_Connection
   /**
    * Is the connection suspended?
    */
-  int suspended;
+  bool suspended;
 
   /**
    * Is the connection wanting to resume?
    */
-  int resuming;
+  bool resuming;
 };
 
 
@@ -1433,7 +1433,7 @@ struct MHD_Daemon
   /*
    * Do we need to process resuming connections?
    */
-  int resuming;
+  bool resuming;
 
   /**
    * Number of active parallel connections.
diff --git a/src/testcurl/test_quiesce_stream.c 
b/src/testcurl/test_quiesce_stream.c
index bee9548..d658b71 100644
--- a/src/testcurl/test_quiesce_stream.c
+++ b/src/testcurl/test_quiesce_stream.c
@@ -57,6 +57,7 @@ resume_connection (void *arg)
 {
   struct MHD_Connection *connection = arg;
 
+  fprintf (stderr, "Calling resume\n");
   MHD_resume_connection (connection);
   return NULL;
 }
@@ -67,6 +68,7 @@ suspend_connection (struct MHD_Connection *connection)
 {
   pthread_t thread_id;
 
+  fprintf (stderr, "Calling suspend\n");
   MHD_suspend_connection (connection);
   int status = pthread_create (&thread_id,
                                NULL,


hooks/post-receive
-- 
GNU libmicrohttpd



reply via email to

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