Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c4447e

Browse files
committed
Merge branch 'master' into serializer
Conflicts: redis.c
2 parents 9cb2dc2 + a35396e commit 5c4447e

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

library.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,11 @@ PHPAPI int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo
874874

875875
IF_MULTI_OR_PIPELINE() {
876876
add_next_index_zval(z_tab, z_multi_result);
877+
} else {
878+
*return_value = *z_multi_result;
879+
efree(z_multi_result);
877880
}
878-
879-
*return_value = *z_multi_result;
880881
//zval_copy_ctor(return_value);
881-
efree(z_multi_result);
882882
return 0;
883883
}
884884

redis.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ PHP_METHOD(Redis, __construct)
362362
PHP_METHOD(Redis, connect)
363363
{
364364
zval *object;
365+
zval **socket;
365366
int host_len, id;
366367
char *host = NULL;
367368
long port = -1;
@@ -384,6 +385,16 @@ PHP_METHOD(Redis, connect)
384385
port = 6379;
385386
}
386387

388+
/* if there is a redis sock already we have to remove it from the list */
389+
if (redis_sock_get(object, &redis_sock TSRMLS_CC) > 0) {
390+
if (zend_hash_find(Z_OBJPROP_P(object), "socket",
391+
sizeof("socket"), (void **) &socket) == FAILURE) {
392+
/* maybe there is a socket but the id isn't known.. what to do? */
393+
} else {
394+
zend_list_delete(Z_LVAL_PP(socket)); /* the refcount should be decreased and the detructor called */
395+
}
396+
}
397+
387398
redis_sock = redis_sock_create(host, host_len, port, timeout);
388399

389400
if (redis_sock_server_open(redis_sock, 1 TSRMLS_CC) < 0) {
@@ -4557,6 +4568,7 @@ PHP_METHOD(Redis, slaveof)
45574568
}
45584569
/* }}} */
45594570

4571+
<<<<<<< HEAD
45604572
/* {{{ proto string Redis::getOption($option)
45614573
*/
45624574
PHP_METHOD(Redis, getOption) {
@@ -4624,5 +4636,5 @@ PHP_METHOD(Redis, setOptions) {
46244636
}
46254637
/* }}} */
46264638

4627-
/* vim: set tabstop=4 expandtab: */
4639+
/* vim: set tabstop=4 softtabstop=4 noexpandtab shiftwidth=4: */
46284640

tests/TestRedis.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,7 @@ protected function sequence($mode) {
19081908
$this->assertTrue($ret == array());
19091909

19101910
// ttl, mget, mset, msetnx, expire, expireAt
1911+
$this->redis->delete('key');
19111912
$ret = $this->redis->multi($mode)
19121913
->ttl('key')
19131914
->mget(array('key1', 'key2', 'key3'))

0 commit comments

Comments
 (0)