Signed-off-by: Andy Green <andy.green@linaro.org>
context->service_tid = context->protocols[0].callback(context, NULL,
LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
context->service_tid = context->protocols[0].callback(context, NULL,
LWS_CALLBACK_GET_THREAD_ID, NULL, NULL, 0);
+#ifdef LWS_OPENSSL_SUPPORT
+ /* if we know we have non-network pending data, do not wait in poll */
+ if (context->ssl_flag_buffered_reads)
+ timeout_ms = 0;
+#endif
n = poll(context->fds, context->fds_count, timeout_ms);
context->service_tid = 0;
n = poll(context->fds, context->fds_count, timeout_ms);
context->service_tid = 0;
+#ifdef LWS_OPENSSL_SUPPORT
+ if (!context->ssl_flag_buffered_reads && n == 0) {
+#else
if (n == 0) /* poll timeout */ {
if (n == 0) /* poll timeout */ {
libwebsocket_service_fd(context, NULL);
return 0;
}
libwebsocket_service_fd(context, NULL);
return 0;
}
+
+#ifdef LWS_OPENSSL_SUPPORT
+ /* any more will have to set it fresh this time around */
+ context->ssl_flag_buffered_reads = 0;
+#endif
if (n < 0) {
if (LWS_ERRNO != LWS_EINTR)
if (n < 0) {
if (LWS_ERRNO != LWS_EINTR)
if (wsi->ssl && wsi->buffered_reads_pending) {
lwsl_debug("wsi %p: forcing POLLIN\n", wsi);
context->fds[n].revents |= context->fds[n].events & POLLIN;
if (wsi->ssl && wsi->buffered_reads_pending) {
lwsl_debug("wsi %p: forcing POLLIN\n", wsi);
context->fds[n].revents |= context->fds[n].events & POLLIN;
+ if (context->fds[n].revents & POLLIN)
+ wsi->buffered_reads_pending = 0;
+ else
+ /* somebody left with pending SSL read data */
+ context->ssl_flag_buffered_reads = 1;
}
#endif
if (!context->fds[n].revents)
}
#endif
if (!context->fds[n].revents)
int allow_non_ssl_on_ssl_port;
SSL_CTX *ssl_ctx;
SSL_CTX *ssl_client_ctx;
int allow_non_ssl_on_ssl_port;
SSL_CTX *ssl_ctx;
SSL_CTX *ssl_client_ctx;
+ unsigned int ssl_flag_buffered_reads:1;
#endif
struct libwebsocket_protocols *protocols;
int count_protocols;
#endif
struct libwebsocket_protocols *protocols;
int count_protocols;
if (!(pollfd->revents & LWS_POLLIN))
break;
if (!(pollfd->revents & LWS_POLLIN))
break;
- eff_buf.token_len = lws_ssl_capable_read(context->wsi,
+ eff_buf.token_len = lws_ssl_capable_read(context, wsi,
context->service_buffer,
sizeof(context->service_buffer));
switch (eff_buf.token_len) {
context->service_buffer,
sizeof(context->service_buffer));
switch (eff_buf.token_len) {
* Because these won't signal at the network layer with POLLIN
* and if we don't realize, this data will sit there forever
*/
* Because these won't signal at the network layer with POLLIN
* and if we don't realize, this data will sit there forever
*/
- if (n == len && wsi->ssl && SSL_pending(wsi->ssl))
+ if (n == len && wsi->ssl && SSL_pending(wsi->ssl)) {
+ context->ssl_flag_buffered_reads = 1;
wsi->buffered_reads_pending = 1;
wsi->buffered_reads_pending = 1;