@@ -2703,6 +2703,24 @@ PHP_METHOD(RedisCluster, client) {
27032703 slot = cluster_cmd_get_slot (c , z_node TSRMLS_CC );
27042704 if (slot < 0 ) RETURN_FALSE ;
27052705
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+
27062724 /* Construct the command */
27072725 if (ZEND_NUM_ARGS () == 3 ) {
27082726 cmd_len = redis_cmd_format_static (& cmd , "CLIENT" , "ss" , opt , opt_len ,
@@ -2714,27 +2732,20 @@ PHP_METHOD(RedisCluster, client) {
27142732 RETURN_FALSE ;
27152733 }
27162734
2717- rtype = CLUSTER_IS_ATOMIC ( c ) ? TYPE_BULK : TYPE_LINE ;
2735+ /* Attempt to write our command */
27182736 if (cluster_send_slot (c , slot , cmd , cmd_len , rtype TSRMLS_CC )< 0 ) {
27192737 zend_throw_exception (redis_cluster_exception_ce ,
27202738 "Unable to send CLIENT command to specific node" , 0 TSRMLS_CC );
27212739 efree (cmd );
27222740 RETURN_FALSE ;
27232741 }
27242742
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-
27322743 /* Now enqueue or process response */
27332744 if (CLUSTER_IS_ATOMIC (c )) {
2734- cluster_client_list_resp (INTERNAL_FUNCTION_PARAM_PASSTHRU , c , NULL );
2745+ cb (INTERNAL_FUNCTION_PARAM_PASSTHRU , c , NULL );
27352746 } else {
27362747 void * ctx = NULL ;
2737- CLUSTER_ENQUEUE_RESPONSE (c , slot , cluster_client_list_resp , ctx );
2748+ CLUSTER_ENQUEUE_RESPONSE (c , slot , cb , ctx );
27382749 }
27392750
27402751 efree (cmd );
0 commit comments