gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 10/10: connection_maximize_write_buffer(): don't try to


From: gnunet
Subject: [libmicrohttpd] 10/10: connection_maximize_write_buffer(): don't try to grow if no space is available
Date: Wed, 29 Sep 2021 19:52:52 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit d7cac578837064baabe1284072be1ceb34dae23e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Sep 29 16:15:35 2021 +0300

    connection_maximize_write_buffer(): don't try to grow if no space is 
available
---
 src/microhttpd/connection.c | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 3ca4d4a3..3e6a4ba0 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1523,27 +1523,32 @@ connection_maximize_write_buffer (struct MHD_Connection 
*connection)
   struct MemoryPool *const pool = connection->pool;
   void *new_buf;
   size_t new_size;
+  size_t free_size;
 
   mhd_assert ((NULL != c->write_buffer) || (0 == c->write_buffer_size));
   mhd_assert (c->write_buffer_append_offset >= c->write_buffer_send_offset);
   mhd_assert (c->write_buffer_size >= c->write_buffer_append_offset);
 
-  new_size = c->write_buffer_size + MHD_pool_get_free (pool);
-  new_buf = MHD_pool_reallocate (pool,
-                                 c->write_buffer,
-                                 c->write_buffer_size,
-                                 new_size);
-  /* Buffer position must not be moved.
-   * Position could be moved only if buffer was allocated 'from_end',
-   * which cannot happen. */
-  mhd_assert ((c->write_buffer == new_buf) || (NULL == c->write_buffer));
-  c->write_buffer = new_buf;
-  c->write_buffer_size = new_size;
-  if (c->write_buffer_send_offset == c->write_buffer_append_offset)
+  free_size = MHD_pool_get_free (pool);
+  if (0 != free_size)
   {
-    /* All data have been sent, reset offsets to zero. */
-    c->write_buffer_send_offset = 0;
-    c->write_buffer_append_offset = 0;
+    new_size = c->write_buffer_size + free_size;
+    new_buf = MHD_pool_reallocate (pool,
+                                   c->write_buffer,
+                                   c->write_buffer_size,
+                                   new_size);
+    /* Buffer position must not be moved.
+     * Position could be moved only if buffer was allocated 'from_end',
+     * which cannot happen. */
+    mhd_assert ((c->write_buffer == new_buf) || (NULL == c->write_buffer));
+    c->write_buffer = new_buf;
+    c->write_buffer_size = new_size;
+    if (c->write_buffer_send_offset == c->write_buffer_append_offset)
+    {
+      /* All data have been sent, reset offsets to zero. */
+      c->write_buffer_send_offset = 0;
+      c->write_buffer_append_offset = 0;
+    }
   }
 
   return c->write_buffer_size - c->write_buffer_append_offset;

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