Skip to content

Commit

Permalink
Dead code generic_unsubscribe_cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukhnenko authored and michael-grunder committed Oct 11, 2019
1 parent 4ff9bd7 commit 8ee4abb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
9 changes: 0 additions & 9 deletions php_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,8 @@ typedef void (*ResultCallback)(INTERNAL_FUNCTION_PARAMETERS,

PHP_REDIS_API int redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent);

PHP_REDIS_API void generic_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, char *sub_cmd);

PHP_REDIS_API void generic_unsubscribe_cmd(INTERNAL_FUNCTION_PARAMETERS,
char *unsub_cmd);

PHP_REDIS_API int redis_response_enqueued(RedisSock *redis_sock);

PHP_REDIS_API int get_flag(zval *object);

PHP_REDIS_API void set_flag(zval *object, int new_flag);

PHP_REDIS_API int redis_sock_read_multibulk_multi_reply_loop(
INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab,
int numElems);
Expand Down
67 changes: 0 additions & 67 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2622,73 +2622,6 @@ PHP_METHOD(Redis, subscribe) {
* );
**/

PHP_REDIS_API void generic_unsubscribe_cmd(INTERNAL_FUNCTION_PARAMETERS,
char *unsub_cmd)
{
zval *object, *array, *data;
HashTable *arr_hash;
RedisSock *redis_sock;
char *cmd = "", *old_cmd = NULL;
int cmd_len, array_count;

int i;
zval z_tab, *z_channel;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa",
&object, redis_ce, &array) == FAILURE) {
RETURN_FALSE;
}
if ((redis_sock = redis_sock_get(object, 0)) == NULL) {
RETURN_FALSE;
}

arr_hash = Z_ARRVAL_P(array);
array_count = zend_hash_num_elements(arr_hash);

if (array_count == 0) {
RETURN_FALSE;
}

ZEND_HASH_FOREACH_VAL(arr_hash, data) {
ZVAL_DEREF(data);
if (Z_TYPE_P(data) == IS_STRING) {
char *old_cmd = NULL;
if(*cmd) {
old_cmd = cmd;
}
spprintf(&cmd, 0, "%s %s", cmd, Z_STRVAL_P(data));
if(old_cmd) {
efree(old_cmd);
}
}
} ZEND_HASH_FOREACH_END();

old_cmd = cmd;
cmd_len = spprintf(&cmd, 0, "%s %s\r\n", unsub_cmd, cmd);
efree(old_cmd);

SOCKET_WRITE_COMMAND(redis_sock, cmd, cmd_len)
efree(cmd);

array_init(return_value);
for (i = 1; i <= array_count; i++) {
redis_sock_read_multibulk_reply_zval(
INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, &z_tab);

if (Z_TYPE(z_tab) == IS_ARRAY) {
if ((z_channel = zend_hash_index_find(Z_ARRVAL(z_tab), 1)) == NULL) {
RETURN_FALSE;
}
add_assoc_bool(return_value, Z_STRVAL_P(z_channel), 1);
} else {
//error
zval_dtor(&z_tab);
RETURN_FALSE;
}
zval_dtor(&z_tab);
}
}

PHP_METHOD(Redis, unsubscribe)
{
REDIS_PROCESS_KW_CMD("UNSUBSCRIBE", redis_unsubscribe_cmd,
Expand Down

0 comments on commit 8ee4abb

Please sign in to comment.