commit 295a4884c7fb4c769c73e8013bd6e47803927703
parent eee0b9ad40d13311b989cfc9995df53fba960d94
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 8 Jan 2017 23:38:56 +0300
thread_main_connection_upgrade(): process data from TLS buffers
Diffstat:
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -1289,11 +1289,23 @@ thread_main_connection_upgrade (struct MHD_Connection *con)
break;
}
if (MHD_INVALID_SOCKET != max_fd)
- num_ready = MHD_SYS_select_ (max_fd + 1,
- &rs,
- &ws,
- NULL,
- NULL);
+ {
+ struct timeval* tvp;
+ struct timeval tv;
+ if (con->tls_read_ready)
+ { /* No need to wait if incoming data is already pending in TLS buffers. */
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ tvp = &tv;
+ }
+ else
+ tvp = NULL;
+ num_ready = MHD_SYS_select_ (max_fd + 1,
+ &rs,
+ &ws,
+ NULL,
+ tvp);
+ }
else
num_ready = 0;
if (num_ready < 0)
@@ -1325,12 +1337,12 @@ thread_main_connection_upgrade (struct MHD_Connection *con)
else if (0 != (daemon->options & MHD_USE_TLS))
{
/* use poll() */
- const unsigned int timeout = UINT_MAX;
while ( (MHD_CONNECTION_UPGRADE == con->state) ||
(0 != urh->out_buffer_used) )
{
struct pollfd p[2];
+ unsigned int timeout;
memset (p,
0,
@@ -1346,6 +1358,11 @@ thread_main_connection_upgrade (struct MHD_Connection *con)
if (0 != urh->in_buffer_used)
p[1].events |= POLLOUT;
+ if (con->tls_read_ready)
+ timeout = 0; /* No need to wait if incoming data is already pending in TLS buffers. */
+ else
+ timeout = UINT_MAX;
+
if ( (0 != (p[0].events | p[1].events)) &&
(MHD_sys_poll_ (p,
2,