diff --git a/lib/server.c b/lib/server.c index 1711ae62..79ad5829 100644 --- a/lib/server.c +++ b/lib/server.c @@ -856,7 +856,9 @@ lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, const char *readbuf, size_t len) { struct lws *wsi = lws_adopt_socket(context, accept_fd); + struct lws_context_per_thread *pt; struct allocated_headers *ah; + struct lws_pollfd *pfd; if (!wsi) return NULL; @@ -880,6 +882,16 @@ lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, ah->rxpos = 0; ah->rxlen = len; + pt = &context->pt[(int)wsi->tsi]; + + /* unlike a normal connect, we have the headers already + * (or the first part of them anyway) + */ + pfd = &pt->fds[wsi->position_in_fds_table]; + pfd->revents |= LWS_POLLIN; + lwsl_err("%s: calling service\n", __func__); + lws_service_fd_tsi(context, pfd, wsi->tsi); + return wsi; } @@ -1047,6 +1059,9 @@ try_pollout: goto fail; } + if (!wsi->hdr_parsing_completed) + break; + if (wsi->state != LWSS_HTTP_ISSUING_FILE) { n = user_callback_handle_rxflow(wsi->protocol->callback, wsi, LWS_CALLBACK_HTTP_WRITEABLE, diff --git a/lib/service.c b/lib/service.c index 6ebd562d..e1faeba4 100644 --- a/lib/service.c +++ b/lib/service.c @@ -237,6 +237,9 @@ user_service: return 1; } + if (!wsi->hdr_parsing_completed) + return 0; + #ifdef LWS_USE_HTTP2 /* * we are the 'network wsi' for potentially many muxed child wsi with