Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'redis_cluster.c')
-rw-r--r--redis_cluster.c225
1 files changed, 55 insertions, 170 deletions
diff --git a/redis_cluster.c b/redis_cluster.c
index 3eb267c4..4de9d6c3 100644
--- a/redis_cluster.c
+++ b/redis_cluster.c
@@ -297,43 +297,23 @@ zend_function_entry redis_cluster_functions[] = {
};
/* Our context seeds will be a hash table with RedisSock* pointers */
-#if (PHP_MAJOR_VERSION < 7)
-static void ht_free_seed(void *data)
-#else
-static void ht_free_seed(zval *data)
-#endif
-{
+static void ht_free_seed(zval *data) {
RedisSock *redis_sock = *(RedisSock**)data;
if (redis_sock) redis_free_socket(redis_sock);
}
/* Free redisClusterNode objects we've stored */
-#if (PHP_MAJOR_VERSION < 7)
-static void ht_free_node(void *data)
-#else
-static void ht_free_node(zval *data)
-#endif
-{
+static void ht_free_node(zval *data) {
redisClusterNode *node = *(redisClusterNode**)data;
cluster_free_node(node);
}
/* Create redisCluster context */
-#if (PHP_MAJOR_VERSION < 7)
-zend_object_value
-create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
- redisCluster *cluster;
-
- // Allocate our actual struct
- cluster = ecalloc(1, sizeof(redisCluster));
-#else
-zend_object *
-create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
+zend_object * create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
redisCluster *cluster;
// Allocate our actual struct
cluster = ecalloc(1, sizeof(redisCluster) + sizeof(zval) * (class_type->default_properties_count - 1));
-#endif
// We're not currently subscribed anywhere
cluster->subscribed_slot = -1;
@@ -351,25 +331,7 @@ create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
// Initialize it
zend_object_std_init(&cluster->std, class_type TSRMLS_CC);
-#if (PHP_MAJOR_VERSION < 7)
- zend_object_value retval;
-#if PHP_VERSION_ID < 50399
- zval *tmp;
- zend_hash_copy(cluster->std.properties, &class_type->default_properties,
- (copy_ctor_func_t)zval_add_ref, (void*)&tmp, sizeof(zval*));
-#else
- object_properties_init(&cluster->std, class_type);
-#endif
-
- retval.handle = zend_objects_store_put(cluster,
- (zend_objects_store_dtor_t)zend_objects_destroy_object,
- free_cluster_context, NULL TSRMLS_CC);
-
- retval.handlers = zend_get_std_object_handlers();
-
- return retval;
-#else
object_properties_init(&cluster->std, class_type);
memcpy(&RedisCluster_handlers, zend_get_std_object_handlers(), sizeof(RedisCluster_handlers));
RedisCluster_handlers.offset = XtOffsetOf(redisCluster, std);
@@ -378,53 +340,34 @@ create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
cluster->std.handlers = &RedisCluster_handlers;
return &cluster->std;
-#endif
}
/* Free redisCluster context */
-#if (PHP_MAJOR_VERSION < 7)
-void
-free_cluster_context(void *object TSRMLS_DC)
-{
- redisCluster *cluster = (redisCluster*)object;
-
- cluster_free(cluster, 0 TSRMLS_CC);
- zend_object_std_dtor(&cluster->std TSRMLS_CC);
- efree(cluster);
-}
-#else
-void
-free_cluster_context(zend_object *object)
-{
+void free_cluster_context(zend_object *object) {
redisCluster *cluster = (redisCluster*)((char*)(object) - XtOffsetOf(redisCluster, std));
cluster_free(cluster, 0 TSRMLS_CC);
zend_object_std_dtor(&cluster->std TSRMLS_CC);
}
-#endif
/* Attempt to connect to a Redis cluster provided seeds and timeout options */
-static void
-redis_cluster_init(redisCluster *c, HashTable *ht_seeds,
- double timeout, double read_timeout, int persistent,
- char *auth, strlen_t auth_len TSRMLS_DC)
+static void redis_cluster_init(redisCluster *c, HashTable *ht_seeds, double timeout,
+ double read_timeout, int persistent, char *auth,
+ size_t auth_len TSRMLS_DC)
{
// Validate timeout
if (timeout < 0L || timeout > INT_MAX) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Invalid timeout", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Invalid timeout", 0);
}
// Validate our read timeout
if (read_timeout < 0L || read_timeout > INT_MAX) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Invalid read timeout", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Invalid read timeout", 0);
}
/* Make sure there are some seeds */
if (zend_hash_num_elements(ht_seeds) == 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Must pass seeds", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Must pass seeds", 0);
}
if (auth && auth_len > 0) {
@@ -454,7 +397,7 @@ redis_cluster_init(redisCluster *c, HashTable *ht_seeds,
void redis_cluster_load(redisCluster *c, char *name, int name_len TSRMLS_DC) {
zval z_seeds, z_timeout, z_read_timeout, z_persistent, z_auth, *z_value;
char *iptr, *auth = NULL;
- strlen_t auth_len = 0;
+ size_t auth_len = 0;
double timeout = 0, read_timeout = 0;
int persistent = 0;
HashTable *ht_seeds = NULL;
@@ -468,7 +411,7 @@ void redis_cluster_load(redisCluster *c, char *name, int name_len TSRMLS_DC) {
ht_seeds = Z_ARRVAL_P(z_value);
} else {
zval_dtor(&z_seeds);
- zend_throw_exception(redis_cluster_exception_ce, "Couldn't find seeds for cluster", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't find seeds for cluster", 0);
return;
}
@@ -546,7 +489,7 @@ void redis_cluster_load(redisCluster *c, char *name, int name_len TSRMLS_DC) {
PHP_METHOD(RedisCluster, __construct) {
zval *object, *z_seeds = NULL;
char *name, *auth = NULL;
- strlen_t name_len, auth_len = 0;
+ size_t name_len, auth_len = 0;
double timeout = 0.0, read_timeout = 0.0;
zend_bool persistent = 0;
redisCluster *context = GET_CONTEXT();
@@ -562,9 +505,7 @@ PHP_METHOD(RedisCluster, __construct) {
// Require a name
if (name_len == 0 && ZEND_NUM_ARGS() < 2) {
- zend_throw_exception(redis_cluster_exception_ce,
- "You must specify a name or pass seeds!",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("You must specify a name or pass seeds!", 0);
}
/* If we've been passed only one argument, the user is attempting to connect
@@ -643,12 +584,12 @@ typedef struct clusterKeyValHT {
char kbuf[22];
char *key;
- strlen_t key_len;
+ size_t key_len;
int key_free;
short slot;
char *val;
- strlen_t val_len;
+ size_t val_len;
int val_free;
} clusterKeyValHT;
@@ -661,26 +602,18 @@ static int get_key_val_ht(redisCluster *c, HashTable *ht, HashPosition *ptr,
// Grab the key, convert it to a string using provided kbuf buffer if it's
// a LONG style key
-#if (PHP_MAJOR_VERSION < 7)
- uint key_len;
- switch(zend_hash_get_current_key_ex(ht, &(kv->key), &key_len, &idx, 0, ptr)) {
- case HASH_KEY_IS_STRING:
- kv->key_len = (int)(key_len-1);
-#else
zend_string *zkey;
switch (zend_hash_get_current_key_ex(ht, &zkey, &idx, ptr)) {
case HASH_KEY_IS_STRING:
kv->key_len = ZSTR_LEN(zkey);
kv->key = ZSTR_VAL(zkey);
-#endif
break;
case HASH_KEY_IS_LONG:
kv->key_len = snprintf(kv->kbuf,sizeof(kv->kbuf),"%ld",(long)idx);
kv->key = kv->kbuf;
break;
default:
- zend_throw_exception(redis_cluster_exception_ce,
- "Internal Zend HashTable error", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Internal Zend HashTable error", 0);
return -1;
}
@@ -690,8 +623,7 @@ static int get_key_val_ht(redisCluster *c, HashTable *ht, HashPosition *ptr,
// Now grab our value
if ((z_val = zend_hash_get_current_data_ex(ht, ptr)) == NULL) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Internal Zend HashTable error", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Internal Zend HashTable error", 0);
return -1;
}
@@ -710,8 +642,7 @@ static int get_key_ht(redisCluster *c, HashTable *ht, HashPosition *ptr,
if ((z_key = zend_hash_get_current_data_ex(ht, ptr)) == NULL) {
// Shouldn't happen, but check anyway
- zend_throw_exception(redis_cluster_exception_ce,
- "Internal Zend HashTable error", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Internal Zend HashTable error", 0);
return -1;
}
@@ -979,14 +910,8 @@ static int cluster_mset_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
static void cluster_generic_delete(INTERNAL_FUNCTION_PARAMETERS,
char *kw, int kw_len)
{
- zval *z_ret;
-
-#if (PHP_MAJOR_VERSION < 7)
- MAKE_STD_ZVAL(z_ret);
-#else
- z_ret = emalloc(sizeof(zval));
-#endif
-
+ zval *z_ret = emalloc(sizeof(*z_ret));
+
// Initialize a LONG value to zero for our return
ZVAL_LONG(z_ret, 0);
@@ -1011,14 +936,8 @@ PHP_METHOD(RedisCluster, unlink) {
/* {{{ proto array RedisCluster::mget(array keys) */
PHP_METHOD(RedisCluster, mget) {
- zval *z_ret;
+ zval *z_ret = emalloc(sizeof(*z_ret));
- // Array response
-#if (PHP_MAJOR_VERSION < 7)
- MAKE_STD_ZVAL(z_ret);
-#else
- z_ret = emalloc(sizeof(zval));
-#endif
array_init(z_ret);
// Parse args, process
@@ -1033,14 +952,8 @@ PHP_METHOD(RedisCluster, mget) {
/* {{{ proto bool RedisCluster::mset(array keyvalues) */
PHP_METHOD(RedisCluster, mset) {
- zval *z_ret;
+ zval *z_ret = emalloc(sizeof(*z_ret));
- // Response, defaults to TRUE
-#if (PHP_MAJOR_VERSION < 7)
- MAKE_STD_ZVAL(z_ret);
-#else
- z_ret = emalloc(sizeof(zval));
-#endif
ZVAL_TRUE(z_ret);
// Parse args and process. If we get a failure, free zval and return FALSE.
@@ -1054,19 +967,13 @@ PHP_METHOD(RedisCluster, mset) {
/* {{{ proto array RedisCluster::msetnx(array keyvalues) */
PHP_METHOD(RedisCluster, msetnx) {
- zval *z_ret;
+ zval *z_ret = emalloc(sizeof(*z_ret));
- // Array response
-#if (PHP_MAJOR_VERSION < 7)
- MAKE_STD_ZVAL(z_ret);
-#else
- z_ret = emalloc(sizeof(zval));
-#endif
array_init(z_ret);
// Parse args and process. If we get a failure, free mem and return FALSE
if (cluster_mset_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, "MSETNX",
- sizeof("MSETNX")-1, z_ret, cluster_msetnx_resp) ==-1)
+ sizeof("MSETNX")-1, z_ret, cluster_msetnx_resp) ==-1)
{
zval_dtor(z_ret);
efree(z_ret);
@@ -1109,7 +1016,7 @@ PHP_METHOD(RedisCluster, exists) {
PHP_METHOD(RedisCluster, keys) {
redisCluster *c = GET_CONTEXT();
redisClusterNode *node;
- strlen_t pat_len;
+ size_t pat_len;
char *pat, *cmd;
clusterReply *resp;
int i, cmd_len;
@@ -1974,8 +1881,7 @@ static void generic_unsub_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
if (cluster_send_slot(c, c->subscribed_slot, cmd, cmd_len, TYPE_MULTIBULK
TSRMLS_CC) == FAILURE)
{
- zend_throw_exception(redis_cluster_exception_ce,
- "Failed to UNSUBSCRIBE within our subscribe loop!", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Failed to UNSUBSCRIBE within our subscribe loop!", 0);
RETURN_FALSE;
}
@@ -2091,14 +1997,13 @@ PHP_METHOD(RedisCluster, _masters) {
ZEND_HASH_FOREACH_PTR(c->nodes, node) {
if (node == NULL) break;
- zval z, *z_sub = &z;
+ zval z_sub;
- REDIS_MAKE_STD_ZVAL(z_sub);
- array_init(z_sub);
+ array_init(&z_sub);
- add_next_index_stringl(z_sub, ZSTR_VAL(node->sock->host), ZSTR_LEN(node->sock->host));
- add_next_index_long(z_sub, node->sock->port);
- add_next_index_zval(return_value, z_sub);
+ add_next_index_stringl(&z_sub, ZSTR_VAL(node->sock->host), ZSTR_LEN(node->sock->host));
+ add_next_index_long(&z_sub, node->sock->port);
+ add_next_index_zval(return_value, &z_sub);
} ZEND_HASH_FOREACH_END();
}
@@ -2175,9 +2080,7 @@ PHP_METHOD(RedisCluster, watch) {
// Add this key to our distribution handler
if (cluster_dist_add_key(c, ht_dist, ZSTR_VAL(zstr), ZSTR_LEN(zstr), NULL) == FAILURE) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Can't issue WATCH command as the keyspace isn't fully mapped",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Can't issue WATCH command as the keyspace isn't fully mapped", 0);
zend_string_release(zstr);
RETURN_FALSE;
}
@@ -2188,8 +2091,7 @@ PHP_METHOD(RedisCluster, watch) {
ZEND_HASH_FOREACH_PTR(ht_dist, dl) {
// Grab the clusterDistList pointer itself
if (dl == NULL) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Internal error in a PHP HashTable", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Internal error in a PHP HashTable", 0);
cluster_dist_free(ht_dist);
efree(z_args);
efree(cmd.c);
@@ -2265,10 +2167,7 @@ PHP_METHOD(RedisCluster, exec) {
if (SLOT_SOCK(c, fi->slot)->mode == MULTI) {
if ( cluster_send_exec(c, fi->slot TSRMLS_CC) < 0) {
cluster_abort_exec(c TSRMLS_CC);
-
- zend_throw_exception(redis_cluster_exception_ce,
- "Error processing EXEC across the cluster",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Error processing EXEC across the cluster", 0);
// Free our queue, reset MULTI state
CLUSTER_FREE_QUEUE(c);
@@ -2313,7 +2212,7 @@ PHP_METHOD(RedisCluster, discard) {
static short
cluster_cmd_get_slot(redisCluster *c, zval *z_arg TSRMLS_DC)
{
- strlen_t key_len;
+ size_t key_len;
int key_free;
zval *z_host, *z_port;
short slot;
@@ -2386,8 +2285,7 @@ cluster_empty_node_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw,
// Kick off our command
if (cluster_send_slot(c, slot, cmd, cmd_len, reply_type TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to send command at a specific node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to send command at a specific node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -2430,8 +2328,7 @@ cluster_flush_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, REDIS_REPLY_TYPE reply
// Kick off our command
if (cluster_send_slot(c, slot, cmd, cmd_len, reply_type TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to send command at a specific node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to send command at a specific node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -2495,8 +2392,7 @@ static void cluster_raw_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len)
/* Send it off */
if (cluster_send_slot(c, slot, cmd.c, cmd.len, TYPE_EOF TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't send command to node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't send command to node", 0);
efree(cmd.c);
efree(z_args);
RETURN_FALSE;
@@ -2515,7 +2411,7 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
{
redisCluster *c = GET_CONTEXT();
char *cmd, *pat = NULL, *key = NULL;
- strlen_t key_len = 0, pat_len = 0;
+ size_t key_len = 0, pat_len = 0;
int cmd_len, key_free = 0;
short slot;
zval *z_it;
@@ -2525,8 +2421,7 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
// Can't be in MULTI mode
if (!CLUSTER_IS_ATOMIC(c)) {
- zend_throw_exception(redis_cluster_exception_ce,
- "SCAN type commands can't be called in MULTI mode!", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("SCAN type commands can't be called in MULTI mode!", 0);
RETURN_FALSE;
}
@@ -2571,8 +2466,7 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
// Send it off
if (cluster_send_command(c, slot, cmd, cmd_len TSRMLS_CC) == FAILURE)
{
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't send SCAN command", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't send SCAN command", 0);
if (key_free) efree(key);
efree(cmd);
RETURN_FALSE;
@@ -2582,8 +2476,7 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
if (cluster_scan_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, type,
&it) == FAILURE)
{
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't read SCAN response", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't read SCAN response", 0);
if (key_free) efree(key);
efree(cmd);
RETURN_FALSE;
@@ -2608,7 +2501,7 @@ static void cluster_kscan_cmd(INTERNAL_FUNCTION_PARAMETERS,
PHP_METHOD(RedisCluster, scan) {
redisCluster *c = GET_CONTEXT();
char *cmd, *pat = NULL;
- strlen_t pat_len = 0;
+ size_t pat_len = 0;
int cmd_len;
short slot;
zval *z_it, *z_node;
@@ -2620,8 +2513,7 @@ PHP_METHOD(RedisCluster, scan) {
/* Can't be in MULTI mode */
if (!CLUSTER_IS_ATOMIC(c)) {
- zend_throw_exception(redis_cluster_exception_ce,
- "SCAN type commands can't be called in MULTI mode", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("SCAN type commands can't be called in MULTI mode", 0);
RETURN_FALSE;
}
@@ -2662,8 +2554,7 @@ PHP_METHOD(RedisCluster, scan) {
// Send it to the node in question
if (cluster_send_command(c, slot, cmd, cmd_len TSRMLS_CC) < 0)
{
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't send SCAN to node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't send SCAN to node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -2671,8 +2562,7 @@ PHP_METHOD(RedisCluster, scan) {
if (cluster_scan_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, TYPE_SCAN,
&it) == FAILURE || Z_TYPE_P(return_value)!=IS_ARRAY)
{
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't process SCAN response from node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't process SCAN response from node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -2767,7 +2657,7 @@ PHP_METHOD(RedisCluster, info) {
REDIS_REPLY_TYPE rtype;
char *cmd, *opt = NULL;
int cmd_len;
- strlen_t opt_len = 0;
+ size_t opt_len = 0;
void *ctx = NULL;
zval *z_arg;
@@ -2795,8 +2685,7 @@ PHP_METHOD(RedisCluster, info) {
rtype = CLUSTER_IS_ATOMIC(c) ? TYPE_BULK : TYPE_LINE;
if (cluster_send_slot(c, slot, cmd, cmd_len, rtype TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to send INFO command to specific node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to send INFO command to specific node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -2820,7 +2709,7 @@ PHP_METHOD(RedisCluster, client) {
redisCluster *c = GET_CONTEXT();
char *cmd, *opt = NULL, *arg = NULL;
int cmd_len;
- strlen_t opt_len, arg_len = 0;
+ size_t opt_len, arg_len = 0;
REDIS_REPLY_TYPE rtype;
zval *z_node;
short slot;
@@ -2869,8 +2758,7 @@ PHP_METHOD(RedisCluster, client) {
/* Attempt to write our command */
if (cluster_send_slot(c, slot, cmd, cmd_len, rtype TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to send CLIENT command to specific node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to send CLIENT command to specific node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -2948,8 +2836,7 @@ PHP_METHOD(RedisCluster, script) {
/* Send it off */
if (cluster_send_slot(c, slot, cmd.c, cmd.len, TYPE_EOF TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't send command to node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't send command to node", 0);
efree(cmd.c);
efree(z_args);
RETURN_FALSE;
@@ -3109,7 +2996,7 @@ PHP_METHOD(RedisCluster, echo) {
zval *z_arg;
char *cmd, *msg;
int cmd_len;
- strlen_t msg_len;
+ size_t msg_len;
short slot;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &z_arg, &msg,
@@ -3133,8 +3020,7 @@ PHP_METHOD(RedisCluster, echo) {
/* Send it off */
rtype = CLUSTER_IS_ATOMIC(c) ? TYPE_BULK : TYPE_LINE;
if (cluster_send_slot(c,slot,cmd,cmd_len,rtype TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to send commnad at the specificed node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to send commnad at the specificed node", 0);
efree(cmd);
RETURN_FALSE;
}
@@ -3187,8 +3073,7 @@ PHP_METHOD(RedisCluster, rawcommand) {
/* Direct the command */
rtype = CLUSTER_IS_ATOMIC(c) ? TYPE_EOF : TYPE_LINE;
if (cluster_send_slot(c,slot,cmd,cmd_len,rtype TSRMLS_CC) < 0) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to send command to the specified node", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to send command to the specified node", 0);
efree(cmd);
RETURN_FALSE;
}