gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 05/29: Request body processing: removed impossible code


From: gnunet
Subject: [libmicrohttpd] 05/29: Request body processing: removed impossible code paths
Date: Tue, 20 Jun 2023 22:24:18 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 69da856991eeb4fabf519552ff4c55708cb56d0a
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Fri Feb 24 20:26:35 2023 +0300

    Request body processing: removed impossible code paths
    
    Some code paths are impossible. Removed and replaced with asserts.
    Also redundant checks are removed.
---
 src/microhttpd/connection.c | 36 ++++++++++--------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 3fad127d..756aba4f 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3402,24 +3402,7 @@ process_request_body (struct MHD_Connection *connection)
 
   connection->rq.some_payload_processed = false;
 
-  if (NULL != connection->rp.response)
-  {
-    /* TODO: discard all read buffer as early response
-     * means that connection have to be closed. */
-    /* already queued a response, discard remaining upload
-       (but not more, there might be another request after it) */
-    size_t purge;
-
-    purge = (size_t) MHD_MIN (connection->rq.remaining_upload_size,
-                              (uint64_t) connection->read_buffer_offset);
-    connection->rq.remaining_upload_size -= purge;
-    if (connection->read_buffer_offset > purge)
-      memmove (connection->read_buffer,
-               &connection->read_buffer[purge],
-               connection->read_buffer_offset - purge);
-    connection->read_buffer_offset -= purge;
-    return;
-  }
+  mhd_assert (NULL == connection->rp.response);
 
   buffer_head = connection->read_buffer;
   available = connection->read_buffer_offset;
@@ -5704,24 +5687,25 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
       }
       break;
     case MHD_CONNECTION_BODY_RECEIVING:
+      mhd_assert (0 != connection->rq.remaining_upload_size);
+      mhd_assert (! connection->discard_request);
+      mhd_assert (NULL == connection->rp.response);
       if (0 != connection->read_buffer_offset)
       {
         process_request_body (connection);           /* loop call */
         if (MHD_CONNECTION_BODY_RECEIVING != connection->state)
           continue;
       }
-      if ( (0 == connection->rq.remaining_upload_size) ||
-           ( (MHD_SIZE_UNKNOWN == connection->rq.remaining_upload_size) &&
-             (0 == connection->read_buffer_offset) &&
-             (connection->discard_request) ) )
+      /* Modify here when response queue during data processing
+         will be supported */
+      mhd_assert (! connection->discard_request);
+      mhd_assert (NULL == connection->rp.response);
+      if (0 == connection->rq.remaining_upload_size)
       {
-        if ( (connection->rq.have_chunked_upload) &&
-             (! connection->discard_request) )
+        if (connection->rq.have_chunked_upload)
           connection->state = MHD_CONNECTION_BODY_RECEIVED;
         else
           connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED;
-        if (connection->suspended)
-          break;
         continue;
       }
       break;

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