gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 18/29: Added proper connection's buffers pre-initialisai


From: gnunet
Subject: [libmicrohttpd] 18/29: Added proper connection's buffers pre-initialisaion
Date: Tue, 20 Jun 2023 22:24:31 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 2e996ee5c2cbf9cb36b12c1152d81b1477607b2c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Jun 14 10:49:10 2023 +0300

    Added proper connection's buffers pre-initialisaion
---
 src/microhttpd/connection.c | 41 +++++++++++++++++++++++++++++++++++++++++
 src/microhttpd/connection.h |  8 ++++++++
 src/microhttpd/daemon.c     |  3 +++
 3 files changed, 52 insertions(+)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index be9c5525..4716eb0f 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -6068,6 +6068,47 @@ cleanup_connection (struct MHD_Connection *connection)
 }
 
 
+/**
+ * Set initial internal states for the connection to start reading and
+ * processing incoming data.
+ * @param c the connection to process
+ */
+void
+MHD_connection_set_initial_state_ (struct MHD_Connection *c)
+{
+  size_t read_buf_size;
+
+#ifdef HTTPS_SUPPORT
+  mhd_assert ( (0 == (c->daemon->options & MHD_USE_TLS)) || \
+               (MHD_TLS_CONN_INIT == c->tls_state) );
+  mhd_assert ( (0 != (c->daemon->options & MHD_USE_TLS)) || \
+               (MHD_TLS_CONN_NO_TLS == c->tls_state) );
+#endif /* HTTPS_SUPPORT */
+  mhd_assert (MHD_CONNECTION_INIT == c->state);
+
+  c->keepalive = MHD_CONN_KEEPALIVE_UNKOWN;
+  c->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
+
+  memset (&c->rq, 0, sizeof(c->rq));
+  memset (&c->rp, 0, sizeof(c->rp));
+
+  c->write_buffer = NULL;
+  c->write_buffer_size = 0;
+  c->write_buffer_send_offset = 0;
+  c->write_buffer_append_offset = 0;
+
+  c->continue_message_write_offset = 0;
+
+  c->read_buffer_offset = 0;
+  read_buf_size = c->daemon->pool_size / 2;
+  c->read_buffer
+    = MHD_pool_allocate (c->pool,
+                         read_buf_size,
+                         false);
+  c->read_buffer_size = read_buf_size;
+}
+
+
 /**
  * Reset connection after request-reply cycle.
  * @param connection the connection to process
diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h
index 693e26fc..67a251a8 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -86,6 +86,14 @@ void
 MHD_set_http_callbacks_ (struct MHD_Connection *connection);
 
 
+/**
+ * Set initial internal states for the connection to start reading and
+ * processing incoming data.
+ * @param c the connection to process
+ */
+void
+MHD_connection_set_initial_state_ (struct MHD_Connection *c);
+
 /**
  * This function handles a particular connection when it has been
  * determined that there is data to be read off a socket. All
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f9ffb388..f310e1c7 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2801,6 +2801,9 @@ new_connection_process_ (struct MHD_Daemon *daemon,
                      connection);
       }
       MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
+
+      MHD_connection_set_initial_state_ (connection);
+
       if (NULL != daemon->notify_connection)
         daemon->notify_connection (daemon->notify_connection_cls,
                                    connection,

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