From a9a0845b19727251058d979bbaf01ae15d4dc1d2 Mon Sep 17 00:00:00 2001 From: Sean Kirby Date: Fri, 29 Oct 2010 18:30:06 -0400 Subject: [PATCH 1/2] fixed stack overflows that could happen when a large number of runners run tests that output a lot to the console when ssh testing --- lib/hydra/messaging_io.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/hydra/messaging_io.rb b/lib/hydra/messaging_io.rb index fc981c2..da8764f 100644 --- a/lib/hydra/messaging_io.rb +++ b/lib/hydra/messaging_io.rb @@ -8,14 +8,17 @@ module Hydra #:nodoc: # IO.gets # => Hydra::Message # or subclass def gets - raise IOError unless @reader - message = @reader.gets - return nil unless message - return Message.build(eval(message.chomp)) - rescue SyntaxError, NameError - # uncomment to help catch remote errors by seeing all traffic - #$stderr.write "Not a message: [#{message.inspect}]\n" - return gets + while true + begin + raise IOError unless @reader + message = @reader.gets + return nil unless message + return Message.build(eval(message.chomp)) + rescue SyntaxError, NameError + # uncomment to help catch remote errors by seeing all traffic + #$stderr.write "Not a message: [#{message.inspect}]\n" + end + end end # Write a Message to the output IO object. It will automatically From 78ae8eace6e7ad75cd97c1042feefcfc2561c064 Mon Sep 17 00:00:00 2001 From: Arturo Date: Tue, 26 Apr 2011 11:08:15 -0400 Subject: [PATCH 2/2] Fixed stack overflow when runners produce a lot of non-Hydra console output. --- test/fixtures/many_outputs_to_console.rb | 9 +++++++++ test/ssh_test.rb | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/fixtures/many_outputs_to_console.rb diff --git a/test/fixtures/many_outputs_to_console.rb b/test/fixtures/many_outputs_to_console.rb new file mode 100644 index 0000000..8a79a74 --- /dev/null +++ b/test/fixtures/many_outputs_to_console.rb @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby + +10000.times do + $stdout.write "A non-hydra message...\n" + $stdout.flush +end + +$stdout.write "{:class=>Hydra::Messages::TestMessage, :text=>\"My message\"}\n" +$stdout.flush diff --git a/test/ssh_test.rb b/test/ssh_test.rb index 6b0ee40..eb331ef 100644 --- a/test/ssh_test.rb +++ b/test/ssh_test.rb @@ -11,4 +11,15 @@ class SSHTest < Test::Unit::TestCase assert_equal "Hello World", response.text ssh.close end + + should "be able to handle a large number of non-Hydra console output" do + ssh = Hydra::SSH.new( + 'localhost', # connect to this machine + File.expand_path(File.join(File.dirname(__FILE__))), # move to the test directory + "ruby fixtures/many_outputs_to_console.rb" + ) + response = ssh.gets + assert_equal "My message", response.text + ssh.close + end end