Destroy all tabs :-)

This commit is contained in:
michael-grunder
2017-09-28 15:44:18 -07:00
parent 6a53cb99ba
commit 345fc7fc9f
6 changed files with 1067 additions and 1066 deletions
+65 -64
View File
@@ -1517,16 +1517,17 @@ PHP_REDIS_API int redis_sock_disconnect(RedisSock *redis_sock TSRMLS_DC)
redis_sock->dbNumber = 0;
if (redis_sock->stream != NULL) {
redis_sock->status = REDIS_SOCK_STATUS_DISCONNECTED;
redis_sock->watching = 0;
redis_sock->status = REDIS_SOCK_STATUS_DISCONNECTED;
redis_sock->watching = 0;
/* Stil valid? */
if (!redis_sock->persistent) {
php_stream_close(redis_sock->stream);
}
redis_sock->stream = NULL;
/* Stil valid? */
if (!redis_sock->persistent) {
php_stream_close(redis_sock->stream);
}
return 1;
redis_sock->stream = NULL;
return 1;
}
return 0;
@@ -1967,12 +1968,12 @@ redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size,
return -1;
}
/* We don't need \r\n */
*line_size-=2;
buf[*line_size]='\0';
/* We don't need \r\n */
*line_size-=2;
buf[*line_size]='\0';
/* Success! */
return 0;
/* Success! */
return 0;
}
PHP_REDIS_API int
@@ -2001,17 +2002,17 @@ redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type,
// Buffer to hold size information
char inbuf[255];
/* Read up to our newline */
if(php_stream_gets(redis_sock->stream, inbuf, sizeof(inbuf)) == NULL) {
return -1;
}
/* Read up to our newline */
if (php_stream_gets(redis_sock->stream, inbuf, sizeof(inbuf)) == NULL) {
return -1;
}
/* Set our size response */
*reply_info = atol(inbuf);
}
/* Set our size response */
*reply_info = atol(inbuf);
}
/* Success! */
return 0;
/* Success! */
return 0;
}
/*
@@ -2025,26 +2026,26 @@ redis_read_variant_line(RedisSock *redis_sock, REDIS_REPLY_TYPE reply_type,
char inbuf[4096];
size_t line_size;
/* Attempt to read our single line reply */
if(redis_sock_gets(redis_sock, inbuf, sizeof(inbuf), &line_size TSRMLS_CC) < 0) {
return -1;
}
/* Attempt to read our single line reply */
if(redis_sock_gets(redis_sock, inbuf, sizeof(inbuf), &line_size TSRMLS_CC) < 0) {
return -1;
}
// If this is an error response, check if it is a SYNC error, and throw in
// that case
if(reply_type == TYPE_ERR) {
/* Set our last error */
redis_sock_set_err(redis_sock, inbuf, line_size);
/* Set our last error */
redis_sock_set_err(redis_sock, inbuf, line_size);
/* Handle throwable errors */
redis_error_throw(redis_sock TSRMLS_CC);
/* Set our response to FALSE */
ZVAL_FALSE(z_ret);
} else {
/* Set our response to TRUE */
ZVAL_TRUE(z_ret);
}
/* Set our response to FALSE */
ZVAL_FALSE(z_ret);
} else {
/* Set our response to TRUE */
ZVAL_TRUE(z_ret);
}
return 0;
}
@@ -2056,11 +2057,11 @@ redis_read_variant_bulk(RedisSock *redis_sock, int size, zval *z_ret
// Attempt to read the bulk reply
char *bulk_resp = redis_sock_read_bulk_reply(redis_sock, size TSRMLS_CC);
/* Set our reply to FALSE on failure, and the string on success */
if(bulk_resp == NULL) {
ZVAL_FALSE(z_ret);
return -1;
}
/* Set our reply to FALSE on failure, and the string on success */
if(bulk_resp == NULL) {
ZVAL_FALSE(z_ret);
return -1;
}
ZVAL_STRINGL(z_ret, bulk_resp, size);
efree(bulk_resp);
return 0;
@@ -2126,9 +2127,9 @@ redis_read_multibulk_recursive(RedisSock *redis_sock, int elements, zval *z_ret
break;
}
/* Decrement our element counter */
elements--;
}
/* Decrement our element counter */
elements--;
}
return 0;
}
@@ -2152,21 +2153,21 @@ redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
#if (PHP_MAJOR_VERSION < 7)
MAKE_STD_ZVAL(z_ret);
#endif
/* Switch based on our top level reply type */
switch(reply_type) {
case TYPE_ERR:
case TYPE_LINE:
redis_read_variant_line(redis_sock, reply_type, z_ret TSRMLS_CC);
break;
case TYPE_INT:
ZVAL_LONG(z_ret, reply_info);
break;
case TYPE_BULK:
redis_read_variant_bulk(redis_sock, reply_info, z_ret TSRMLS_CC);
break;
case TYPE_MULTIBULK:
/* Initialize an array for our multi-bulk response */
array_init(z_ret);
/* Switch based on our top level reply type */
switch(reply_type) {
case TYPE_ERR:
case TYPE_LINE:
redis_read_variant_line(redis_sock, reply_type, z_ret TSRMLS_CC);
break;
case TYPE_INT:
ZVAL_LONG(z_ret, reply_info);
break;
case TYPE_BULK:
redis_read_variant_bulk(redis_sock, reply_info, z_ret TSRMLS_CC);
break;
case TYPE_MULTIBULK:
/* Initialize an array for our multi-bulk response */
array_init(z_ret);
// If we've got more than zero elements, parse our multi bulk
// response recursively
@@ -2185,15 +2186,15 @@ redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
return FAILURE;
}
IF_NOT_ATOMIC() {
add_next_index_zval(z_tab, z_ret);
} else {
/* Set our return value */
IF_NOT_ATOMIC() {
add_next_index_zval(z_tab, z_ret);
} else {
/* Set our return value */
RETVAL_ZVAL(z_ret, 0, 1);
}
}
/* Success */
return 0;
/* Success */
return 0;
}
/* vim: set tabstop=4 softtabstop=4 expandtab shiftwidth=4: */
+28 -28
View File
@@ -2895,7 +2895,7 @@ PHP_METHOD(Redis, evalsha) {
PHP_REDIS_API int
redis_build_script_exists_cmd(char **ret, zval *argv, int argc) {
smart_string cmd = {0};
smart_string cmd = {0};
zend_string *zstr;
int i;
@@ -2909,9 +2909,9 @@ redis_build_script_exists_cmd(char **ret, zval *argv, int argc) {
zend_string_release(zstr);
}
/* Success */
/* Success */
*ret = cmd.c;
return cmd.len;
return cmd.len;
}
/* {{{ proto status Redis::script('flush')
@@ -2925,24 +2925,24 @@ PHP_METHOD(Redis, script) {
int cmd_len, argc;
char *cmd;
/* Attempt to grab our socket */
/* Attempt to grab our socket */
if ((redis_sock = redis_sock_get(getThis() TSRMLS_CC, 0)) == NULL) {
RETURN_FALSE;
}
RETURN_FALSE;
}
/* Grab the number of arguments */
argc = ZEND_NUM_ARGS();
/* Grab the number of arguments */
argc = ZEND_NUM_ARGS();
/* Allocate an array big enough to store our arguments */
z_args = emalloc(argc * sizeof(zval));
/* Allocate an array big enough to store our arguments */
z_args = emalloc(argc * sizeof(zval));
/* Make sure we can grab our arguments, we have a string directive */
if (zend_get_parameters_array(ht, argc, z_args) == FAILURE ||
(argc < 1 || Z_TYPE(z_args[0]) != IS_STRING))
{
efree(z_args);
RETURN_FALSE;
}
/* Make sure we can grab our arguments, we have a string directive */
if (zend_get_parameters_array(ht, argc, z_args) == FAILURE ||
(argc < 1 || Z_TYPE(z_args[0]) != IS_STRING))
{
efree(z_args);
RETURN_FALSE;
}
// Branch based on the directive
if(!strcasecmp(Z_STRVAL(z_args[0]), "flush") ||
@@ -2964,17 +2964,17 @@ PHP_METHOD(Redis, script) {
// Format our SCRIPT LOAD command
cmd_len = REDIS_SPPRINTF(&cmd, "SCRIPT", "ss", "LOAD", 4, Z_STRVAL(z_args[1]),
Z_STRLEN(z_args[1]));
} else if(!strcasecmp(Z_STRVAL(z_args[0]), "exists")) {
/* Construct our SCRIPT EXISTS command */
cmd_len = redis_build_script_exists_cmd(&cmd, &(z_args[1]), argc-1);
} else {
/* Unknown directive */
efree(z_args);
RETURN_FALSE;
}
} else if(!strcasecmp(Z_STRVAL(z_args[0]), "exists")) {
/* Construct our SCRIPT EXISTS command */
cmd_len = redis_build_script_exists_cmd(&cmd, &(z_args[1]), argc-1);
} else {
/* Unknown directive */
efree(z_args);
RETURN_FALSE;
}
/* Free our alocated arguments */
efree(z_args);
/* Free our alocated arguments */
efree(z_args);
// Kick off our request
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
@@ -3066,7 +3066,7 @@ PHP_METHOD(Redis, getLastError) {
RETURN_FALSE;
}
/* Return our last error or NULL if we don't have one */
/* Return our last error or NULL if we don't have one */
if (redis_sock->err) {
RETURN_STRINGL(ZSTR_VAL(redis_sock->err), ZSTR_LEN(redis_sock->err));
}
+544 -544
View File
File diff suppressed because it is too large Load Diff
+13 -13
View File
@@ -39,20 +39,20 @@ PHP_METHOD(RedisArray, unwatch);
typedef struct RedisArray_ {
int count;
char **hosts; /* array of host:port strings */
zval *redis; /* array of Redis instances */
zval *z_multi_exec; /* Redis instance to be used in multi-exec */
zend_bool index; /* use per-node index */
zend_bool auto_rehash; /* migrate keys on read operations */
zend_bool pconnect; /* should we use pconnect */
zval z_fun; /* key extractor, callable */
zval z_dist; /* key distributor, callable */
HashTable *pure_cmds; /* hash table */
double connect_timeout; /* socket connect timeout */
double read_timeout; /* socket read timeout */
int count;
char **hosts; /* array of host:port strings */
zval *redis; /* array of Redis instances */
zval *z_multi_exec; /* Redis instance to be used in multi-exec */
zend_bool index; /* use per-node index */
zend_bool auto_rehash; /* migrate keys on read operations */
zend_bool pconnect; /* should we use pconnect */
zval z_fun; /* key extractor, callable */
zval z_dist; /* key distributor, callable */
HashTable *pure_cmds; /* hash table */
double connect_timeout; /* socket connect timeout */
double read_timeout; /* socket read timeout */
struct RedisArray_ *prev;
struct RedisArray_ *prev;
} RedisArray;
#if (PHP_MAJOR_VERSION < 7)
+394 -394
View File
File diff suppressed because it is too large Load Diff
+23 -23
View File
@@ -332,14 +332,14 @@ create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
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);
object_properties_init(&cluster->std, class_type);
memcpy(&RedisCluster_handlers, zend_get_std_object_handlers(), sizeof(RedisCluster_handlers));
RedisCluster_handlers.offset = XtOffsetOf(redisCluster, std);
RedisCluster_handlers.free_obj = free_cluster_context;
cluster->std.handlers = &RedisCluster_handlers;
cluster->std.handlers = &RedisCluster_handlers;
return &cluster->std;
return &cluster->std;
#endif
}
@@ -606,21 +606,21 @@ static int get_key_val_ht(redisCluster *c, HashTable *ht, HashPosition *ptr,
clusterKeyValHT *kv TSRMLS_DC)
{
zval *z_val;
zend_ulong idx;
zend_ulong idx;
// 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);
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);
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:
@@ -743,7 +743,7 @@ static int cluster_mkey_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
// it's the first iteration every time, needlessly
zend_hash_internal_pointer_reset_ex(ht_arr, &ptr);
if(get_key_ht(c, ht_arr, &ptr, &kv TSRMLS_CC)<0) {
efree(z_args);
efree(z_args);
return -1;
}
@@ -765,7 +765,7 @@ static int cluster_mkey_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
zend_hash_destroy(ht_arr);
efree(ht_arr);
}
efree(z_args);
efree(z_args);
return -1;
}
@@ -780,7 +780,7 @@ static int cluster_mkey_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
zend_hash_destroy(ht_arr);
efree(ht_arr);
}
efree(z_args);
efree(z_args);
return -1;
}
}
@@ -797,7 +797,7 @@ static int cluster_mkey_cmd(INTERNAL_FUNCTION_PARAMETERS, char *kw, int kw_len,
zend_hash_move_forward_ex(ht_arr, &ptr);
}
efree(z_args);
efree(z_args);
// If we've got straggler(s) process them
if(mc.argc > 0) {
@@ -2246,10 +2246,10 @@ cluster_cmd_get_slot(redisCluster *c, zval *z_arg TSRMLS_DC)
zend_string_release(zstr);
if(key_free) efree(key);
} else if (Z_TYPE_P(z_arg) == IS_ARRAY &&
(z_host = zend_hash_index_find(Z_ARRVAL_P(z_arg), 0)) != NULL &&
(z_port = zend_hash_index_find(Z_ARRVAL_P(z_arg), 1)) != NULL &&
Z_TYPE_P(z_host) == IS_STRING && Z_TYPE_P(z_port) == IS_LONG
) {
(z_host = zend_hash_index_find(Z_ARRVAL_P(z_arg), 0)) != NULL &&
(z_port = zend_hash_index_find(Z_ARRVAL_P(z_arg), 1)) != NULL &&
Z_TYPE_P(z_host) == IS_STRING && Z_TYPE_P(z_port) == IS_LONG
) {
/* Attempt to find this specific node by host:port */
slot = cluster_find_slot(c,(const char *)Z_STRVAL_P(z_host),
(unsigned short)Z_LVAL_P(z_port));