The problem here is that your signaling thread is signaling before the
originating thread has had the chance to wait on the condition. This
results in the wait hanging forever waiting for a signal. The fix is
to synchronize the creation of the background thread as well. Here's a
patch that fixes the issue. I have also removed the Thread.pass calls
as they not needed.

Index: gateway.rb
===================================================================
--- gateway.rb  (revision 6494)
+++ gateway.rb  (working copy)
@@ -38,18 +38,18 @@
       mutex = Mutex.new
       waiter = ConditionVariable.new

-      @thread = Thread.new do
-        logger.trace "starting connection to gateway
`#{server.host}'" if logger
-        SSH.connect(server, @options) do |@session|
-          logger.trace "gateway connection established" if logger
-          Thread.pass
-          mutex.synchronize { waiter.signal }
-          @session.loop { [EMAIL PROTECTED] }
+      mutex.synchronize do
+        @thread = Thread.new do
+          logger.trace "starting connection to gateway
`#{server.host}'" if logger
+          SSH.connect(server, @options) do |@session|
+            logger.trace "gateway connection established" if logger
+            mutex.synchronize { waiter.signal }
+            @session.loop do
+              [EMAIL PROTECTED]
+            end
+          end
         end
-      end

-      mutex.synchronize do
-        Thread.pass
         waiter.wait(mutex)
       end
     end


On Mar 30, 9:38 am, Jamis Buck <[EMAIL PROTECTED]> wrote:
> Yeah...I've not been able to figure that out. It only happens
> intermittently to me. If you go into test/gateway_test.rb and comment
> out the
> test_initialize_when_connect_lags_should_open_and_set_session_value
> test (lines 13-17), it should go away.
>
> Any threading/concurrency gurus around that would like to help
> explain what I'm doing wrong? It only seems to affect the tests;
> Capistrano itself hasn't seemed to be impacted by this.
>
> - Jamis
>
> P.S. Good to see some people starting to play with cap2!
>
> On Mar 30, 2007, at 8:29 AM, rubdabadub wrote:
>
> > Hi:
>
> > I am just wondering what does this mean.. I get when i run the tests
>
> > ......................................................................
> > ...................................................deadlock
> > 0x14bc084: sleep:-  - ./test/cli/../../lib/capistrano/gateway.rb:46
> > deadlock 0x31704: sleep:- (main) - ./test/cli/../../lib/capistrano/
> > gateway.rb:53
>
> > Does it mean I am missing something or??
>
> > Thanks


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to