@@ -21,15 +21,19 @@ 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 ;
26
28
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
27
29
}
28
30
zend_throw_exception (redis_exception_ce , "Connection lost" , 0 TSRMLS_CC );
29
31
return -1 ;
30
32
}
31
33
if (redis_sock -> stream ) { /* close existing stream before reconnecting */
32
- php_stream_close (redis_sock -> stream );
34
+ if (!redis_sock -> persistent ) {
35
+ php_stream_close (redis_sock -> stream );
36
+ }
33
37
redis_sock -> stream = NULL ;
34
38
}
35
39
redis_sock_connect (redis_sock TSRMLS_CC ); /* reconnect */
@@ -48,7 +52,9 @@ PHPAPI zval *redis_sock_read_multibulk_reply_zval(INTERNAL_FUNCTION_PARAMETERS,
48
52
}
49
53
50
54
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
51
- php_stream_close (redis_sock -> stream );
55
+ if (!redis_sock -> persistent ) {
56
+ php_stream_close (redis_sock -> stream );
57
+ }
52
58
redis_sock -> stream = NULL ;
53
59
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
54
60
redis_sock -> mode = ATOMIC ;
@@ -118,7 +124,9 @@ PHPAPI char *redis_sock_read(RedisSock *redis_sock, int *buf_len TSRMLS_DC)
118
124
}
119
125
120
126
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
121
- php_stream_close (redis_sock -> stream );
127
+ if (!redis_sock -> persistent ) {
128
+ php_stream_close (redis_sock -> stream );
129
+ }
122
130
redis_sock -> stream = NULL ;
123
131
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
124
132
redis_sock -> mode = ATOMIC ;
@@ -599,7 +607,9 @@ PHPAPI int redis_sock_read_multibulk_reply_zipped_with_flag(INTERNAL_FUNCTION_PA
599
607
return -1 ;
600
608
}
601
609
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
602
- php_stream_close (redis_sock -> stream );
610
+ if (!redis_sock -> persistent ) {
611
+ php_stream_close (redis_sock -> stream );
612
+ }
603
613
redis_sock -> stream = NULL ;
604
614
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
605
615
redis_sock -> mode = ATOMIC ;
@@ -852,7 +862,9 @@ PHPAPI int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo
852
862
return -1 ;
853
863
}
854
864
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
855
- php_stream_close (redis_sock -> stream );
865
+ if (!redis_sock -> persistent ) {
866
+ php_stream_close (redis_sock -> stream );
867
+ }
856
868
redis_sock -> stream = NULL ;
857
869
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
858
870
redis_sock -> mode = ATOMIC ;
@@ -914,7 +926,9 @@ PHPAPI int redis_sock_read_multibulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, R
914
926
return -1 ;
915
927
}
916
928
if (php_stream_gets (redis_sock -> stream , inbuf , 1024 ) == NULL ) {
917
- php_stream_close (redis_sock -> stream );
929
+ if (!redis_sock -> persistent ) {
930
+ php_stream_close (redis_sock -> stream );
931
+ }
918
932
redis_sock -> stream = NULL ;
919
933
redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
920
934
redis_sock -> mode = ATOMIC ;
@@ -976,3 +990,5 @@ PHPAPI void redis_free_socket(RedisSock *redis_sock)
976
990
efree (redis_sock );
977
991
}
978
992
993
+ /* vim: set tabstop=4 softtabstop=4 noexpandtab shiftwidth=4: */
994
+
0 commit comments