diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 425a18a4..55604eb8 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1012,10 +1012,12 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1012 | urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; | 1012 | urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; |
1013 | /* Reading from remote client is not required anymore. */ | 1013 | /* Reading from remote client is not required anymore. */ |
1014 | urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; | 1014 | urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; |
1015 | urh->connection->tls_read_ready = 0; | ||
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | /* handle reading from TLS client and writing to application */ | 1018 | /* handle reading from TLS client and writing to application */ |
1018 | if ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) && | 1019 | if ( ( (0 != (MHD_EPOLL_STATE_READ_READY & urh->app.celi)) || |
1020 | (urh->connection->tls_read_ready) ) && | ||
1019 | (urh->in_buffer_used < urh->in_buffer_size) ) | 1021 | (urh->in_buffer_used < urh->in_buffer_size) ) |
1020 | { | 1022 | { |
1021 | ssize_t res; | 1023 | ssize_t res; |
@@ -1025,6 +1027,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1025 | if (buf_size > SSIZE_MAX) | 1027 | if (buf_size > SSIZE_MAX) |
1026 | buf_size = SSIZE_MAX; | 1028 | buf_size = SSIZE_MAX; |
1027 | 1029 | ||
1030 | urh->connection->tls_read_ready = 0; | ||
1028 | res = gnutls_record_recv (urh->connection->tls_session, | 1031 | res = gnutls_record_recv (urh->connection->tls_session, |
1029 | &urh->in_buffer[urh->in_buffer_used], | 1032 | &urh->in_buffer[urh->in_buffer_used], |
1030 | buf_size); | 1033 | buf_size); |
@@ -1036,6 +1039,11 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1036 | else if (res > 0) | 1039 | else if (res > 0) |
1037 | { | 1040 | { |
1038 | urh->in_buffer_used += res; | 1041 | urh->in_buffer_used += res; |
1042 | if (0 < gnutls_record_check_pending (urh->connection->tls_session)) | ||
1043 | { | ||
1044 | urh->connection->tls_read_ready = !0; | ||
1045 | urh->connection->daemon->has_tls_recv_ready = !0; | ||
1046 | } | ||
1039 | } | 1047 | } |
1040 | else if (0 >= res) | 1048 | else if (0 >= res) |
1041 | { | 1049 | { |
@@ -1083,6 +1091,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) | |||
1083 | urh->in_buffer_used = 0; | 1091 | urh->in_buffer_used = 0; |
1084 | urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; | 1092 | urh->mhd.celi &= ~MHD_EPOLL_STATE_WRITE_READY; |
1085 | urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; | 1093 | urh->app.celi &= ~MHD_EPOLL_STATE_READ_READY; |
1094 | urh->connection->tls_read_ready = 0; | ||
1086 | } | 1095 | } |
1087 | } | 1096 | } |
1088 | else | 1097 | else |
@@ -2872,7 +2881,7 @@ MHD_get_timeout (struct MHD_Daemon *daemon, | |||
2872 | } | 2881 | } |
2873 | 2882 | ||
2874 | #ifdef HTTPS_SUPPORT | 2883 | #ifdef HTTPS_SUPPORT |
2875 | if (0 != daemon->num_tls_read_ready) | 2884 | if (0 != daemon->num_tls_read_ready || daemon->has_tls_recv_ready) |
2876 | { | 2885 | { |
2877 | /* if there is any TLS connection with data ready for | 2886 | /* if there is any TLS connection with data ready for |
2878 | reading, we must not block in the event loop */ | 2887 | reading, we must not block in the event loop */ |
@@ -2974,6 +2983,14 @@ MHD_run_from_select (struct MHD_Daemon *daemon, | |||
2974 | read_fd_set)) ) | 2983 | read_fd_set)) ) |
2975 | MHD_itc_clear_ (daemon->itc); | 2984 | MHD_itc_clear_ (daemon->itc); |
2976 | 2985 | ||
2986 | #ifdef HTTPS_SUPPORT | ||
2987 | /* Reset TLS read-ready. | ||
2988 | * New value will be set by read handlers. */ | ||
2989 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
2990 | (0 != (daemon->options & MHD_USE_TLS)) ) | ||
2991 | daemon->has_tls_recv_ready = 0; | ||
2992 | #endif /* HTTPS_SUPPORT */ | ||
2993 | |||
2977 | /* Resuming external connections when using an extern mainloop */ | 2994 | /* Resuming external connections when using an extern mainloop */ |
2978 | if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & mask)) | 2995 | if (MHD_ALLOW_SUSPEND_RESUME == (daemon->options & mask)) |
2979 | resume_suspended_connections (daemon); | 2996 | resume_suspended_connections (daemon); |
@@ -3363,6 +3380,14 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
3363 | (0 != (p[poll_itc_idx].revents & POLLIN)) ) | 3380 | (0 != (p[poll_itc_idx].revents & POLLIN)) ) |
3364 | MHD_itc_clear_ (daemon->itc); | 3381 | MHD_itc_clear_ (daemon->itc); |
3365 | 3382 | ||
3383 | #ifdef HTTPS_SUPPORT | ||
3384 | /* Reset TLS read-ready. | ||
3385 | * New value will be set by read handlers. */ | ||
3386 | if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && | ||
3387 | (0 != (daemon->options & MHD_USE_TLS)) ) | ||
3388 | daemon->has_tls_recv_ready = 0; | ||
3389 | #endif /* HTTPS_SUPPORT */ | ||
3390 | |||
3366 | /* handle shutdown */ | 3391 | /* handle shutdown */ |
3367 | if (MHD_YES == daemon->shutdown) | 3392 | if (MHD_YES == daemon->shutdown) |
3368 | { | 3393 | { |
@@ -3759,6 +3784,12 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3759 | #endif | 3784 | #endif |
3760 | return MHD_NO; | 3785 | return MHD_NO; |
3761 | } | 3786 | } |
3787 | #ifdef HTTPS_SUPPORT | ||
3788 | /* Reset TLS read-ready. | ||
3789 | * New value will be set by read handlers. */ | ||
3790 | if ( 0 != (daemon->options & MHD_USE_TLS) ) | ||
3791 | daemon->has_tls_recv_ready = 0; | ||
3792 | #endif /* HTTPS_SUPPORT */ | ||
3762 | for (i=0;i<(unsigned int) num_events;i++) | 3793 | for (i=0;i<(unsigned int) num_events;i++) |
3763 | { | 3794 | { |
3764 | /* First, check for the values of `ptr` that would indicate | 3795 | /* First, check for the values of `ptr` that would indicate |