]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix concurrency support in stateless helpers: Parse multiple replies correctly.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 14 Mar 2013 23:04:37 +0000 (17:04 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 14 Mar 2013 23:04:37 +0000 (17:04 -0600)
When multiple helper replies were read at the same time, the old code moved \0
(former EoM mark) in front of the buffer after handling the first reply, which
prevented remaining replies from being parsed.

The code also did not terminate the remaining replies correctly after moving
them to the beginning of the buffer. As far as I could test, such termination
is accidentally(?) not necessary, but I could not figure out why and added it
anyway.

src/helper.cc

index 65868525bbbb662a7f23c2527f377d8d81591d36..438d9ea256d96a083ee1932614495559a284c91c 100644 (file)
@@ -953,7 +953,8 @@ helperHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, com
 
         helperReturnBuffer(i, srv, hlp, msg, t);
         srv->roffset -= (t - srv->rbuf) + skip;
-        memmove(srv->rbuf, t, srv->roffset);
+        memmove(srv->rbuf, t + skip, srv->roffset);
+        srv->rbuf[srv->roffset] = '\0';
     }
 
     if (Comm::IsConnOpen(srv->readPipe)) {