@@ -34,7 +34,7 @@ PHPAPI void redis_stream_close(RedisSock *redis_sock TSRMLS_DC) {
3434 }
3535}
3636
37- PHPAPI int redis_check_eof (RedisSock * redis_sock TSRMLS_DC )
37+ PHPAPI int redis_check_eof (RedisSock * redis_sock , int no_throw TSRMLS_DC )
3838{
3939 int eof ;
4040 int count = 0 ;
@@ -54,8 +54,10 @@ PHPAPI int redis_check_eof(RedisSock *redis_sock TSRMLS_DC)
5454 redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
5555 redis_sock -> watching = 0 ;
5656 }
57- zend_throw_exception (redis_exception_ce , "Connection lost" ,
58- 0 TSRMLS_CC );
57+ if (!no_throw ) {
58+ zend_throw_exception (redis_exception_ce , "Connection lost" ,
59+ 0 TSRMLS_CC );
60+ }
5961 return -1 ;
6062 }
6163 if (redis_sock -> stream ) { /* close existing stream before reconnecting */
@@ -329,7 +331,7 @@ redis_sock_read_multibulk_reply_zval(INTERNAL_FUNCTION_PARAMETERS,
329331 int numElems ;
330332 zval * z_tab ;
331333
332- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
334+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
333335 return NULL ;
334336 }
335337
@@ -368,7 +370,7 @@ PHPAPI char *redis_sock_read_bulk_reply(RedisSock *redis_sock,
368370
369371 char * reply ;
370372
371- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
373+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
372374 return NULL ;
373375 }
374376
@@ -409,7 +411,7 @@ PHPAPI char *redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
409411 char * resp = NULL ;
410412 size_t err_len ;
411413
412- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
414+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
413415 return NULL ;
414416 }
415417
@@ -1133,7 +1135,7 @@ redis_sock_read_multibulk_reply_zipped_with_flag(INTERNAL_FUNCTION_PARAMETERS,
11331135 int numElems ;
11341136 zval * z_multi_result ;
11351137
1136- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1138+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
11371139 return -1 ;
11381140 }
11391141 if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
@@ -1551,7 +1553,7 @@ PHPAPI int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS,
15511553 int numElems ;
15521554 zval * z_multi_result ;
15531555
1554- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1556+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
15551557 return -1 ;
15561558 }
15571559 if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
@@ -1602,7 +1604,7 @@ PHPAPI int redis_sock_read_multibulk_reply_raw(INTERNAL_FUNCTION_PARAMETERS,
16021604 int numElems ;
16031605 zval * z_multi_result ;
16041606
1605- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1607+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
16061608 return -1 ;
16071609 }
16081610 if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
@@ -1691,7 +1693,7 @@ PHPAPI int redis_sock_read_multibulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS,
16911693
16921694 zval * * z_keys = ctx ;
16931695
1694- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1696+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
16951697 return -1 ;
16961698 }
16971699 if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
@@ -1763,7 +1765,7 @@ PHPAPI int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz
17631765 0 TSRMLS_CC );
17641766 return -1 ;
17651767 }
1766- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1768+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
17671769 return -1 ;
17681770 }
17691771 return php_stream_write (redis_sock -> stream , cmd , sz );
@@ -1953,7 +1955,7 @@ redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size,
19531955 size_t * line_size TSRMLS_DC )
19541956{
19551957 // Handle EOF
1956- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1958+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
19571959 return -1 ;
19581960 }
19591961
@@ -1986,7 +1988,7 @@ redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type,
19861988 int * reply_info TSRMLS_DC )
19871989{
19881990 // Make sure we haven't lost the connection, even trying to reconnect
1989- if (-1 == redis_check_eof (redis_sock TSRMLS_CC )) {
1991+ if (-1 == redis_check_eof (redis_sock , 0 TSRMLS_CC )) {
19901992 // Failure
19911993 return -1 ;
19921994 }
0 commit comments