Hi .. 

 On Friday 11 February 2005 00:20, Robert Klemme wrote:
>
> Which means ensure is never called if the acquire fails.  So I would do it
> like this:
>
>   <excellent version removed>
>
Thank you.

Ara also mention, off-list, that I am catching the exception, otherwise the 
app would be failing.  He suggested that the issue could also be with how I 
am using @exception.

I am not so sure that is the case.  The basic driver that I use looks like:

    require 'bsn_a.rb'
    def run
        threads = []
        @addr.each do |ip_addr|
            threads << Thread.new(ip_addr) do |node|
              name, ip, usr, pwd = node.split(/:/)
              
              bsn = BSN.new(node)  #### deliberately fail for now
              bsn.user = usr
              bsn.pwd  = pwd

              puts "  .. trying to go to #{nn} (#{bsn.host})"
       f = bsn.login    #### this is line 144
              puts "  --> #{(f ? " got there" : " failed ")} #{bsn.host}"
            end
        end
        threads.each { |thr| thr.join }
    end

The program creates a BSN object then calls login().  

  def login
      f = alive?
      if not f
          _pr "login --> host not alive (#{@exception})"  ### log to file
          return false 
      end  
      ### go on with login stuff
  end

So, it is calling alive? to find out if we can connect, before we try and 
connect for real.

My problem is that when I do this from my test harness, line 144 doesn't throw 
an exception:


8:48 (kant)$ ruby test.rb
  .. trying to go to Foo (Foo:10.10.10.5:foo:bar)
  -->  failed  Foo:10.10.10.5:foo:bar
  .. trying to go to Foo (Foo:10.10.10.5:foo:bar)
  -->  failed  Foo:10.10.10.5:foo:bar

However, from the 'real' program it does throw one at line 144 ????

8:49 (kant)$ ruby bsncoll.rb -g -n eeua.txt -c flow.txt -d data
  .. trying to go to Foo (Foo:10.10.10.5:foo:bar)
  Exception `SocketError' at ./bsn_a.rb:144 - getaddrinfo: hostname 
    nor servname provided, or not known
  -->  failed  Foo:10.10.10.5:foo:bar
  .. trying to go to Bar (Bar:10.10.10.6:foo:bar)
  Exception `SocketError' at ./bsn_a.rb:144 - getaddrinfo: hostname 
    nor servname provided, or not known
  -->  failed  Bar:10.10.10.6:foo:bar
  - post-processing data ... please wait

Ara is right that the program doesn't die.  However, it is, in the second case 
throwing a message to stderr that the first program doesn't do.  I am not 
certain, but I think that this may be part of my memory leak problem that I 
mentioned in another thread.  And I don't seem to be able to make it go away!

This behaviour seems abnormal.  If the exception is thrown at 144, then I 
should be able to rescue the way that Robert points out.  Except, it doesn't 
in this case.

Still confused ...

-- 
-mark.  (probertm at acm dot org)