@@ -2703,6 +2703,24 @@ PHP_METHOD(RedisCluster, client) {
2703
2703
slot = cluster_cmd_get_slot (c , z_node TSRMLS_CC );
2704
2704
if (slot < 0 ) RETURN_FALSE ;
2705
2705
2706
+ /* Our return type and reply callback is different for all subcommands */
2707
+ if (opt_len == 4 && !strncasecmp (opt , "list" , 4 )) {
2708
+ rtype = CLUSTER_IS_ATOMIC (c ) ? TYPE_BULK : TYPE_LINE ;
2709
+ cb = cluster_client_list_resp ;
2710
+ } else if ((opt_len == 4 && !strncasecmp (opt , "kill" , 4 )) ||
2711
+ (opt_len == 7 && !strncasecmp (opt , "setname" , 7 )))
2712
+ {
2713
+ rtype = TYPE_LINE ;
2714
+ cb = cluster_bool_resp ;
2715
+ } else if (opt_len == 7 && !strncasecmp (opt , "getname" , 7 )) {
2716
+ rtype = CLUSTER_IS_ATOMIC (c ) ? TYPE_BULK : TYPE_LINE ;
2717
+ cb = cluster_bulk_resp ;
2718
+ } else {
2719
+ php_error_docref (NULL TSRMLS_CC , E_WARNING ,
2720
+ "Invalid CLIENT subcommand (LIST, KILL, GETNAME, and SETNAME are valid" );
2721
+ RETURN_FALSE ;
2722
+ }
2723
+
2706
2724
/* Construct the command */
2707
2725
if (ZEND_NUM_ARGS () == 3 ) {
2708
2726
cmd_len = redis_cmd_format_static (& cmd , "CLIENT" , "ss" , opt , opt_len ,
@@ -2714,27 +2732,20 @@ PHP_METHOD(RedisCluster, client) {
2714
2732
RETURN_FALSE ;
2715
2733
}
2716
2734
2717
- rtype = CLUSTER_IS_ATOMIC ( c ) ? TYPE_BULK : TYPE_LINE ;
2735
+ /* Attempt to write our command */
2718
2736
if (cluster_send_slot (c , slot , cmd , cmd_len , rtype TSRMLS_CC )< 0 ) {
2719
2737
zend_throw_exception (redis_cluster_exception_ce ,
2720
2738
"Unable to send CLIENT command to specific node" , 0 TSRMLS_CC );
2721
2739
efree (cmd );
2722
2740
RETURN_FALSE ;
2723
2741
}
2724
2742
2725
- /* Handle client list and anything else differently */
2726
- if (opt_len == 4 && !strncasecmp (opt , "list" , 4 )) {
2727
- cb = cluster_client_list_resp ;
2728
- } else {
2729
- cb = cluster_variant_resp ;
2730
- }
2731
-
2732
2743
/* Now enqueue or process response */
2733
2744
if (CLUSTER_IS_ATOMIC (c )) {
2734
- cluster_client_list_resp (INTERNAL_FUNCTION_PARAM_PASSTHRU , c , NULL );
2745
+ cb (INTERNAL_FUNCTION_PARAM_PASSTHRU , c , NULL );
2735
2746
} else {
2736
2747
void * ctx = NULL ;
2737
- CLUSTER_ENQUEUE_RESPONSE (c , slot , cluster_client_list_resp , ctx );
2748
+ CLUSTER_ENQUEUE_RESPONSE (c , slot , cb , ctx );
2738
2749
}
2739
2750
2740
2751
efree (cmd );
0 commit comments