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

Skip to content

Commit f1a85b3

Browse files
authored
Merge pull request phpredis#1032 from yatsukhnenko/issue.504
Issue phpredis#504
2 parents d22e7f5 + c7ab55a commit f1a85b3

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

redis.c

+17-7
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,8 @@ static void redis_destructor_redis_sock(zend_resource * rsrc TSRMLS_DC)
431431
redis_free_socket(redis_sock);
432432
}
433433

434-
/**
435-
* redis_sock_get
436-
*/
437-
PHP_REDIS_API int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC,
438-
int no_throw)
434+
static zend_always_inline int
435+
redis_sock_get_instance(zval *id, RedisSock **redis_sock TSRMLS_DC, int no_throw)
439436
{
440437
zval *socket;
441438

@@ -466,6 +463,19 @@ PHP_REDIS_API int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC,
466463
}
467464
return -1;
468465
}
466+
return 0;
467+
}
468+
469+
/**
470+
* redis_sock_get
471+
*/
472+
PHP_REDIS_API int
473+
redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC, int no_throw)
474+
{
475+
if (redis_sock_get_instance(id, redis_sock TSRMLS_CC, no_throw) < 0) {
476+
return -1;
477+
}
478+
469479
if ((*redis_sock)->lazy_connect)
470480
{
471481
(*redis_sock)->lazy_connect = 0;
@@ -2670,7 +2680,7 @@ PHP_METHOD(Redis, object)
26702680
PHP_METHOD(Redis, getOption) {
26712681
RedisSock *redis_sock;
26722682

2673-
if (redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
2683+
if (redis_sock_get_instance(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
26742684
RETURN_FALSE;
26752685
}
26762686

@@ -2683,7 +2693,7 @@ PHP_METHOD(Redis, getOption) {
26832693
PHP_METHOD(Redis, setOption) {
26842694
RedisSock *redis_sock;
26852695

2686-
if(redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 0)<0) {
2696+
if (redis_sock_get_instance(getThis(), &redis_sock TSRMLS_CC, 0) < 0) {
26872697
RETURN_FALSE;
26882698
}
26892699

0 commit comments

Comments
 (0)