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:
authormichael-grunder <michael.grunder@gmail.com>2019-02-09 08:31:47 +0300
committermichael-grunder <michael.grunder@gmail.com>2019-02-09 08:31:47 +0300
commitfa130a4bd46200d799f0659b709c8062c87f692b (patch)
treefdeb696c1e1ec9db02b765deefc38eaedd4188c9
parentf9928642b5e539bbdca43ec51ed9c9642cb42ded (diff)
PHP 7 exception and compiler warning fixes
PHP 7 removed TSRMLS_CC from zend_throw_exception* routines. Additionally this commit creates two simple wrapper macros for throwing Redis or RedisCluster exceptions so we don't duplicate as much code. Additionally there were a couple of minor compiler warnings printf type correctness fixed in this commit.
-rw-r--r--cluster_library.c33
-rw-r--r--library.c25
-rw-r--r--library.h6
-rw-r--r--redis.c13
-rw-r--r--redis_array.c2
-rw-r--r--redis_array_impl.c2
-rw-r--r--redis_cluster.c81
-rw-r--r--redis_commands.c2
8 files changed, 61 insertions, 103 deletions
diff --git a/cluster_library.c b/cluster_library.c
index bcc5fb07..43e0c1cf 100644
--- a/cluster_library.c
+++ b/cluster_library.c
@@ -974,9 +974,7 @@ PHP_REDIS_API int cluster_map_keyspace(redisCluster *c TSRMLS_DC) {
// Throw an exception if we couldn't map
if (!mapped) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Couldn't map cluster keyspace using any provided seed", 0
- TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Couldn't map cluster keyspace using any provided seed", 0);
return -1;
}
@@ -1355,9 +1353,7 @@ PHP_REDIS_API int cluster_send_slot(redisCluster *c, short slot, char *cmd,
* send it to this node yet */
if (c->flags->mode == MULTI && c->cmd_sock->mode != MULTI) {
if (cluster_send_multi(c, slot TSRMLS_CC) == -1) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to enter MULTI mode on requested slot",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to enter MULTI mode on requested slot", 0);
return -1;
}
}
@@ -1384,7 +1380,7 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
long msstart;
if (!SLOT(c, slot)) {
- zend_throw_exception_ex(redis_cluster_exception_ce, 0 TSRMLS_CC,
+ zend_throw_exception_ex(redis_cluster_exception_ce, 0,
"The slot %d is not covered by any node in this cluster", slot);
return -1;
}
@@ -1406,9 +1402,7 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
if (c->flags->mode == MULTI && CMD_SOCK(c)->mode != MULTI) {
/* We have to fail if we can't send MULTI to the node */
if (cluster_send_multi(c, slot TSRMLS_CC) == -1) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Unable to enter MULTI mode on requested slot",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Unable to enter MULTI mode on requested slot", 0);
return -1;
}
}
@@ -1417,9 +1411,7 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
* node until we find one that is available. */
if (cluster_sock_write(c, cmd, cmd_len, 0 TSRMLS_CC) == -1) {
/* We have to abort, as no nodes are reachable */
- zend_throw_exception(redis_cluster_exception_ce,
- "Can't communicate with any node in the cluster",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Can't communicate with any node in the cluster", 0);
return -1;
}
@@ -1433,9 +1425,7 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
if (resp == 1) {
/* Abort if we're in a transaction as it will be invalid */
if (c->flags->mode == MULTI) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Can't process MULTI sequence when cluster is resharding",
- 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("Can't process MULTI sequence when cluster is resharding", 0);
return -1;
}
@@ -1452,19 +1442,18 @@ PHP_REDIS_API short cluster_send_command(redisCluster *c, short slot, const char
// If we've detected the cluster is down, throw an exception
if (c->clusterdown) {
- zend_throw_exception(redis_cluster_exception_ce,
- "The Redis Cluster is down (CLUSTERDOWN)", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION("The Redis Cluster is down (CLUSTERDOWN)", 0);
return -1;
} else if (timedout || resp == -1) {
// Make sure the socket is reconnected, it such that it is in a clean state
redis_sock_disconnect(c->cmd_sock, 1 TSRMLS_CC);
if (timedout) {
- zend_throw_exception(redis_cluster_exception_ce,
- "Timed out attempting to find data in the correct node!", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION(
+ "Timed out attempting to find data in the correct node!", 0);
} else {
- zend_throw_exception(redis_cluster_exception_ce,
- "Error processing response from Redis node!", 0 TSRMLS_CC);
+ CLUSTER_THROW_EXCEPTION(
+ "Error processing response from Redis node!", 0);
}
return -1;
diff --git a/library.c b/library.c
index 26358e11..a58b7ee4 100644
--- a/library.c
+++ b/library.c
@@ -132,7 +132,7 @@ redis_error_throw(RedisSock *redis_sock TSRMLS_DC)
!REDIS_SOCK_ERRCMP_STATIC(redis_sock, "BUSYGROUP") &&
!REDIS_SOCK_ERRCMP_STATIC(redis_sock, "NOGROUP"))
{
- zend_throw_exception(redis_exception_ce, ZSTR_VAL(redis_sock->err), 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION( ZSTR_VAL(redis_sock->err), 0);
}
}
@@ -144,7 +144,7 @@ redis_check_eof(RedisSock *redis_sock, int no_throw TSRMLS_DC)
if (!redis_sock || !redis_sock->stream || redis_sock->status == REDIS_SOCK_STATUS_FAILED) {
if (!no_throw) {
- zend_throw_exception(redis_exception_ce, "Connection closed", 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION( "Connection closed", 0);
}
return -1;
}
@@ -208,7 +208,7 @@ redis_check_eof(RedisSock *redis_sock, int no_throw TSRMLS_DC)
redis_sock_disconnect(redis_sock, 1 TSRMLS_CC);
redis_sock->status = REDIS_SOCK_STATUS_FAILED;
if (!no_throw) {
- zend_throw_exception(redis_exception_ce, errmsg, 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION( errmsg, 0);
}
return -1;
}
@@ -461,8 +461,7 @@ redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes TSRMLS_DC)
/* Protect against reading too few bytes */
if (offset < nbytes) {
/* Error or EOF */
- zend_throw_exception(redis_exception_ce,
- "socket error on read socket", 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION("socket error on read socket", 0);
efree(reply);
return NULL;
}
@@ -515,9 +514,7 @@ redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
return estrndup(inbuf, *buf_len);
}
default:
- zend_throw_exception_ex(
- redis_exception_ce,
- 0 TSRMLS_CC,
+ zend_throw_exception_ex(redis_exception_ce, 0,
"protocol error, got '%c' as reply type byte\n",
inbuf[0]
);
@@ -674,7 +671,7 @@ int redis_cmd_append_sstr_long(smart_string *str, long append) {
*/
int redis_cmd_append_sstr_i64(smart_string *str, int64_t append) {
char nbuf[64];
- int len = snprintf(nbuf, sizeof(nbuf), "%lld", append);
+ int len = snprintf(nbuf, sizeof(nbuf), PRId64, append);
return redis_cmd_append_sstr(str, nbuf, len);
}
@@ -2257,8 +2254,7 @@ redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size,
redis_sock_disconnect(redis_sock, 1 TSRMLS_CC);
// Throw a read error exception
- zend_throw_exception(redis_exception_ce, "read error on connection",
- 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION( "read error on connection", 0);
return -1;
}
@@ -2283,8 +2279,7 @@ redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type,
// Attempt to read the reply-type byte
if((*reply_type = php_stream_getc(redis_sock->stream)) == EOF) {
- zend_throw_exception(redis_exception_ce, "socket error on read socket",
- 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION( "socket error on read socket", 0);
return -1;
}
@@ -2370,7 +2365,7 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, int elements, int status_s
if(redis_read_reply_type(redis_sock, &reply_type, &reply_info
TSRMLS_CC) < 0)
{
- zend_throw_exception_ex(redis_exception_ce, 0 TSRMLS_CC,
+ zend_throw_exception_ex(redis_exception_ce, 0,
"protocol error, couldn't parse MULTI-BULK response\n");
return FAILURE;
}
@@ -2449,7 +2444,7 @@ variant_reply_generic(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
}
break;
default:
- zend_throw_exception_ex(redis_exception_ce, 0 TSRMLS_CC,
+ zend_throw_exception_ex(redis_exception_ce, 0,
"protocol error, got '%c' as reply-type byte\n", reply_type);
return FAILURE;
}
diff --git a/library.h b/library.h
index a7a2f060..3028711c 100644
--- a/library.h
+++ b/library.h
@@ -14,6 +14,12 @@
#define REDIS_CMD_INIT_SSTR_STATIC(sstr, argc, keyword) \
redis_cmd_init_sstr(sstr, argc, keyword, sizeof(keyword)-1);
+#define REDIS_THROW_EXCEPTION(msg, code) \
+ zend_throw_exception(redis_exception_ce, (msg), code)
+
+#define CLUSTER_THROW_EXCEPTION(msg, code) \
+ zend_throw_exception(redis_cluster_exception_ce, (msg), code)
+
int redis_cmd_init_sstr(smart_string *str, int num_args, char *keyword, int keyword_len);
int redis_cmd_append_sstr(smart_string *str, char *append, int append_len);
int redis_cmd_append_sstr_int(smart_string *str, int append);
diff --git a/redis.c b/redis.c
index ec743733..e99527fa 100644
--- a/redis.c
+++ b/redis.c
@@ -592,7 +592,7 @@ redis_sock_get_instance(zval *id TSRMLS_DC, int no_throw)
}
// Throw an exception unless we've been requested not to
if (!no_throw) {
- zend_throw_exception(redis_exception_ce, "Redis server went away", 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION("Redis server went away", 0);
}
return NULL;
}
@@ -883,20 +883,17 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
if (timeout < 0L || timeout > INT_MAX) {
- zend_throw_exception(redis_exception_ce,
- "Invalid connect timeout", 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION("Invalid connect timeout", 0);
return FAILURE;
}
if (read_timeout < 0L || read_timeout > INT_MAX) {
- zend_throw_exception(redis_exception_ce,
- "Invalid read timeout", 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION("Invalid read timeout", 0);
return FAILURE;
}
if (retry_interval < 0L || retry_interval > INT_MAX) {
- zend_throw_exception(redis_exception_ce, "Invalid retry interval",
- 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION("Invalid retry interval", 0);
return FAILURE;
}
@@ -917,7 +914,7 @@ redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (redis_sock_server_open(redis->sock TSRMLS_CC) < 0) {
if (redis->sock->err) {
- zend_throw_exception(redis_exception_ce, ZSTR_VAL(redis->sock->err), 0 TSRMLS_CC);
+ REDIS_THROW_EXCEPTION(ZSTR_VAL(redis->sock->err), 0);
}
redis_free_socket(redis->sock);
redis->sock = NULL;
diff --git a/redis_array.c b/redis_array.c
index 1d989cb9..37b31484 100644
--- a/redis_array.c
+++ b/redis_array.c
@@ -1125,7 +1125,7 @@ PHP_METHOD(RedisArray, mset)
/* Generic handler for DEL or UNLINK which behave identically to phpredis */
static void ra_generic_del(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len) {
- zval *object, z_keys, z_fun, *data, z_ret, *z_tmp, *z_args;
+ zval *object, z_keys, z_fun, *data, z_ret, *z_args;
int i, n;
RedisArray *ra;
int *pos, argc = ZEND_NUM_ARGS(), *argc_each;
diff --git a/redis_array_impl.c b/redis_array_impl.c
index aeb08e20..918359c5 100644
--- a/redis_array_impl.c
+++ b/redis_array_impl.c
@@ -387,7 +387,7 @@ ra_make_continuum(zend_string **hosts, int nb_hosts)
for (i = 0; i < nb_hosts; ++i) {
for (j = 0; j < 40; ++j) {
- len = snprintf(host, sizeof(host), "%.*s-%u", ZSTR_LEN(hosts[i]), ZSTR_VAL(hosts[i]), j);
+ len = snprintf(host, sizeof(host), "%.*s-%u", (int)ZSTR_LEN(hosts[i]), ZSTR_VAL(hosts[i]), j);
PHP_MD5Init(&ctx);
PHP_MD5Update(&ctx, host, len);
PHP_MD5Final(digest, &ctx);
diff --git a/redis_cluster.c b/redis_cluster.c
index fd42db36..63e4bdcf 100644
--- a/redis_cluster.c
+++ b/redis_cluster.c
@@ -351,20 +351,17 @@ static void redis_cluster_init(redisCluster *c, HashTable *ht_seeds, double time
{
// 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) {
@@ -408,7 +405,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;
}
@@ -502,9 +499,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
@@ -612,8 +607,7 @@ static int get_key_val_ht(redisCluster *c, HashTable *ht, HashPosition *ptr,
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;
}
@@ -623,8 +617,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;
}
@@ -643,8 +636,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;
}
@@ -1849,8 +1841,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;
}
@@ -2049,9 +2040,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;
}
@@ -2062,8 +2051,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);
@@ -2139,10 +2127,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);
@@ -2260,8 +2245,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;
}
@@ -2304,8 +2288,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;
}
@@ -2369,8 +2352,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;
@@ -2399,8 +2381,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;
}
@@ -2445,8 +2426,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;
@@ -2456,8 +2436,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;
@@ -2494,8 +2473,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;
}
@@ -2536,8 +2514,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;
}
@@ -2545,8 +2522,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;
}
@@ -2669,8 +2645,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;
}
@@ -2743,8 +2718,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;
}
@@ -2822,8 +2796,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;
@@ -2997,8 +2970,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;
}
@@ -3051,8 +3023,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;
}
diff --git a/redis_commands.c b/redis_commands.c
index 078d12c0..263e3516 100644
--- a/redis_commands.c
+++ b/redis_commands.c
@@ -4027,7 +4027,7 @@ void redis_unserialize_handler(INTERNAL_FUNCTION_PARAMETERS,
zval zv, *z_ret = &zv;
if (!redis_unserialize(redis_sock, value, value_len, z_ret TSRMLS_CC)) {
// Badly formed input, throw an execption
- zend_throw_exception(ex, "Invalid serialized data, or unserialization error", 0 TSRMLS_CC);
+ zend_throw_exception(ex, "Invalid serialized data, or unserialization error", 0);
RETURN_FALSE;
}
RETURN_ZVAL(z_ret, 1, 0);