@@ -21,16 +21,22 @@ PHPAPI int redis_check_eof(RedisSock *redis_sock TSRMLS_DC)
21
21
while (eof ) {
22
22
if (count ++ == 10 ) { /* too many failures */
23
23
if (redis_sock -> stream ) { /* close stream if still here */
24
+ if (!redis_sock -> persistent ) { /* never ever close persistent streams by ourself */
24
25
php_stream_close (redis_sock -> stream );
26
+ }
25
27
redis_sock -> stream = NULL ;
28
+ redis_sock -> mode = ATOMIC ;
26
29
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
27
30
}
28
31
zend_throw_exception (redis_exception_ce , "Connection lost" , 0 TSRMLS_CC );
29
32
return -1 ;
30
33
}
31
34
if (redis_sock -> stream ) { /* close existing stream before reconnecting */
32
- php_stream_close (redis_sock -> stream );
35
+ if (!redis_sock -> persistent ) {
36
+ php_stream_close (redis_sock -> stream );
37
+ }
33
38
redis_sock -> stream = NULL ;
39
+ redis_sock -> mode = ATOMIC ;
34
40
}
35
41
redis_sock_connect (redis_sock TSRMLS_CC ); /* reconnect */
36
42
if (redis_sock -> stream ) { /* check for EOF again. */
@@ -48,7 +54,9 @@ PHPAPI zval *redis_sock_read_multibulk_reply_zval(INTERNAL_FUNCTION_PARAMETERS,
48
54
}
49
55
50
56
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
51
- php_stream_close (redis_sock -> stream );
57
+ if (!redis_sock -> persistent ) {
58
+ php_stream_close (redis_sock -> stream );
59
+ }
52
60
redis_sock -> stream = NULL ;
53
61
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
54
62
redis_sock -> mode = ATOMIC ;
@@ -118,7 +126,9 @@ PHPAPI char *redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
118
126
}
119
127
120
128
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
121
- php_stream_close (redis_sock -> stream );
129
+ if (!redis_sock -> persistent ) {
130
+ php_stream_close (redis_sock -> stream );
131
+ }
122
132
redis_sock -> stream = NULL ;
123
133
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
124
134
redis_sock -> mode = ATOMIC ;
@@ -599,7 +609,9 @@ PHPAPI int redis_sock_read_multibulk_reply_zipped_with_flag(INTERNAL_FUNCTION_PA
599
609
return -1 ;
600
610
}
601
611
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
602
- php_stream_close (redis_sock -> stream );
612
+ if (!redis_sock -> persistent ) {
613
+ php_stream_close (redis_sock -> stream );
614
+ }
603
615
redis_sock -> stream = NULL ;
604
616
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
605
617
redis_sock -> mode = ATOMIC ;
@@ -852,7 +864,9 @@ PHPAPI int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo
852
864
return -1 ;
853
865
}
854
866
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
855
- php_stream_close (redis_sock -> stream );
867
+ if (!redis_sock -> persistent ) {
868
+ php_stream_close (redis_sock -> stream );
869
+ }
856
870
redis_sock -> stream = NULL ;
857
871
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
858
872
redis_sock -> mode = ATOMIC ;
@@ -914,7 +928,9 @@ PHPAPI int redis_sock_read_multibulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, R
914
928
return -1 ;
915
929
}
916
930
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
917
- php_stream_close (redis_sock -> stream );
931
+ if (!redis_sock -> persistent ) {
932
+ php_stream_close (redis_sock -> stream );
933
+ }
918
934
redis_sock -> stream = NULL ;
919
935
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
920
936
redis_sock -> mode = ATOMIC ;
@@ -976,3 +992,5 @@ PHPAPI void redis_free_socket(RedisSock *redis_sock)
976
992
efree (redis_sock );
977
993
}
978
994
995
+ /* vim: set tabstop=4 softtabstop=4 noexpandtab shiftwidth=4: */
996
+
0 commit comments