diff options
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r-- | src/daemon/daemon.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 7b902322..0668245f 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -386,6 +386,7 @@ recv_tls_adapter (struct MHD_Connection *connection, void *other, size_t i) | |||
386 | { | 386 | { |
387 | int res; | 387 | int res; |
388 | 388 | ||
389 | connection->tls_read_ready = MHD_NO; | ||
389 | res = gnutls_record_recv (connection->tls_session, other, i); | 390 | res = gnutls_record_recv (connection->tls_session, other, i); |
390 | if ( (GNUTLS_E_AGAIN == res) || | 391 | if ( (GNUTLS_E_AGAIN == res) || |
391 | (GNUTLS_E_INTERRUPTED == res) ) | 392 | (GNUTLS_E_INTERRUPTED == res) ) |
@@ -401,6 +402,8 @@ recv_tls_adapter (struct MHD_Connection *connection, void *other, size_t i) | |||
401 | errno = EPIPE; | 402 | errno = EPIPE; |
402 | return res; | 403 | return res; |
403 | } | 404 | } |
405 | if (res == i) | ||
406 | connection->tls_read_ready = MHD_YES; | ||
404 | return res; | 407 | return res; |
405 | } | 408 | } |
406 | 409 | ||
@@ -606,7 +609,15 @@ MHD_handle_connection (void *data) | |||
606 | tv.tv_usec = 0; | 609 | tv.tv_usec = 0; |
607 | tvp = &tv; | 610 | tvp = &tv; |
608 | } | 611 | } |
609 | 612 | #if HTTPS_SUPPORT | |
613 | if (MHD_YES == con->tls_read_ready) | ||
614 | { | ||
615 | /* do not block (more data may be inside of TLS buffers waiting for us) */ | ||
616 | tv.tv_sec = 0; | ||
617 | tv.tv_usec = 0; | ||
618 | tvp = &tv; | ||
619 | } | ||
620 | #endif | ||
610 | if (0 == (con->daemon->options & MHD_USE_POLL)) | 621 | if (0 == (con->daemon->options & MHD_USE_POLL)) |
611 | { | 622 | { |
612 | /* use select */ | 623 | /* use select */ |
@@ -629,7 +640,11 @@ MHD_handle_connection (void *data) | |||
629 | break; | 640 | break; |
630 | } | 641 | } |
631 | /* call appropriate connection handler if necessary */ | 642 | /* call appropriate connection handler if necessary */ |
632 | if (FD_ISSET (con->socket_fd, &rs)) | 643 | if ( (FD_ISSET (con->socket_fd, &rs)) |
644 | #if HTTPS_SUPPORT | ||
645 | || (MHD_YES == con->tls_read_ready) | ||
646 | #endif | ||
647 | ) | ||
633 | con->read_handler (con); | 648 | con->read_handler (con); |
634 | if (FD_ISSET (con->socket_fd, &ws)) | 649 | if (FD_ISSET (con->socket_fd, &ws)) |
635 | con->write_handler (con); | 650 | con->write_handler (con); |
@@ -660,7 +675,11 @@ MHD_handle_connection (void *data) | |||
660 | #endif | 675 | #endif |
661 | break; | 676 | break; |
662 | } | 677 | } |
663 | if (0 != (p[0].revents & POLLIN)) | 678 | if ( (0 != (p[0].revents & POLLIN)) |
679 | #if HTTPS_SUPPORT | ||
680 | || (MHD_YES == con->tls_read_ready) | ||
681 | #endif | ||
682 | ) | ||
664 | con->read_handler (con); | 683 | con->read_handler (con); |
665 | if (0 != (p[0].revents & POLLOUT)) | 684 | if (0 != (p[0].revents & POLLOUT)) |
666 | con->write_handler (con); | 685 | con->write_handler (con); |
@@ -1271,6 +1290,14 @@ MHD_get_timeout (struct MHD_Daemon *daemon, | |||
1271 | have_timeout = MHD_NO; | 1290 | have_timeout = MHD_NO; |
1272 | for (pos = daemon->connections_head; NULL != pos; pos = pos->next) | 1291 | for (pos = daemon->connections_head; NULL != pos; pos = pos->next) |
1273 | { | 1292 | { |
1293 | #if HTTPS_SUPPORT | ||
1294 | if (MHD_YES == pos->tls_read_ready) | ||
1295 | { | ||
1296 | earliest_deadline = 0; | ||
1297 | have_timeout = MHD_YES; | ||
1298 | break; | ||
1299 | } | ||
1300 | #endif | ||
1274 | if (0 != pos->connection_timeout) | 1301 | if (0 != pos->connection_timeout) |
1275 | { | 1302 | { |
1276 | if ( (! have_timeout) || | 1303 | if ( (! have_timeout) || |
@@ -1397,7 +1424,11 @@ MHD_select (struct MHD_Daemon *daemon, | |||
1397 | ds = pos->socket_fd; | 1424 | ds = pos->socket_fd; |
1398 | if (ds != -1) | 1425 | if (ds != -1) |
1399 | { | 1426 | { |
1400 | if (FD_ISSET (ds, &rs)) | 1427 | if ( (FD_ISSET (ds, &rs)) |
1428 | #if HTTPS_SUPPORT | ||
1429 | || (MHD_YES == pos->tls_read_ready) | ||
1430 | #endif | ||
1431 | ) | ||
1401 | pos->read_handler (pos); | 1432 | pos->read_handler (pos); |
1402 | if (FD_ISSET (ds, &ws)) | 1433 | if (FD_ISSET (ds, &ws)) |
1403 | pos->write_handler (pos); | 1434 | pos->write_handler (pos); |