From 7bef981eb4b82ae484b4a32d6ef6b9e728db2ef6 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Thu, 14 Mar 2013 17:04:37 -0600 Subject: [PATCH] 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. --- src/helper.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)) { -- 2.47.2