From ca54db95d31db2d80c02f6a19a2723d45989f0fa Mon Sep 17 00:00:00 2001 From: donghee yang Date: Mon, 4 Mar 2013 17:12:57 +0900 Subject: [PATCH] [Title] Added TIMEOUT parameters to read_lines function --- src/common/BuildComm.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/common/BuildComm.rb b/src/common/BuildComm.rb index f80a9e2..6b866ed 100644 --- a/src/common/BuildComm.rb +++ b/src/common/BuildComm.rb @@ -331,7 +331,7 @@ end class BuildCommClient VERSION = "1.7.0" - FIRST_REPONSE_TIMEOUT = 120 + FIRST_RESPONSE_TIMEOUT = 120 private_class_method :new @@ -396,7 +396,7 @@ class BuildCommClient begin l = nil - timeout(FIRST_REPONSE_TIMEOUT) do + timeout(FIRST_RESPONSE_TIMEOUT) do l = @socket.gets() end @@ -432,12 +432,16 @@ class BuildCommClient # handle - def read_lines + def read_lines(begin_timeout = nil, data_timeout = nil) begin # get first line l = nil - timeout(FIRST_REPONSE_TIMEOUT) do + if begin_timeout.nil? then + begin_timeout = FIRST_RESPONSE_TIMEOUT + end + + timeout( begin_timeout ) do l = @socket.gets() end @@ -454,7 +458,15 @@ class BuildCommClient # get contents result = true - while line = @socket.gets() + while true + if not data_timeout.nil? then + timeout( data_timeout ) do + line = @socket.gets() + end + else + line = @socket.gets() + end + if line.nil? then break end if line.strip == "=END" then break end if line.strip == "=CHK" then next end -- 2.34.1