Skip to content

Commit

Permalink
Remove redis_send_discard duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
yatsukhnenko committed Jul 12, 2017
1 parent f8de702 commit ea15ce2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
22 changes: 0 additions & 22 deletions library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,28 +1527,6 @@ PHP_REDIS_API int redis_sock_disconnect(RedisSock *redis_sock TSRMLS_DC)
return 0;
}

PHP_REDIS_API void redis_send_discard(INTERNAL_FUNCTION_PARAMETERS,
RedisSock *redis_sock)
{
char *cmd;
int response_len, cmd_len;
char * response;

cmd_len = redis_spprintf(redis_sock, NULL TSRMLS_CC, &cmd, "DISCARD", "");

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

if ((response = redis_sock_read(redis_sock, &response_len TSRMLS_CC))
== NULL)
{
RETURN_FALSE;
}

RETVAL_BOOL(response_len == 3 && strncmp(response, "+OK", 3) == 0);
efree(response);
}

/**
* redis_sock_set_err
*/
Expand Down
1 change: 0 additions & 1 deletion library.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ PHP_REDIS_API void redis_stream_close(RedisSock *redis_sock TSRMLS_DC);
PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock, int no_throw TSRMLS_DC);
PHP_REDIS_API RedisSock *redis_sock_get(zval *id TSRMLS_DC, int nothrow);
PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock);
PHP_REDIS_API void redis_send_discard(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock);
PHP_REDIS_API void redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len);

PHP_REDIS_API int
Expand Down
8 changes: 5 additions & 3 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,9 @@ PHP_REDIS_API zend_class_entry *redis_get_exception_base(int root TSRMLS_DC)
}

/* Send a static DISCARD in case we're in MULTI mode. */
static int send_discard_static(RedisSock *redis_sock TSRMLS_DC) {
static int
redis_send_discard(RedisSock *redis_sock TSRMLS_DC)
{
int result = FAILURE;
char *cmd, *resp;
int resp_len, cmd_len;
Expand Down Expand Up @@ -1255,7 +1257,7 @@ PHP_METHOD(Redis,__destruct) {
IF_MULTI() {
// Discard any multi commands, and free any callbacks that have been
// queued
send_discard_static(redis_sock TSRMLS_CC);
redis_send_discard(redis_sock TSRMLS_CC);
free_reply_callbacks(redis_sock);
}
}
Expand Down Expand Up @@ -2673,7 +2675,7 @@ PHP_METHOD(Redis, discard)

redis_sock->mode = ATOMIC;
free_reply_callbacks(redis_sock);
redis_send_discard(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock);
RETURN_BOOL(redis_send_discard(redis_sock TSRMLS_CC) == SUCCESS);
}

/* redis_sock_read_multibulk_multi_reply */
Expand Down

0 comments on commit ea15ce2

Please sign in to comment.