]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 21 Dec 2010 00:52:56 +0000 (17:52 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 21 Dec 2010 00:52:56 +0000 (17:52 -0700)
Polished HttpStateData::persistentConnStatus() code. No functionality changes.

Do not check for flags.headers_parsed. The removed check was:
 - misplaced: connection-related conditions such as eof must be checked first;
 - wasteful: we never call persistentConnStatus() unless we parsed headers.

Moreover, calling persistentConnStatus() before we parse headers would trigger
and assertion because the method uses virginReply() which does not exist until
the headers are parsed.

Moved virginReply() call closer to the first virgin reply use. This will help
re-adding "did we parse the header yet" check if we ever need it again. It
also saves a couple of CPU cycles for some transactions.

src/http.cc

index c8bb9ece2e1b7a401a49b128ae9f8858eafb71cc..0b92260247fadb80e2b4c7994df0a887b451129e 100644 (file)
@@ -967,15 +967,6 @@ HttpStateData::ConnectionStatus
 HttpStateData::persistentConnStatus() const
 {
     debugs(11, 3, "persistentConnStatus: FD " << fd << " eof=" << eof);
-    const HttpReply *vrep = virginReply();
-    debugs(11, 5, "persistentConnStatus: content_length=" << vrep->content_length);
-
-    /* If we haven't seen the end of reply headers, we are not done */
-    debugs(11, 5, "persistentConnStatus: flags.headers_parsed=" << flags.headers_parsed);
-
-    if (!flags.headers_parsed)
-        return INCOMPLETE_MSG;
-
     if (eof) // already reached EOF
         return COMPLETE_NONPERSISTENT_MSG;
 
@@ -987,6 +978,9 @@ HttpStateData::persistentConnStatus() const
     if (lastChunk && flags.chunked)
         return statusIfComplete();
 
+    const HttpReply *vrep = virginReply();
+    debugs(11, 5, "persistentConnStatus: content_length=" << vrep->content_length);
+
     const int64_t clen = vrep->bodySize(request->method);
 
     debugs(11, 5, "persistentConnStatus: clen=" << clen);