From: Stephan Bosch Date: Sat, 4 Feb 2017 14:40:41 +0000 (+0100) Subject: lib-http: response parser: Drop previous response's pool immediately when parsing... X-Git-Tag: 2.3.0.rc1~2098 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c177bc7c153dd4d00dfa719f8a93c81129c4235e;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/lib-http/http-response-parser.c b/src/lib-http/http-response-parser.c index 0f70092590..a9e4ff2aa5 100644 --- a/src/lib-http/http-response-parser.c +++ b/src/lib-http/http-response-parser.c @@ -146,7 +146,6 @@ static int http_response_parse(struct http_response_parser *parser) */ 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 @@ int http_response_parse_next(struct http_response_parser *parser, return ret; } + if (parser->state == HTTP_RESPONSE_PARSE_STATE_INIT) + http_response_parser_restart(parser); + /* RFC 7230, Section 3: HTTP-message = start-line