[Title] Added TIMEOUT parameters to read_lines function
authordonghee yang <donghee.yang@samsung.com>
Mon, 4 Mar 2013 08:12:57 +0000 (17:12 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Mon, 4 Mar 2013 08:20:30 +0000 (17:20 +0900)
src/common/BuildComm.rb

index f80a9e24a6aefa656078800a29148eb9c429966e..6b866ed2a2c6d4b0c697ce3b2f6d86c7f3d95d55 100644 (file)
@@ -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