@@ -362,6 +362,7 @@ PHP_METHOD(Redis, __construct)
362362PHP_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 */ 
45624574PHP_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
0 commit comments