@@ -359,7 +359,8 @@ redis_check_eof(RedisSock *redis_sock, zend_bool no_retry, zend_bool no_throw)
359359 for (retry_index = 0 ; !no_retry && retry_index < redis_sock -> max_retries ; ++ retry_index ) {
360360 /* close existing stream before reconnecting */
361361 if (redis_sock -> stream ) {
362- redis_sock_disconnect (redis_sock , 1 );
362+ /* reconnect no need to reset mode, it will cause pipeline mode socket exception */
363+ redis_sock_disconnect (redis_sock , 1 , 0 );
363364 }
364365 /* Sleep based on our backoff algorithm */
365366 zend_ulong delay = redis_backoff_compute (& redis_sock -> backoff , retry_index );
@@ -390,7 +391,7 @@ redis_check_eof(RedisSock *redis_sock, zend_bool no_retry, zend_bool no_throw)
390391 }
391392 }
392393 /* close stream and mark socket as failed */
393- redis_sock_disconnect (redis_sock , 1 );
394+ redis_sock_disconnect (redis_sock , 1 , 1 );
394395 redis_sock -> status = REDIS_SOCK_STATUS_FAILED ;
395396 if (!no_throw ) {
396397 REDIS_THROW_EXCEPTION ( errmsg , 0 );
@@ -3058,7 +3059,7 @@ PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock)
30583059 ConnectionPool * p = NULL ;
30593060
30603061 if (redis_sock -> stream != NULL ) {
3061- redis_sock_disconnect (redis_sock , 0 );
3062+ redis_sock_disconnect (redis_sock , 0 , 1 );
30623063 }
30633064
30643065 address = ZSTR_VAL (redis_sock -> host );
@@ -3206,7 +3207,7 @@ redis_sock_server_open(RedisSock *redis_sock)
32063207 * redis_sock_disconnect
32073208 */
32083209PHP_REDIS_API int
3209- redis_sock_disconnect (RedisSock * redis_sock , int force )
3210+ redis_sock_disconnect (RedisSock * redis_sock , int force , int is_reset_mode )
32103211{
32113212 if (redis_sock == NULL ) {
32123213 return FAILURE ;
@@ -3228,7 +3229,9 @@ redis_sock_disconnect(RedisSock *redis_sock, int force)
32283229 }
32293230 redis_sock -> stream = NULL ;
32303231 }
3231- redis_sock -> mode = ATOMIC ;
3232+ if (is_reset_mode ) {
3233+ redis_sock -> mode = ATOMIC ;
3234+ }
32323235 redis_sock -> status = REDIS_SOCK_STATUS_DISCONNECTED ;
32333236 redis_sock -> watching = 0 ;
32343237
@@ -4107,7 +4110,7 @@ redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size, size_t *line_siz
41074110 snprintf (buf , buf_size , "read error on connection to %s:%d" , ZSTR_VAL (redis_sock -> host ), redis_sock -> port );
41084111 }
41094112 // Close our socket
4110- redis_sock_disconnect (redis_sock , 1 );
4113+ redis_sock_disconnect (redis_sock , 1 , 1 );
41114114
41124115 // Throw a read error exception
41134116 REDIS_THROW_EXCEPTION (buf , 0 );
0 commit comments