]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: response parser: Drop previous response's pool immediately when parsing...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 4 Feb 2017 14:40:41 +0000 (15:40 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 17 Feb 2017 09:32:32 +0000 (11:32 +0200)
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.

src/lib-http/http-response-parser.c

index be604ce3cc44cc224589f1e6354972132cb02468..a6fca1d3b3a909cefb3fe3d57a4045274b217f87 100644 (file)
@@ -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