From 912c42f2918e06e609d9cf0d6fcba363e6cbfbf1 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 19 Apr 2016 10:10:53 +0800 Subject: [PATCH] ah try for ah when adopting socket to vhost https://github.com/warmcat/libwebsockets/issues/496 Even if no ah available, we will be on the ah waiting list and get triggered when one is freed and we're next in line. Signed-off-by: Andy Green --- lib/server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/server.c b/lib/server.c index 41e6339a..f1c29e5b 100644 --- a/lib/server.c +++ b/lib/server.c @@ -1200,6 +1200,9 @@ lws_adopt_socket_vhost(struct lws_vhost *vh, lws_sockfd_type accept_fd) } } + if (!lws_header_table_attach(new_wsi, 0)) + lwsl_debug("Attached ah immediately\n"); + return new_wsi; fail: @@ -1279,7 +1282,7 @@ lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, * readbuf data to wsi or ah yet, and we will do it next if we get * the ah. */ - if (!lws_header_table_attach(wsi, 0)) { + if (wsi->u.hdr.ah || !lws_header_table_attach(wsi, 0)) { ah = wsi->u.hdr.ah; memcpy(ah->rx, readbuf, len); ah->rxpos = 0;