changeset 21561:f0fbdd5839c1

lib-http: response parser: Drop previous response's pool immediately when parsing continues. Prevously, it would only do that when the first byte of the next response was received. This prevents wasting memory when no response is being parsed.
author Stephan Bosch <stephan.bosch@dovecot.fi>
date Sat, 04 Feb 2017 15:40:41 +0100
parents a304fb6bb606
children 4d4823518e9c
files src/lib-http/http-response-parser.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-http/http-response-parser.c	Sat Feb 04 16:21:51 2017 +0100
+++ b/src/lib-http/http-response-parser.c	Sat Feb 04 15:40:41 2017 +0100
@@ -146,7 +146,6 @@
 	 */
 	switch (parser->state) {
 	case HTTP_RESPONSE_PARSE_STATE_INIT:
-		http_response_parser_restart(parser);
 		parser->state = HTTP_RESPONSE_PARSE_STATE_VERSION;
 		/* fall through */
 	case HTTP_RESPONSE_PARSE_STATE_VERSION:
@@ -313,6 +312,9 @@
 		return ret;
 	}
 
+	if (parser->state == HTTP_RESPONSE_PARSE_STATE_INIT)
+		http_response_parser_restart(parser);
+
 	/* RFC 7230, Section 3:
 		
 	   HTTP-message   = start-line