From: Alex Rousskov Date: Thu, 14 Mar 2013 23:04:37 +0000 (-0600) Subject: Fix concurrency support in stateless helpers: Parse multiple replies correctly. X-Git-Tag: SQUID_3_4_0_1~238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7bef981eb4b82ae484b4a32d6ef6b9e728db2ef6;p=thirdparty%2Fsquid.git Fix concurrency support in stateless helpers: Parse multiple replies correctly. 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. --- diff --git a/src/helper.cc b/src/helper.cc index 65868525bb..438d9ea256 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -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)) {