@@ -1597,7 +1597,7 @@ PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
15971597
15981598 php_stream_auto_cleanup (redis_sock -> stream );
15991599
1600- if ( tv .tv_sec != 0 || tv .tv_usec != 0 ) {
1600+ if ( read_tv .tv_sec != 0 || read_tv .tv_usec != 0 ) {
16011601 php_stream_set_option (redis_sock -> stream ,PHP_STREAM_OPTION_READ_TIMEOUT ,
16021602 0 , & read_tv );
16031603 }
@@ -1791,36 +1791,33 @@ redis_mbulk_reply_loop(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
17911791 zval * z_tab , int count , int unserialize )
17921792{
17931793 char * line ;
1794- int len ;
1795-
1796- while (count > 0 ) {
1797- line = redis_sock_read (redis_sock , & len TSRMLS_CC );
1798- if (line != NULL ) {
1799- zval zv , * z = & zv ;
1800- int unwrap ;
1801-
1802- /* We will attempt unserialization, if we're unserializing everything,
1803- * or if we're unserializing keys and we're on a key, or we're
1804- * unserializing values and we're on a value! */
1805- unwrap = unserialize == UNSERIALIZE_ALL ||
1806- (unserialize == UNSERIALIZE_KEYS && count % 2 == 0 ) ||
1807- (unserialize == UNSERIALIZE_VALS && count % 2 != 0 );
1808-
1809- if (unwrap && redis_unserialize (redis_sock , line , len , z TSRMLS_CC )) {
1794+ int i , len ;
1795+
1796+ for (i = 0 ; i < count ; ++ i ) {
1797+ if ((line = redis_sock_read (redis_sock , & len TSRMLS_CC )) == NULL ) {
1798+ add_next_index_bool (z_tab , 0 );
1799+ continue ;
1800+ }
1801+
1802+ /* We will attempt unserialization, if we're unserializing everything,
1803+ * or if we're unserializing keys and we're on a key, or we're
1804+ * unserializing values and we're on a value! */
1805+ int unwrap = (
1806+ (unserialize == UNSERIALIZE_ALL ) ||
1807+ (unserialize == UNSERIALIZE_KEYS && i % 2 == 0 ) ||
1808+ (unserialize == UNSERIALIZE_VALS && i % 2 != 0 )
1809+ );
1810+ zval zv , * z = & zv ;
1811+ if (unwrap && redis_unserialize (redis_sock , line , len , z TSRMLS_CC )) {
18101812#if (PHP_MAJOR_VERSION < 7 )
1811- MAKE_STD_ZVAL (z );
1812- * z = zv ;
1813+ MAKE_STD_ZVAL (z );
1814+ * z = zv ;
18131815#endif
1814- add_next_index_zval (z_tab , z );
1815- } else {
1816- add_next_index_stringl (z_tab , line , len );
1817- }
1818- efree (line );
1816+ add_next_index_zval (z_tab , z );
18191817 } else {
1820- add_next_index_bool (z_tab , 0 );
1818+ add_next_index_stringl (z_tab , line , len );
18211819 }
1822-
1823- count -- ;
1820+ efree (line );
18241821 }
18251822}
18261823
0 commit comments