@@ -841,6 +841,7 @@ PHPAPI RedisSock* redis_sock_create(char *host, int host_len, unsigned short por
841841
842842 redis_sock -> port = port ;
843843 redis_sock -> timeout = timeout ;
844+ redis_sock -> read_timeout = timeout ;
844845
845846 redis_sock -> serializer = REDIS_SERIALIZER_NONE ;
846847 redis_sock -> mode = ATOMIC ;
@@ -860,7 +861,7 @@ PHPAPI RedisSock* redis_sock_create(char *host, int host_len, unsigned short por
860861 */
861862PHPAPI int redis_sock_connect (RedisSock * redis_sock TSRMLS_DC )
862863{
863- struct timeval tv , * tv_ptr = NULL ;
864+ struct timeval tv , read_tv , * tv_ptr = NULL ;
864865 char * host = NULL , * persistent_id = NULL , * errstr = NULL ;
865866 int host_len , err = 0 ;
866867 php_netstream_data_t * sock ;
@@ -876,6 +877,9 @@ PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
876877 tv_ptr = & tv ;
877878 }
878879
880+ read_tv .tv_sec = (time_t )redis_sock -> read_timeout ;
881+ read_tv .tv_usec = (int )((redis_sock -> read_timeout - read_tv .tv_sec ) * 1000000 );
882+
879883 if (redis_sock -> host [0 ] == '/' && redis_sock -> port < 1 ) {
880884 host_len = spprintf (& host , 0 , "unix://%s" , redis_sock -> host );
881885 } else {
@@ -915,9 +919,9 @@ PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
915919
916920 php_stream_auto_cleanup (redis_sock -> stream );
917921
918- if (tv .tv_sec != 0 ) {
922+ if (read_tv .tv_sec != 0 ) {
919923 php_stream_set_option (redis_sock -> stream , PHP_STREAM_OPTION_READ_TIMEOUT ,
920- 0 , & tv );
924+ 0 , & read_tv );
921925 }
922926 php_stream_set_option (redis_sock -> stream ,
923927 PHP_STREAM_OPTION_WRITE_BUFFER ,
0 commit comments