gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. b3


From: gitolite
Subject: [GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. b357bbaa6fcedfa43af7e2549535112468bde41b
Date: Tue, 15 Nov 2016 17:14:38 +0100 (CET)

The branch, master has been updated
       via  b357bbaa6fcedfa43af7e2549535112468bde41b (commit)
       via  03e7c4f4d5a90eefa8d3c77575173b8948ba14c4 (commit)
      from  bc83858f65b0f6465ded232ce551b149beaa12d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b357bbaa6fcedfa43af7e2549535112468bde41b
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Tue Nov 15 19:06:43 2016 +0300

    Fixed forwarding data of TLS "upgraded" connections for chunks sizes larger 
than forward buffer

commit 03e7c4f4d5a90eefa8d3c77575173b8948ba14c4
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Tue Nov 15 19:00:39 2016 +0300

    Fixed English in comments

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 |  4 ++++
 src/microhttpd/daemon.c   | 37 ++++++++++++++++++++++++++++++++++---
 src/microhttpd/internal.h |  6 ++++++
 3 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c1773e5..7d3bdd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Nov 15 19:08:43 MSK 2016
+       Fixed forwarding "upgraded" TLS connections for
+       chunks sizes larger than buffer size. -EG
+
 Mon Nov 14 22:18:30 MSK 2016
        Fixed unintentional usage of SO_REUSEADDR on W32.
        Added support for SO_EXCLBIND on Solaris.
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index ee43900..55604eb 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1012,10 +1012,12 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
       urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY;
       /* Reading from remote client is not required anymore. */
       urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY;
+      urh->connection->tls_read_ready = 0;
     }
 
   /* handle reading from TLS client and writing to application */
-  if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) &&
+  if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) ||
+         (urh->connection->tls_read_ready) ) &&
        (urh->in_buffer_used < urh->in_buffer_size) )
     {
       ssize_t res;
@@ -1025,6 +1027,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
       if (buf_size > SSIZE_MAX)
         buf_size = SSIZE_MAX;
 
+      urh->connection->tls_read_ready = 0;
       res = gnutls_record_recv (urh->connection->tls_session,
                                 &urh->in_buffer[urh->in_buffer_used],
                                 buf_size);
@@ -1036,6 +1039,11 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
       else if (res > 0)
         {
           urh->in_buffer_used += res;
+          if (0 < gnutls_record_check_pending (urh->connection->tls_session))
+            {
+              urh->connection->tls_read_ready = !0;
+              urh->connection->daemon->has_tls_recv_ready = !0;
+            }
         }
       else if (0 >= res)
         {
@@ -1083,6 +1091,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
               urh->in_buffer_used = 0;
               urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY;
               urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY;
+              urh->connection->tls_read_ready = 0;
             }
         }
       else
@@ -1125,7 +1134,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
         {
           if (MHD_NO != urh->was_closed)
             {
-              /* Connection was shuted down or all data received and
+              /* Connection was shut down or all data received and
                * application will not forward any more data. */
               urh->out_buffer_size = 0;
               urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY;
@@ -2872,7 +2881,7 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
     }
 
 #ifdef HTTPS_SUPPORT
-  if (0 != daemon->num_tls_read_ready)
+  if (0 != daemon->num_tls_read_ready || daemon->has_tls_recv_ready)
     {
       /* if there is any TLS connection with data ready for
         reading, we must not block in the event loop */
@@ -2974,6 +2983,14 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
                   read_fd_set)) )
     MHD_itc_clear_ (daemon->itc);
 
+#ifdef HTTPS_SUPPORT
+    /* Reset TLS read-ready.
+     * New value will be set by read handlers. */
+    if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+         (0 != (daemon->options & MHD_USE_TLS)) )
+      daemon->has_tls_recv_ready = 0;
+#endif /* HTTPS_SUPPORT */
+
   /* Resuming external connections when using an extern mainloop  */
   if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & mask))
     resume_suspended_connections (daemon);
@@ -3363,6 +3380,14 @@ MHD_poll_all (struct MHD_Daemon *daemon,
          (0 != (p[poll_itc_idx].revents & POLLIN)) )
       MHD_itc_clear_ (daemon->itc);
 
+#ifdef HTTPS_SUPPORT
+    /* Reset TLS read-ready.
+     * New value will be set by read handlers. */
+    if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+         (0 != (daemon->options & MHD_USE_TLS)) )
+      daemon->has_tls_recv_ready = 0;
+#endif /* HTTPS_SUPPORT */
+
     /* handle shutdown */
     if (MHD_YES == daemon->shutdown)
       {
@@ -3759,6 +3784,12 @@ MHD_epoll (struct MHD_Daemon *daemon,
 #endif
          return MHD_NO;
        }
+#ifdef HTTPS_SUPPORT
+    /* Reset TLS read-ready.
+     * New value will be set by read handlers. */
+    if ( 0 != (daemon->options & MHD_USE_TLS) )
+      daemon->has_tls_recv_ready = 0;
+#endif /* HTTPS_SUPPORT */
       for (i=0;i<(unsigned int) num_events;i++)
        {
           /* First, check for the values of `ptr` that would indicate
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 64f3c65..ae63e79 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1553,6 +1553,12 @@ struct MHD_Daemon
    */
   unsigned int num_tls_read_ready;
 
+  /**
+   * Indicate that some TLS connection(s) have received data pending in
+   * TLS buffers.
+   */
+  bool has_tls_recv_ready;
+
 #endif /* HTTPS_SUPPORT */
 
 #ifdef DAUTH_SUPPORT


hooks/post-receive
-- 
GNU libmicrohttpd



reply via email to

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