Skip to content

Commit 4898642

Browse files
Properly handle ECHO in MULTI or ATOMIC mode
1 parent 1725fcc commit 4898642

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

redis_cluster.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,7 @@ PHP_METHOD(RedisCluster, ping) {
28282828
* proto string RedisCluster::echo(array host_port, string msg) */
28292829
PHP_METHOD(RedisCluster, echo) {
28302830
redisCluster *c = GET_CONTEXT();
2831+
REDIS_REPLY_TYPE rtype;
28312832
zval *z_arg;
28322833
char *cmd, *msg;
28332834
int cmd_len, msg_len;
@@ -2852,15 +2853,21 @@ PHP_METHOD(RedisCluster, echo) {
28522853
cmd_len = redis_cmd_format_static(&cmd, "ECHO", "s", msg, msg_len);
28532854

28542855
/* Send it off */
2855-
if(cluster_send_slot(c,slot,cmd,cmd_len,TYPE_BULK TSRMLS_CC)<0) {
2856+
rtype = CLUSTER_IS_ATOMIC(c) ? TYPE_BULK : TYPE_LINE;
2857+
if(cluster_send_slot(c,slot,cmd,cmd_len,rtype TSRMLS_CC)<0) {
28562858
zend_throw_exception(redis_cluster_exception_ce,
28572859
"Unable to send commnad at the specificed node", 0 TSRMLS_CC);
28582860
efree(cmd);
28592861
RETURN_FALSE;
28602862
}
28612863

28622864
/* Process bulk response */
2863-
cluster_bulk_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, NULL);
2865+
if (CLUSTER_IS_ATOMIC(c)) {
2866+
cluster_bulk_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, NULL);
2867+
} else {
2868+
void *ctx = NULL;
2869+
CLUSTER_ENQUEUE_RESPONSE(c, slot, cluster_bulk_resp, ctx);
2870+
}
28642871

28652872
efree(cmd);
28662873
}

0 commit comments

Comments
 (0)