@@ -861,6 +861,7 @@ PHPAPI RedisSock* redis_sock_create(char *host, int host_len, unsigned short por
861861
862862    redis_sock -> port     =  port ;
863863    redis_sock -> timeout  =  timeout ;
864+     redis_sock -> read_timeout  =  timeout ;
864865
865866    redis_sock -> serializer  =  REDIS_SERIALIZER_NONE ;
866867    redis_sock -> mode  =  ATOMIC ;
@@ -880,7 +881,7 @@ PHPAPI RedisSock* redis_sock_create(char *host, int host_len, unsigned short por
880881 */ 
881882PHPAPI  int  redis_sock_connect (RedisSock  * redis_sock  TSRMLS_DC )
882883{
883-     struct  timeval  tv , * tv_ptr  =  NULL ;
884+     struct  timeval  tv , read_tv ,  * tv_ptr  =  NULL ;
884885    char  * host  =  NULL , * persistent_id  =  NULL , * errstr  =  NULL ;
885886    int  host_len , err  =  0 ;
886887	php_netstream_data_t  * sock ;
@@ -896,6 +897,9 @@ PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
896897	    tv_ptr  =  & tv ;
897898    }
898899
900+     read_tv .tv_sec   =  (time_t )redis_sock -> read_timeout ;
901+     read_tv .tv_usec  =  (int )((redis_sock -> read_timeout  -  read_tv .tv_sec ) *  1000000 );
902+ 
899903    if (redis_sock -> host [0 ] ==  '/'  &&  redis_sock -> port  <  1 ) {
900904	    host_len  =  spprintf (& host , 0 , "unix://%s" , redis_sock -> host );
901905    } else  {
@@ -937,7 +941,7 @@ PHPAPI int redis_sock_connect(RedisSock *redis_sock TSRMLS_DC)
937941
938942    if (tv .tv_sec  !=  0  ||  tv .tv_usec  !=  0 ) {
939943        php_stream_set_option (redis_sock -> stream , PHP_STREAM_OPTION_READ_TIMEOUT ,
940-                               0 , & tv );
944+                               0 , & read_tv );
941945    }
942946    php_stream_set_option (redis_sock -> stream ,
943947                          PHP_STREAM_OPTION_WRITE_BUFFER ,
0 commit comments