gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (1d356a1f -> 5c988da5


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (1d356a1f -> 5c988da5)
Date: Mon, 05 Jun 2017 22:49:03 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 1d356a1f MHD_connection_handle_write(): removed unused variable
     new de669ead Merged MHD_tls_connection_handle_read() into 
MHD_connection_handle_read()
     new 23733004 Merged MHD_tls_connection_handle_write() into 
MHD_connection_handle_write()
     new 460745c1 MHD_connection_handle_read(): changed return type to void as 
return value is not used Functionality is unchanged.
     new 74f0569b MHD_connection_handle_write(): changed return type to void as 
return value is not used Functionality is unchanged.
     new 37518ba4 MHD_connection_handle_read(): simplified and unified code, 
removed dead code. Functionality is unchanged.
     new 5c988da5 MHD_connection_handle_write(): simplified and unified code, 
removed dead code. Functionality is unchanged.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                         |  11 +
 src/microhttpd/connection.c       | 491 +++++++++++++++++++-------------------
 src/microhttpd/connection.h       |   8 +-
 src/microhttpd/connection_https.c |  54 +----
 src/microhttpd/connection_https.h |  13 +
 src/microhttpd/daemon.c           |   8 +-
 src/microhttpd/internal.h         |  12 -
 7 files changed, 281 insertions(+), 316 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7d44bd2b..66f77867 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Jun 05 23:34:00 MSK 2017
+       More internal refactoring:
+       merged MHD_tls_connection_handle_read/write() with non-TLS version,
+       reduced and unified number of layers for network processing (before
+       refactoring MHD_tls_connection_handle_read->MHD_connection_handle_read->
+       do_read->recv_tls_adapter->GnuTLS->recv_param_adapter - 5 MHD layers;
+       after refactoring MHD_connection_handle_read->recv_tls_adapter->GnuTLS -
+       2 MHD layers),
+       simplified and removed dead code from
+       MHD_connection_handle_read/write() without functional change. -EG
+
 Mon Jun 05 22:20:00 MSK 2017
        Internal refactoring:
        used TCP sockets directly with GnuTLS (performance improvement),
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 1a692618..e8dd0752 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2656,17 +2656,26 @@ MHD_update_last_activity_ (struct MHD_Connection 
*connection)
  * determined that there is data to be read off a socket.
  *
  * @param connection connection to handle
- * @return always #MHD_YES (we should continue to process the
- *         connection)
  */
-int
+void
 MHD_connection_handle_read (struct MHD_Connection *connection)
 {
   ssize_t bytes_read;
 
   if ( (MHD_CONNECTION_CLOSED == connection->state) ||
        (connection->suspended) )
-    return MHD_YES;
+    return;
+#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;
+        }
+    }
+#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 >
@@ -2674,7 +2683,7 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
     try_grow_read_buffer (connection);
 
   if (connection->read_buffer_size == connection->read_buffer_offset)
-    return MHD_YES; /* No space for receiving data. */
+    return; /* No space for receiving data. */
   bytes_read = connection->recv_cls (connection,
                                      &connection->read_buffer
                                      [connection->read_buffer_offset],
@@ -2683,20 +2692,20 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
   if (bytes_read < 0)
     {
       if (MHD_ERR_AGAIN_ == bytes_read)
-          return MHD_YES; /* No new data to process. */
+          return; /* No new data to process. */
       if (MHD_ERR_CONNRESET_ == bytes_read)
         {
            CONNECTION_CLOSE_ERROR (connection,
                                    (MHD_CONNECTION_INIT == connection->state) ?
                                      NULL :
                                      _("Socket is unexpectedly disconnected 
when reading request.\n"));
-           return MHD_NO;
+           return;
         }
       CONNECTION_CLOSE_ERROR (connection,
                               (MHD_CONNECTION_INIT == connection->state) ?
                                 NULL :
                                 _("Connection socket is closed due to 
unexpected error when reading request.\n"));
-      return MHD_YES;
+      return;
     }
 
   if (0 == bytes_read)
@@ -2704,55 +2713,50 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
       connection->read_closed = true;
       MHD_connection_close_ (connection,
                              MHD_REQUEST_TERMINATED_CLIENT_ABORT);
-      return MHD_YES;
+      return;
     }
   connection->read_buffer_offset += bytes_read;
   MHD_update_last_activity_ (connection);
-  while (1)
-    {
 #if DEBUG_STATES
-      MHD_DLOG (connection->daemon,
-                _("In function %s handling connection at state: %s\n"),
-                __FUNCTION__,
-                MHD_state_to_string (connection->state));
+  MHD_DLOG (connection->daemon,
+            _("In function %s handling connection at state: %s\n"),
+            __FUNCTION__,
+            MHD_state_to_string (connection->state));
 #endif
-      switch (connection->state)
+  switch (connection->state)
+    {
+    case MHD_CONNECTION_INIT:
+    case MHD_CONNECTION_URL_RECEIVED:
+    case MHD_CONNECTION_HEADER_PART_RECEIVED:
+    case MHD_CONNECTION_HEADERS_RECEIVED:
+    case MHD_CONNECTION_HEADERS_PROCESSED:
+    case MHD_CONNECTION_CONTINUE_SENDING:
+    case MHD_CONNECTION_CONTINUE_SENT:
+    case MHD_CONNECTION_BODY_RECEIVED:
+    case MHD_CONNECTION_FOOTER_PART_RECEIVED:
+      /* nothing to do but default action */
+      if (connection->read_closed)
         {
-        case MHD_CONNECTION_INIT:
-        case MHD_CONNECTION_URL_RECEIVED:
-        case MHD_CONNECTION_HEADER_PART_RECEIVED:
-        case MHD_CONNECTION_HEADERS_RECEIVED:
-        case MHD_CONNECTION_HEADERS_PROCESSED:
-        case MHD_CONNECTION_CONTINUE_SENDING:
-        case MHD_CONNECTION_CONTINUE_SENT:
-        case MHD_CONNECTION_BODY_RECEIVED:
-        case MHD_CONNECTION_FOOTER_PART_RECEIVED:
-          /* nothing to do but default action */
-          if (connection->read_closed)
-            {
-             MHD_connection_close_ (connection,
-                                     MHD_REQUEST_TERMINATED_READ_ERROR);
-              continue;
-            }
-          break;
-        case MHD_CONNECTION_CLOSED:
-          return MHD_YES;
+          MHD_connection_close_ (connection,
+                                 MHD_REQUEST_TERMINATED_READ_ERROR);
+        }
+      return;
+    case MHD_CONNECTION_CLOSED:
+      return;
 #ifdef UPGRADE_SUPPORT
-        case MHD_CONNECTION_UPGRADE:
-          EXTRA_CHECK (0);
-          break;
+    case MHD_CONNECTION_UPGRADE:
+      EXTRA_CHECK (0);
+      return;
 #endif /* UPGRADE_SUPPORT */
-        default:
-          /* shrink read buffer to how much is actually used */
-          MHD_pool_reallocate (connection->pool,
-                               connection->read_buffer,
-                               connection->read_buffer_size + 1,
-                               connection->read_buffer_offset);
-          break;
-        }
+    default:
+      /* shrink read buffer to how much is actually used */
+      MHD_pool_reallocate (connection->pool,
+                           connection->read_buffer,
+                           connection->read_buffer_size + 1,
+                           connection->read_buffer_offset);
       break;
     }
-  return MHD_YES;
+  return;
 }
 
 
@@ -2761,231 +2765,236 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
  * been determined that the socket can be written to.
  *
  * @param connection connection to handle
- * @return always #MHD_YES (we should continue to process the
- *         connection)
  */
-int
+void
 MHD_connection_handle_write (struct MHD_Connection *connection)
 {
   struct MHD_Response *response;
   ssize_t ret;
   if (connection->suspended)
-    return MHD_YES;
+    return;
+
+#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;
+        }
+    }
+#endif /* HTTPS_SUPPORT */
 
-  while (1)
-    {
 #if DEBUG_STATES
-      MHD_DLOG (connection->daemon,
-                _("In function %s handling connection at state: %s\n"),
-                __FUNCTION__,
-                MHD_state_to_string (connection->state));
+  MHD_DLOG (connection->daemon,
+            _("In function %s handling connection at state: %s\n"),
+            __FUNCTION__,
+            MHD_state_to_string (connection->state));
 #endif
-      switch (connection->state)
+  switch (connection->state)
+    {
+    case MHD_CONNECTION_INIT:
+    case MHD_CONNECTION_URL_RECEIVED:
+    case MHD_CONNECTION_HEADER_PART_RECEIVED:
+    case MHD_CONNECTION_HEADERS_RECEIVED:
+      EXTRA_CHECK (0);
+      return;
+    case MHD_CONNECTION_HEADERS_PROCESSED:
+      return;
+    case MHD_CONNECTION_CONTINUE_SENDING:
+      ret = connection->send_cls (connection,
+                                  &HTTP_100_CONTINUE
+                                  [connection->continue_message_write_offset],
+                                  MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) -
+                                  connection->continue_message_write_offset);
+      if (ret < 0)
         {
-        case MHD_CONNECTION_INIT:
-        case MHD_CONNECTION_URL_RECEIVED:
-        case MHD_CONNECTION_HEADER_PART_RECEIVED:
-        case MHD_CONNECTION_HEADERS_RECEIVED:
-          EXTRA_CHECK (0);
-          break;
-        case MHD_CONNECTION_HEADERS_PROCESSED:
-          break;
-        case MHD_CONNECTION_CONTINUE_SENDING:
-          ret = connection->send_cls (connection,
-                                      &HTTP_100_CONTINUE
-                                      
[connection->continue_message_write_offset],
-                                      MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) -
-                                      
connection->continue_message_write_offset);
-          if (ret < 0)
-            {
-              if (MHD_ERR_AGAIN_ == ret)
-                break;
+          if (MHD_ERR_AGAIN_ == ret)
+            return;
 #ifdef HAVE_MESSAGES
-              MHD_DLOG (connection->daemon,
-                        _("Failed to send data in request for %s.\n"),
-                        connection->url);
+          MHD_DLOG (connection->daemon,
+                    _("Failed to send data in request for %s.\n"),
+                    connection->url);
 #endif
-             CONNECTION_CLOSE_ERROR (connection,
-                                      NULL);
-              return MHD_YES;
-            }
+          CONNECTION_CLOSE_ERROR (connection,
+                                  NULL);
+          return;
+        }
 #if DEBUG_SEND_DATA
-          fprintf (stderr,
-                   _("Sent 100 continue response: `%.*s'\n"),
-                   (int) ret,
-                   
&HTTP_100_CONTINUE[connection->continue_message_write_offset]);
+      fprintf (stderr,
+               _("Sent 100 continue response: `%.*s'\n"),
+               (int) ret,
+               &HTTP_100_CONTINUE[connection->continue_message_write_offset]);
 #endif
-          connection->continue_message_write_offset += ret;
-          MHD_update_last_activity_ (connection);
-          break;
-        case MHD_CONNECTION_CONTINUE_SENT:
-        case MHD_CONNECTION_BODY_RECEIVED:
-        case MHD_CONNECTION_FOOTER_PART_RECEIVED:
-        case MHD_CONNECTION_FOOTERS_RECEIVED:
-          EXTRA_CHECK (0);
-          break;
-        case MHD_CONNECTION_HEADERS_SENDING:
-          ret = connection->send_cls (connection,
-                                      &connection->write_buffer
-                                      [connection->write_buffer_send_offset],
-                                      connection->write_buffer_append_offset -
-                                        connection->write_buffer_send_offset);
-          if (ret < 0)
+      connection->continue_message_write_offset += ret;
+      MHD_update_last_activity_ (connection);
+      return;
+    case MHD_CONNECTION_CONTINUE_SENT:
+    case MHD_CONNECTION_BODY_RECEIVED:
+    case MHD_CONNECTION_FOOTER_PART_RECEIVED:
+    case MHD_CONNECTION_FOOTERS_RECEIVED:
+      EXTRA_CHECK (0);
+      return;
+    case MHD_CONNECTION_HEADERS_SENDING:
+      ret = connection->send_cls (connection,
+                                  &connection->write_buffer
+                                  [connection->write_buffer_send_offset],
+                                  connection->write_buffer_append_offset -
+                                    connection->write_buffer_send_offset);
+      if (ret < 0)
+        {
+          if (MHD_ERR_AGAIN_ == ret)
+            return;
+          CONNECTION_CLOSE_ERROR (connection,
+                                  _("Connection was closed while sending 
response headers.\n"));
+          return;
+        }
+      connection->write_buffer_send_offset += ret;
+      MHD_update_last_activity_ (connection);
+      if (MHD_CONNECTION_HEADERS_SENDING != connection->state)
+        return;
+      check_write_done (connection,
+                        MHD_CONNECTION_HEADERS_SENT);
+      return;
+    case MHD_CONNECTION_HEADERS_SENT:
+      return;
+    case MHD_CONNECTION_NORMAL_BODY_READY:
+      response = connection->response;
+      if (connection->response_write_position <
+          connection->response->total_size)
+        {
+          uint64_t data_write_offset;
+
+          if (NULL != response->crc)
+            MHD_mutex_lock_chk_ (&response->mutex);
+          if (MHD_YES != try_ready_normal_body (connection))
             {
-              if (MHD_ERR_AGAIN_ == ret)
-                break;
-              CONNECTION_CLOSE_ERROR (connection,
-                                      _("Connection was closed while sending 
response headers.\n"));
-              return MHD_YES;
+              /* mutex was already unlocked by try_ready_normal_body */
+              return;
             }
-          connection->write_buffer_send_offset += ret;
-          MHD_update_last_activity_ (connection);
-         if (MHD_CONNECTION_HEADERS_SENDING != connection->state)
-            break;
-          check_write_done (connection,
-                            MHD_CONNECTION_HEADERS_SENT);
-          break;
-        case MHD_CONNECTION_HEADERS_SENT:
-          break;
-        case MHD_CONNECTION_NORMAL_BODY_READY:
-          response = connection->response;
-          if (connection->response_write_position <
-              connection->response->total_size)
-          {
-            uint64_t data_write_offset;
-
-            if (NULL != response->crc)
-              MHD_mutex_lock_chk_ (&response->mutex);
-            if (MHD_YES != try_ready_normal_body (connection))
-              {
-                /* mutex was already unlocked by try_ready_normal_body */
-                break;
-              }
 #ifdef __linux__
-            if (MHD_resp_sender_sendfile == connection->resp_sender)
-              {
-                ret = sendfile_adapter (connection);
-              }
-            else
+          if (MHD_resp_sender_sendfile == connection->resp_sender)
+            {
+              ret = sendfile_adapter (connection);
+            }
+          else
 #else  /* ! __linux__ */
-            if (1)
+          if (1)
 #endif /* ! __linux__ */
-              {
-                data_write_offset = connection->response_write_position
-                                    - response->data_start;
-                if (data_write_offset > (uint64_t)SIZE_MAX)
-                  MHD_PANIC (_("Data offset exceeds limit"));
-                ret = connection->send_cls (connection,
-                                            &response->data
-                                            [(size_t)data_write_offset],
-                                            response->data_size -
-                                            (size_t)data_write_offset);
+            {
+              data_write_offset = connection->response_write_position
+                                  - response->data_start;
+              if (data_write_offset > (uint64_t)SIZE_MAX)
+                MHD_PANIC (_("Data offset exceeds limit"));
+              ret = connection->send_cls (connection,
+                                          &response->data
+                                          [(size_t)data_write_offset],
+                                          response->data_size -
+                                          (size_t)data_write_offset);
 #if DEBUG_SEND_DATA
-                if (ret > 0)
-                  fprintf (stderr,
-                           _("Sent %d-byte DATA response: `%.*s'\n"),
-                           (int) ret,
-                           (int) ret,
-                           &response->data[connection->response_write_position 
-
-                                           response->data_start]);
-#endif
-              }
-            if (NULL != response->crc)
-              MHD_mutex_unlock_chk_ (&response->mutex);
-            if (ret < 0)
-              {
-                if (MHD_ERR_AGAIN_ == ret)
-                  return MHD_YES;
-#ifdef HAVE_MESSAGES
-                MHD_DLOG (connection->daemon,
-                          _("Failed to send data in request for `%s'.\n"),
-                          connection->url);
+              if (ret > 0)
+                fprintf (stderr,
+                         _("Sent %d-byte DATA response: `%.*s'\n"),
+                         (int) ret,
+                         (int) ret,
+                         &response->data[connection->response_write_position -
+                                         response->data_start]);
 #endif
-                CONNECTION_CLOSE_ERROR (connection,
-                                        NULL);
-                return MHD_YES;
-              }
-            connection->response_write_position += ret;
-            MHD_update_last_activity_ (connection);
-          }
-          if (connection->response_write_position ==
-              connection->response->total_size)
-            connection->state = MHD_CONNECTION_FOOTERS_SENT; /* have no 
footers */
-          break;
-        case MHD_CONNECTION_NORMAL_BODY_UNREADY:
-          EXTRA_CHECK (0);
-          break;
-        case MHD_CONNECTION_CHUNKED_BODY_READY:
-          ret = connection->send_cls (connection,
-                                      &connection->write_buffer
-                                      [connection->write_buffer_send_offset],
-                                      connection->write_buffer_append_offset -
-                                        connection->write_buffer_send_offset);
-          if (ret < 0)
-            {
-              if (MHD_ERR_AGAIN_ == ret)
-                break;
-              CONNECTION_CLOSE_ERROR (connection,
-                                      _("Connection was closed while sending 
response body.\n"));
-              return MHD_YES;
             }
-          connection->write_buffer_send_offset += ret;
-          MHD_update_last_activity_ (connection);
-         if (MHD_CONNECTION_CHUNKED_BODY_READY != connection->state)
-            break;
-          check_write_done (connection,
-                            (connection->response->total_size ==
-                             connection->response_write_position) ?
-                            MHD_CONNECTION_BODY_SENT :
-                            MHD_CONNECTION_CHUNKED_BODY_UNREADY);
-          break;
-        case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
-        case MHD_CONNECTION_BODY_SENT:
-          EXTRA_CHECK (0);
-          break;
-        case MHD_CONNECTION_FOOTERS_SENDING:
-          ret = connection->send_cls (connection,
-                                      &connection->write_buffer
-                                      [connection->write_buffer_send_offset],
-                                      connection->write_buffer_append_offset -
-                                        connection->write_buffer_send_offset);
+          if (NULL != response->crc)
+            MHD_mutex_unlock_chk_ (&response->mutex);
           if (ret < 0)
             {
               if (MHD_ERR_AGAIN_ == ret)
-                break;
+                return;
+#ifdef HAVE_MESSAGES
+              MHD_DLOG (connection->daemon,
+                        _("Failed to send data in request for `%s'.\n"),
+                        connection->url);
+#endif
               CONNECTION_CLOSE_ERROR (connection,
-                                      _("Connection was closed while sending 
response body.\n"));
-              return MHD_YES;
+                                      NULL);
+              return;
             }
-          connection->write_buffer_send_offset += ret;
+          connection->response_write_position += ret;
           MHD_update_last_activity_ (connection);
-         if (MHD_CONNECTION_FOOTERS_SENDING != connection->state)
-           break;
-          check_write_done (connection,
-                            MHD_CONNECTION_FOOTERS_SENT);
-          break;
-        case MHD_CONNECTION_FOOTERS_SENT:
-          EXTRA_CHECK (0);
-          break;
-        case MHD_CONNECTION_CLOSED:
-          return MHD_YES;
-        case MHD_CONNECTION_IN_CLEANUP:
-          EXTRA_CHECK (0);
-          break;
+        }
+      if (connection->response_write_position ==
+          connection->response->total_size)
+        connection->state = MHD_CONNECTION_FOOTERS_SENT; /* have no footers */
+      return;
+    case MHD_CONNECTION_NORMAL_BODY_UNREADY:
+      EXTRA_CHECK (0);
+      return;
+    case MHD_CONNECTION_CHUNKED_BODY_READY:
+      ret = connection->send_cls (connection,
+                                  &connection->write_buffer
+                                  [connection->write_buffer_send_offset],
+                                  connection->write_buffer_append_offset -
+                                    connection->write_buffer_send_offset);
+      if (ret < 0)
+        {
+          if (MHD_ERR_AGAIN_ == ret)
+            return;
+          CONNECTION_CLOSE_ERROR (connection,
+                                  _("Connection was closed while sending 
response body.\n"));
+          return;
+        }
+      connection->write_buffer_send_offset += ret;
+      MHD_update_last_activity_ (connection);
+      if (MHD_CONNECTION_CHUNKED_BODY_READY != connection->state)
+        return;
+      check_write_done (connection,
+                        (connection->response->total_size ==
+                         connection->response_write_position) ?
+                        MHD_CONNECTION_BODY_SENT :
+                        MHD_CONNECTION_CHUNKED_BODY_UNREADY);
+      return;
+    case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
+    case MHD_CONNECTION_BODY_SENT:
+      EXTRA_CHECK (0);
+      return;
+    case MHD_CONNECTION_FOOTERS_SENDING:
+      ret = connection->send_cls (connection,
+                                  &connection->write_buffer
+                                  [connection->write_buffer_send_offset],
+                                  connection->write_buffer_append_offset -
+                                    connection->write_buffer_send_offset);
+      if (ret < 0)
+        {
+          if (MHD_ERR_AGAIN_ == ret)
+            return;
+          CONNECTION_CLOSE_ERROR (connection,
+                                  _("Connection was closed while sending 
response body.\n"));
+          return;
+        }
+      connection->write_buffer_send_offset += ret;
+      MHD_update_last_activity_ (connection);
+      if (MHD_CONNECTION_FOOTERS_SENDING != connection->state)
+        return;
+      check_write_done (connection,
+                        MHD_CONNECTION_FOOTERS_SENT);
+      return;
+    case MHD_CONNECTION_FOOTERS_SENT:
+      EXTRA_CHECK (0);
+      return;
+    case MHD_CONNECTION_CLOSED:
+      return;
+    case MHD_CONNECTION_IN_CLEANUP:
+      EXTRA_CHECK (0);
+      return;
 #ifdef UPGRADE_SUPPORT
-        case MHD_CONNECTION_UPGRADE:
-          EXTRA_CHECK (0);
-          break;
+    case MHD_CONNECTION_UPGRADE:
+      EXTRA_CHECK (0);
+      return;
 #endif /* UPGRADE_SUPPORT */
-        default:
-          EXTRA_CHECK (0);
-         CONNECTION_CLOSE_ERROR (connection,
-                                  _("Internal error\n"));
-          return MHD_YES;
-        }
+    default:
+      EXTRA_CHECK (0);
+      CONNECTION_CLOSE_ERROR (connection,
+                              _("Internal error\n"));
       break;
     }
-  return MHD_YES;
+  return;
 }
 
 
@@ -3624,8 +3633,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.h b/src/microhttpd/connection.h
index 147d7343..f5316887 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -77,10 +77,8 @@ MHD_set_http_callbacks_ (struct MHD_Connection *connection);
  * call this function to handle reads.
  *
  * @param connection connection to handle
- * @return always MHD_YES (we should continue to process the
- *         connection)
  */
-int
+void
 MHD_connection_handle_read (struct MHD_Connection *connection);
 
 
@@ -91,10 +89,8 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection);
  * call this function
  *
  * @param connection connection to handle
- * @return always MHD_YES (we should continue to process the
- *         connection)
  */
-int
+void
 MHD_connection_handle_write (struct MHD_Connection *connection);
 
 
diff --git a/src/microhttpd/connection_https.c 
b/src/microhttpd/connection_https.c
index 9e7c1953..19d6db59 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,54 +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
- * the connection has been marked for closing.
- *
- * @return always #MHD_YES (we should continue to process the connection)
- */
-static int
-MHD_tls_connection_handle_write (struct MHD_Connection *connection)
-{
-  if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
-    {
-      if (!run_tls_handshake(connection))
-        return MHD_YES;
-    }
-  return MHD_connection_handle_write (connection);
-}
-
-
-/**
  * Set connection callback function to be used through out
  * the processing of this secure connection.
  *
@@ -237,8 +189,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..cb7064a4 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;
         }
@@ -1052,7 +1052,7 @@ call_handlers (struct MHD_Connection *con,
       if ( (MHD_EVENT_LOOP_INFO_WRITE == con->event_loop_info) &&
           write_ready)
         {
-          con->write_handler (con);
+          MHD_connection_handle_write (con);
           ret = MHD_connection_handle_idle (con);
           states_info_processed = true;
         }
@@ -1083,7 +1083,7 @@ call_handlers (struct MHD_Connection *con,
     {
       if (MHD_CONNECTION_HEADERS_SENDING == con->state)
         {
-          con->write_handler (con);
+          MHD_connection_handle_write (con);
           /* Always call 'MHD_connection_handle_idle()' after each read/write. 
*/
           ret = MHD_connection_handle_idle (con);
         }
@@ -1093,7 +1093,7 @@ call_handlers (struct MHD_Connection *con,
       if ((MHD_CONNECTION_NORMAL_BODY_READY == con->state) ||
           (MHD_CONNECTION_CHUNKED_BODY_READY == con->state))
         {
-          con->write_handler (con);
+          MHD_connection_handle_write (con);
           ret = MHD_connection_handle_idle (con);
         }
     }
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index eaed1580..7a47651e 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -931,18 +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
-   */
-  int (*write_handler) (struct MHD_Connection *connection);
-
-  /**
    * Function used for reading HTTP request stream.
    */
   ReceiveCallback recv_cls;

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



reply via email to

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