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:
authorPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2016-12-13 16:47:35 +0300
committerPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2016-12-13 18:39:04 +0300
commit37d8bfde060247e695e6c2bd04bc12e8a6efc094 (patch)
tree40dbc0b4fa23ecbe2b42b5c483c2705d3dea5718 /redis_array.c
parent75ff50236ee24627bfaea684ff52ad89eae00faa (diff)
refactoring
Diffstat (limited to 'redis_array.c')
-rw-r--r--redis_array.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/redis_array.c b/redis_array.c
index bf6d1a96..fad18284 100644
--- a/redis_array.c
+++ b/redis_array.c
@@ -329,14 +329,10 @@ PHP_METHOD(RedisArray, __construct)
static void
ra_forward_call(INTERNAL_FUNCTION_PARAMETERS, RedisArray *ra, const char *cmd, int cmd_len, zval *z_args, zval *z_new_target) {
- zval *zp_tmp, z_tmp;
+ zval z_tmp, z_fun, *redis_inst, *z_callargs, *zp_tmp;
char *key = NULL; /* set to avoid "unused-but-set-variable" */
- int i, key_len = 0;
- zval *redis_inst;
- zval z_fun, *z_callargs;
+ int i, key_len = 0, argc;
HashTable *h_args;
-
- int argc;
zend_bool b_write_cmd = 0;
h_args = Z_ARRVAL_P(z_args);
@@ -400,19 +396,21 @@ ra_forward_call(INTERNAL_FUNCTION_PARAMETERS, RedisArray *ra, const char *cmd, i
} else { /* call directly through. */
call_user_function(&redis_ce->function_table, redis_inst, &z_fun, return_value, argc, z_callargs);
- /* check if we have an error. */
- if(RA_CALL_FAILED(return_value,cmd) && ra->prev && !b_write_cmd) { /* there was an error reading, try with prev ring. */
- /* Free previous return value */
- zval_dtor(return_value);
+ if (!b_write_cmd) {
+ /* check if we have an error. */
+ if (ra->prev && RA_CALL_FAILED(return_value, cmd)) { /* there was an error reading, try with prev ring. */
+ /* Free previous return value */
+ zval_dtor(return_value);
- /* ERROR, FALLBACK TO PREVIOUS RING and forward a reference to the first redis instance we were looking at. */
- ra_forward_call(INTERNAL_FUNCTION_PARAM_PASSTHRU, ra->prev, cmd, cmd_len, z_args, z_new_target?z_new_target:redis_inst);
- }
+ /* ERROR, FALLBACK TO PREVIOUS RING and forward a reference to the first redis instance we were looking at. */
+ ra_forward_call(INTERNAL_FUNCTION_PARAM_PASSTHRU, ra->prev, cmd, cmd_len, z_args, z_new_target ? z_new_target : redis_inst);
+ }
- /* Autorehash if the key was found on the previous node if this is a read command and auto rehashing is on */
- if(!RA_CALL_FAILED(return_value,cmd) && !b_write_cmd && z_new_target && ra->auto_rehash) { /* move key from old ring to new ring */
- ra_move_key(key, key_len, redis_inst, z_new_target TSRMLS_CC);
- }
+ /* Autorehash if the key was found on the previous node if this is a read command and auto rehashing is on */
+ if (ra->auto_rehash && z_new_target && !RA_CALL_FAILED(return_value, cmd)) { /* move key from old ring to new ring */
+ ra_move_key(key, key_len, redis_inst, z_new_target TSRMLS_CC);
+ }
+ }
}
/* cleanup */