From 99e876d8f7f51a331f3d03a5631e75ec5777f79f Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 6 Feb 2016 08:44:34 +0800 Subject: [PATCH] ah pool take care about freeing headers after parsing Signed-off-by: Andy Green --- lib/server.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/server.c b/lib/server.c index 62bf7f93..e1ca3437 100644 --- a/lib/server.c +++ b/lib/server.c @@ -304,8 +304,16 @@ lws_http_action(struct lws *wsi) wsi->user_space, uri_ptr, uri_len); } - /* now drop the header info we kept a pointer to */ - lws_free_header_table(wsi); + /* + * If we are in keepalive, we may already have the next header set + * pipelined in the lws_read buffer above us... if so, we must hold + * the ah so it's still bound when we want to process the next headers. + * + */ + if (connection_type == HTTP_CONNECTION_CLOSE || + !wsi->u.hdr.more_rx_waiting) + /* now drop the header info we kept a pointer to */ + lws_free_header_table(wsi); if (n) { lwsl_info("LWS_CALLBACK_HTTP closing\n");