[PATCH] default constructor for HttpParser

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Fri, 01 Apr 2011 02:07:55 +1300

On 30/03/11 05:43, Alex Rousskov wrote:
> On 03/25/2011 08:03 PM, Amos Jeffries wrote:
>> ------------------------------------------------------------
>> revno: 11314
>> committer: Amos Jeffries<squid3_at_treenet.co.nz>
>> branch nick: trunk
>> timestamp: Sat 2011-03-26 15:03:49 +1300
>> message:
>> Cleanup: make clientParseRequest() a member of ConnStateData
>>
>> This allows the HttpParser to also become a member field and persistent
>> across all requests on the connection instead of newely allocated on
>> the stack for every read cycle.
>> That in turn allows the parser to retain state for efficient 'trickle'
>> parsing across multiple read cycles.
>>
>> For now the old behaviour of reset on every read is retained in order to
>> prevent this shuffling from causing behaviour changes. That negates most
>> of the actual performance gains (for now).
>
>
>> class HttpParser
>> {
>> public:
>> + HttpParser() {};
>
> This creates a parser in an invalid/random state. We should never do
> that. The old code was also broken, but the broken class was not used as
> a member and did not have any constructors so it was more-or-less clear
> that it is just an old C structure. The new code makes it look like a
> good, usable class, but it is not.
>
> Please either remove the default HttpParser constructor or call
> HttpParserInit from the default constructor. In both cases, I think you
> can use a zero-length NULL or "" buffer to give the parser a valid
> initial state.
>

This patch should fix that.

It adds a reset() function to perform the default constructor
initialization. That can also be shared by the other init code.

Amos

-- 
Please be using
   Current Stable Squid 2.7.STABLE9 or 3.1.11
   Beta testers wanted for 3.2.0.5

Received on Thu Mar 31 2011 - 13:08:11 MDT

This archive was generated by hypermail 2.2.0 : Thu Mar 31 2011 - 12:00:04 MDT