@@ -1443,12 +1443,10 @@ static int pipe_response_save(conn *c, const char *str, size_t len)
14431443 if (c->pipe_count == 0) {
14441444 /* skip the memory of response head string: "RESPONSE %d\r\n" */
14451445 c->pipe_reslen = PIPE_RES_HEAD_SIZE;
1446- c->pipe_resptr = &c->pipe_response[c->pipe_reslen];
14471446 }
14481447 if ((c->pipe_reslen + (len+2)) < (PIPE_RES_MAX_SIZE-PIPE_RES_TAIL_SIZE)) {
1449- sprintf(c->pipe_resptr , "%s\r\n", str);
1448+ sprintf(c->pipe_resbuf + c->pipe_reslen , "%s\r\n", str);
14501449 c->pipe_reslen += (len+2);
1451- c->pipe_resptr = &c->pipe_response[c->pipe_reslen];
14521450 c->pipe_count++;
14531451 if (c->pipe_count >= PIPE_CMD_MAX_COUNT && c->noreply == true) {
14541452 /* c->noreply == true: There are remaining pipe operations. */
@@ -1466,13 +1464,13 @@ static int pipe_response_save(conn *c, const char *str, size_t len)
14661464 return -1;
14671465 }
14681466 } else {
1469- /* A response message has come here before pipe error is reset.
1470- * Maybe, clients may not send all the commands of the pipelining .
1471- * So , force to reset the current pipelining.
1467+ /* A new command was processed before the pipe error was reset. This
1468+ * means that the previous pipelined commands were not properly swallowed .
1469+ * For now , force resets the previous pipelining.
14721470 */
14731471 mc_logger->log(EXTENSION_LOG_INFO, c,
1474- "%d: response message before pipe error is reset. %s\n",
1475- c->sfd , str);
1472+ "[%s] A new response before pipe error is reset. %s\n",
1473+ c->client_ip , str);
14761474 pipe_state_clear(c);
14771475 }
14781476 return 0;
@@ -1488,35 +1486,34 @@ static void pipe_response_done(conn *c, bool end_of_pipelining)
14881486 headlen = sprintf(headbuf, "RESPONSE %d\r\n", c->pipe_count);
14891487 assert(headlen > 0 && headlen <= PIPE_RES_HEAD_SIZE);
14901488 headidx = PIPE_RES_HEAD_SIZE - headlen;
1491- memcpy(&c->pipe_response [headidx], headbuf, headlen);
1489+ memcpy(&c->pipe_resbuf [headidx], headbuf, headlen);
14921490
14931491 /* pipe response tail string */
14941492 if (c->pipe_state == PIPE_STATE_ON) {
1495- sprintf(c->pipe_resptr , "END\r\n");
1493+ sprintf(c->pipe_resbuf + c->pipe_reslen , "END\r\n");
14961494 c->pipe_reslen += 5;
1497-
1498- pipe_state_clear(c);
1495+ pipe_state_clear(c); /* the end of pipelining */
14991496 } else {
15001497 if (c->pipe_state == PIPE_STATE_ERR_CFULL) {
1501- sprintf(c->pipe_resptr , "PIPE_ERROR command overflow\r\n");
1498+ sprintf(c->pipe_resbuf + c->pipe_reslen , "PIPE_ERROR command overflow\r\n");
15021499 c->pipe_reslen += 29;
15031500 } else if (c->pipe_state == PIPE_STATE_ERR_MFULL) {
1504- sprintf(c->pipe_resptr , "PIPE_ERROR memory overflow\r\n");
1501+ sprintf(c->pipe_resbuf + c->pipe_reslen , "PIPE_ERROR memory overflow\r\n");
15051502 c->pipe_reslen += 28;
15061503 } else { /* PIPE_STATE_ERR_BAD */
1507- sprintf(c->pipe_resptr , "PIPE_ERROR bad error\r\n");
1504+ sprintf(c->pipe_resbuf + c->pipe_reslen , "PIPE_ERROR bad error\r\n");
15081505 c->pipe_reslen += 22;
15091506 }
15101507 if (end_of_pipelining) {
15111508 pipe_state_clear(c);
15121509 }
15131510 /* The pipe_state will be cleared
1514- * after swallowing the remaining data .
1511+ * after swallowing the remaining command .
15151512 */
15161513 }
15171514
15181515 c->wbytes = c->pipe_reslen - headidx;
1519- c->wcurr = &c->pipe_response [headidx];
1516+ c->wcurr = &c->pipe_resbuf [headidx];
15201517
15211518 conn_set_state(c, conn_write);
15221519 c->write_and_go = conn_new_cmd;
@@ -7795,8 +7792,8 @@ static bool check_and_handle_pipe_state(conn *c)
77957792 if (c->noreply) {
77967793 c->noreply = false; /* reset noreply */
77977794 } else {
7798- /* The last command of pipelining has come. */
7799- pipe_state_clear(c);
7795+ /* The last command of pipelining has come here . */
7796+ pipe_state_clear(c); /* the end of pipelining */
78007797 }
78017798 return false;
78027799 }
0 commit comments