gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 01/02: Reworking early close flags


From: gnunet
Subject: [libmicrohttpd] 01/02: Reworking early close flags
Date: Sun, 21 Nov 2021 20:14:36 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit a761eb67b6e996003ed34bce3f35b4d9d437ad86
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Nov 13 13:44:23 2021 +0300

    Reworking early close flags
    
    'early_response' renamed to 'discard_request'.
    Changed the way how flags are checked.
---
 src/microhttpd/connection.c | 44 ++++++++++++++++++++++++--------------------
 src/microhttpd/internal.h   |  2 +-
 2 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index a068bfe4..390181ec 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -924,7 +924,7 @@ connection_close_error (struct MHD_Connection *connection,
                         const char *emsg)
 {
   connection->stop_with_error = true;
-  connection->early_response = true;
+  connection->discard_request = true;
 #ifdef HAVE_MESSAGES
   if (NULL != emsg)
     MHD_DLOG (connection->daemon,
@@ -1300,8 +1300,8 @@ keepalive_possible (struct MHD_Connection *connection)
   }
 #endif /* UPGRADE_SUPPORT */
 
-  mhd_assert ( (! c->stop_with_error) || (c->early_response));
-  if ((c->read_closed) || (c->early_response))
+  mhd_assert ( (! c->stop_with_error) || (c->discard_request));
+  if ((c->read_closed) || (c->discard_request))
     return MHD_CONN_MUST_CLOSE;
 
   if (0 != (r->flags & MHD_RF_HTTP_1_0_COMPATIBLE_STRICT))
@@ -2265,7 +2265,7 @@ transmit_error_response_len (struct MHD_Connection 
*connection,
     return;
   }
   connection->stop_with_error = true;
-  connection->early_response = true;
+  connection->discard_request = true;
 #ifdef HAVE_MESSAGES
   MHD_DLOG (connection->daemon,
             _ ("Error processing request (HTTP response code is %u ('%s')). " \
@@ -2436,7 +2436,7 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
                                           REQUEST_TOO_BIG);
         continue;
       }
-      if (! connection->early_response)
+      if (! connection->discard_request)
         connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
       else
         connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK;
@@ -2476,7 +2476,7 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
         }
       }
       if ( (connection->read_buffer_offset < connection->read_buffer_size) &&
-           (! connection->early_response) )
+           (! connection->discard_request) )
         connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
       else
         connection->event_loop_info = MHD_EVENT_LOOP_INFO_BLOCK;
@@ -2485,7 +2485,7 @@ MHD_connection_update_event_loop_info (struct 
MHD_Connection *connection)
     case MHD_CONNECTION_FOOTER_PART_RECEIVED:
       /* while reading footers, we always grow the
          read buffer if needed, no size-check required */
-      if (connection->stop_with_error)
+      if (connection->read_closed)
       {
         CONNECTION_CLOSE_ERROR (connection,
                                 NULL);
@@ -3694,8 +3694,9 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
   case MHD_CONNECTION_BODY_RECEIVED:
   case MHD_CONNECTION_FOOTER_PART_RECEIVED:
     /* nothing to do but default action */
-    if ((connection->read_closed) || (connection->stop_with_error))
+    if (connection->read_closed)
     {
+      /* TODO: check whether this really needed */
       MHD_connection_close_ (connection,
                              MHD_REQUEST_TERMINATED_READ_ERROR);
     }
@@ -4176,7 +4177,7 @@ connection_reset (struct MHD_Connection *connection,
     /* Reset connection to process the next request */
     size_t new_read_buf_size;
     mhd_assert (! c->stop_with_error);
-    mhd_assert (! c->early_response);
+    mhd_assert (! c->discard_request);
 
     if ( (NULL != d->notify_completed) &&
          (c->client_aware) )
@@ -4299,7 +4300,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
         continue;
       }
       /* NULL means we didn't get a full line yet */
-      if (connection->stop_with_error)
+      if (connection->discard_request)
       {
         mhd_assert (MHD_CONNECTION_INIT != connection->state);
         continue;
@@ -4314,7 +4315,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       {
         if (MHD_CONNECTION_URL_RECEIVED != connection->state)
           continue;
-        if (connection->stop_with_error)
+        if (connection->read_closed)
         {
           CONNECTION_CLOSE_ERROR (connection,
                                   NULL);
@@ -4346,7 +4347,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       {
         if (connection->state != MHD_CONNECTION_HEADER_PART_RECEIVED)
           continue;
-        if (connection->stop_with_error)
+        if (connection->read_closed)
         {
           CONNECTION_CLOSE_ERROR (connection,
                                   NULL);
@@ -4393,7 +4394,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
         /* we refused (no upload allowed!) */
         connection->remaining_upload_size = 0;
         /* force close, in case client still tries to upload... */
-        connection->early_response = true;
+        connection->discard_request = true;
       }
       connection->state = (0 == connection->remaining_upload_size)
                           ? MHD_CONNECTION_FULL_REQ_RECEIVED
@@ -4413,16 +4414,19 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       if (0 != connection->read_buffer_offset)
       {
         process_request_body (connection);           /* loop call */
-        if (connection->stop_with_error)
+        if (connection->discard_request)
+        {
+          mhd_assert (MHD_CONNECTION_CONTINUE_SENT != connection->state);
           continue;
+        }
       }
       if ( (0 == connection->remaining_upload_size) ||
            ( (MHD_SIZE_UNKNOWN == connection->remaining_upload_size) &&
              (0 == connection->read_buffer_offset) &&
-             (connection->early_response) ) )
+             (connection->discard_request) ) )
       {
         if ( (connection->have_chunked_upload) &&
-             (! connection->early_response) )
+             (! connection->discard_request) )
           connection->state = MHD_CONNECTION_BODY_RECEIVED;
         else
           connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
@@ -4438,7 +4442,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       {
         if (connection->state != MHD_CONNECTION_BODY_RECEIVED)
           continue;
-        if (connection->stop_with_error)
+        if (connection->read_closed)
         {
           CONNECTION_CLOSE_ERROR (connection,
                                   NULL);
@@ -4472,7 +4476,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       {
         if (connection->state != MHD_CONNECTION_FOOTER_PART_RECEIVED)
           continue;
-        if (connection->stop_with_error)
+        if (connection->read_closed)
         {
           CONNECTION_CLOSE_ERROR (connection,
                                   NULL);
@@ -4661,7 +4665,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       connection_reset (connection,
                         MHD_CONN_USE_KEEPALIVE == connection->keepalive &&
                         ! connection->read_closed &&
-                        ! connection->early_response);
+                        ! connection->discard_request);
       continue;
     case MHD_CONNECTION_CLOSED:
       cleanup_connection (connection);
@@ -5096,7 +5100,7 @@ MHD_queue_response (struct MHD_Connection *connection,
   {
     /* response was queued "early", refuse to read body / footers or
        further requests! */
-    connection->early_response = true;
+    connection->discard_request = true;
     connection->state = MHD_CONNECTION_START_REPLY;
     connection->remaining_upload_size = 0;
   }
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index b2bd0f6c..da981c80 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1230,7 +1230,7 @@ struct MHD_Connection
    * request is incompletely read and it is unclear where is the initial
    * byte of the next request.
    */
-  bool early_response;
+  bool discard_request;
 
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   /**

-- 
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]