about summary refs log tree commit homepage
path: root/lib/mogilefs/new_file/common.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mogilefs/new_file/common.rb')
-rw-r--r--lib/mogilefs/new_file/common.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/mogilefs/new_file/common.rb b/lib/mogilefs/new_file/common.rb
index 38d0fd3..e959a21 100644
--- a/lib/mogilefs/new_file/common.rb
+++ b/lib/mogilefs/new_file/common.rb
@@ -19,8 +19,9 @@ module MogileFS::NewFile::Common
   MD5_TRAILER_NODES = {} # :nodoc: # EXPERIMENTAL
 
   def read_response(sock)
-    # mostly relying on SO_KEEPALIVE to timeout
-    case line = sock.timed_read(23, "", 7200)
+    tout = @opts[:new_file_max_time] || 3600.0
+    start_time = @opts[:start_time] and tout -= Time.now - start_time
+    case line = sock.timed_read(23, "", tout > 0.0 ? tout : 0)
     when %r{^HTTP/\d\.\d\s+(2\d\d)\s} # success!
     when nil
       raise EmptyResponseError, 'Unable to read response line from server'