gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 01/06: Merged MHD_tls_connection_handle_rea


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 01/06: Merged MHD_tls_connection_handle_read() into MHD_connection_handle_read()
Date: Mon, 05 Jun 2017 22:49:04 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit de669ead802049bb06f9672aa873b424b8201727
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Mon Jun 5 22:31:48 2017 +0300

    Merged MHD_tls_connection_handle_read() into MHD_connection_handle_read()
---
 src/microhttpd/connection.c       | 12 +++++++++++-
 src/microhttpd/connection_https.c | 35 +++--------------------------------
 src/microhttpd/connection_https.h | 13 +++++++++++++
 src/microhttpd/daemon.c           |  2 +-
 src/microhttpd/internal.h         |  6 ------
 5 files changed, 28 insertions(+), 40 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 1a692618..c0fb687b 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2667,6 +2667,17 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
   if ( (MHD_CONNECTION_CLOSED == connection->state) ||
        (connection->suspended) )
     return MHD_YES;
+#ifdef HTTPS_SUPPORT
+  if (MHD_TLS_CONN_NO_TLS != connection->tls_state)
+    { /* HTTPS connection. */
+      if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
+        {
+          if (!MHD_run_tls_handshake_ (connection))
+            return MHD_YES;
+        }
+    }
+#endif /* HTTPS_SUPPORT */
+
   /* make sure "read" has a reasonable number of bytes
      in buffer to use per system call (if possible) */
   if (connection->read_buffer_offset + connection->daemon->pool_increment >
@@ -3624,7 +3635,6 @@ MHD_connection_epoll_update_ (struct MHD_Connection 
*connection)
 void
 MHD_set_http_callbacks_ (struct MHD_Connection *connection)
 {
-  connection->read_handler = &MHD_connection_handle_read;
   connection->write_handler = &MHD_connection_handle_write;
   connection->recv_cls = &recv_param_adapter;
   connection->send_cls = &send_param_adapter;
diff --git a/src/microhttpd/connection_https.c 
b/src/microhttpd/connection_https.c
index 9e7c1953..c168d543 100644
--- a/src/microhttpd/connection_https.c
+++ b/src/microhttpd/connection_https.c
@@ -143,8 +143,8 @@ send_tls_adapter (struct MHD_Connection *connection,
  *         false is handshake in progress or in case
  *         of error
  */
-static bool
-run_tls_handshake (struct MHD_Connection *connection)
+bool
+MHD_run_tls_handshake_ (struct MHD_Connection *connection)
 {
   int ret;
 
@@ -181,34 +181,6 @@ run_tls_handshake (struct MHD_Connection *connection)
 
 
 /**
- * This function handles a particular SSL/TLS connection when
- * it has been determined that there is data to be read off a
- * socket. Message processing is done by message type which is
- * determined by peeking into the first message type byte of the
- * stream.
- *
- * Error message handling: all fatal level messages cause the
- * connection to be terminated.
- *
- * Application data is forwarded to the underlying daemon for
- * processing.
- *
- * @param connection the source connection
- * @return always #MHD_YES (we should continue to process the connection)
- */
-static int
-MHD_tls_connection_handle_read (struct MHD_Connection *connection)
-{
-  if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
-    {
-      if (!run_tls_handshake(connection))
-        return MHD_YES;
-    }
-  return MHD_connection_handle_read (connection);
-}
-
-
-/**
  * This function was created to handle writes to sockets when it has
  * been determined that the socket can be written to. This function
  * will forward all write requests to the underlying daemon unless
@@ -221,7 +193,7 @@ MHD_tls_connection_handle_write (struct MHD_Connection 
*connection)
 {
   if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
     {
-      if (!run_tls_handshake(connection))
+      if (!MHD_run_tls_handshake_(connection))
         return MHD_YES;
     }
   return MHD_connection_handle_write (connection);
@@ -237,7 +209,6 @@ MHD_tls_connection_handle_write (struct MHD_Connection 
*connection)
 void
 MHD_set_https_callbacks (struct MHD_Connection *connection)
 {
-  connection->read_handler = &MHD_tls_connection_handle_read;
   connection->write_handler = &MHD_tls_connection_handle_write;
   connection->recv_cls = &recv_tls_adapter;
   connection->send_cls = &send_tls_adapter;
diff --git a/src/microhttpd/connection_https.h 
b/src/microhttpd/connection_https.h
index b9686870..1c12ea9f 100644
--- a/src/microhttpd/connection_https.h
+++ b/src/microhttpd/connection_https.h
@@ -40,6 +40,19 @@ MHD_set_https_callbacks (struct MHD_Connection *connection);
 
 
 /**
+ * Give gnuTLS chance to work on the TLS handshake.
+ *
+ * @param connection connection to handshake on
+ * @return true if the handshake has completed successfully
+ *         and we should start to read/write data,
+ *         false is handshake in progress or in case
+ *         of error
+ */
+bool
+MHD_run_tls_handshake_ (struct MHD_Connection *connection);
+
+
+/**
  * Initiate shutdown of TLS layer of connection.
  *
  * @param connection to use
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 48fe6856..d54cdbf5 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1043,7 +1043,7 @@ call_handlers (struct MHD_Connection *con,
       if ( (MHD_EVENT_LOOP_INFO_READ == con->event_loop_info) &&
           read_ready)
         {
-          con->read_handler (con);
+          MHD_connection_handle_read (con);
           ret = MHD_connection_handle_idle (con);
           states_info_processed = true;
         }
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index eaed1580..90c7259f 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -931,12 +931,6 @@ struct MHD_Connection
   uint64_t current_chunk_offset;
 
   /**
-   * Handler used for processing read connection operations
-   * @sa #MHD_connection_handle_read, #MHD_tls_connection_handle_read
-   */
-  int (*read_handler) (struct MHD_Connection *connection);
-
-  /**
    * Handler used for processing write connection operations
    * @sa #MHD_connection_handle_write, #MHD_tls_connection_handle_write
    */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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