Bug 44236

Summary: IsReachable Issue
Product: Ant Reporter: ZW <mpc8250>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 1.7.0   
Target Milestone: ---   
Hardware: All   
OS: Windows XP   

Description ZW 2008-01-14 20:37:42 UTC
Z W wrote:
> Hi
>
> I'm trying to "ping" hosts on network using <isreachable> with ant-contrib.
> All these hosts variables point to the same host ie linpac2.

>

> [echo] start isreachable linpac2
>
> Dynamically discovered 'isreachable'
> org.apache.tools.ant.taskdefs.condition.IsReachable@1f3aa07
>
> Probing host linpac2
>
> Unknown host: linpac2
>
> Condition false; not setting offline
>
> [echo] build_main.debug=0
>
> [sleep] sleeping for 5000 milliseconds
>
> Why on both consecutive "pinging" to the same host, it works the first time
> but not the second ?
>


I'm the author of that task, so blame me.
Here's the source
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskd
efs/condition/IsReachable.java?view=markup

-isreachable uses Sun's API InetAddress.isReachable() , the exact
behaviour of which is undocumented (they dont say how it pings)

If its playing up, its probably the implementation. I see that java 6.4
mentions three fixes for this

6587875         java    classes_net     InetAddress.isReachable() will not 
work for
super users with "large" process ids
6599750         java    classes_net     InetAddress.isReachable implementation 
not
completely thread safe
6601686         java    classes_net     InetAddress.isReachable(timeout) may 
not
return after timout milliseconds

1. please open a bugrep on issues.apache.org/bugzilla
2. try with the latest sun JVM update; if it goes away, then we've found
the problem

I've found I dont use the condition much, because
 -some of the hosts I deploy to have ping locked down
 -it doesnt go through firewalls
 -when a machine is booting up, ping starts ahead of the services I need

I prefer to use <http> and <socket>. Could they work for you ?
Comment 1 Steve Loughran 2008-01-15 01:45:27 UTC
ZW 

-try upgrading to java 1.6.0_04, which has some documented changes to the
IsReachable() code