harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Deakin (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-5530) Selector.select() returns exception if network connection is lost
Date Thu, 21 Feb 2008 15:59:19 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-5530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12571086#action_12571086
] 

Oliver Deakin commented on HARMONY-5530:
----------------------------------------

Hi Phil,

I have tried your test case on both Windows and Linux - it fails on Windows (as you describe)
and passes successfully on Linux (i.e. continues to wait).

I had a dig down into the code, and it seems that the issue might be caused by differences
in the selectImpl() implementation (in OSNetworkSystemLinux.c and OSNetworkSystemWin32.c)
between Linux and Windows. My findings so far are:
 - Linux selectImpl() uses poll() to determine socket status. poll() does not return when
the IP address is released.
 - Windows selecImpl() uses select() to determine socket status. select() exits as soon as
the IP address is released (although apparently without returning an error code).
This could be what's causing the difference we see between Windows and Linux in your test.

Can you attach a patch for your suggested change so we can look it over and test it? Thanks!


> Selector.select() returns exception if network connection is lost
> -----------------------------------------------------------------
>
>                 Key: HARMONY-5530
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5530
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M4
>         Environment: Only test on Win32, Linux unknown at this time.
>            Reporter: Phil Loats
>
> This problem was seen on version "harmony-jdk-603534"
> When Selector.select() is called with an empty list, then the network connection is lost
- an exception is thrown to the caller.
> This behavior is different from J2SE 1.5 where it continues to wait without throwing
an exception.
> The following test code will show this problem:
> import java.io.IOException;
> import java.nio.channels.Selector;
> public class Test {
> 	public static void main(String[] args) {
> 		Selector selector = null;
> 		
> 		try {
> 			selector = Selector.open();
> 			System.out.println("selector open...");		       
> 		} catch (IOException e) {
> 	    }
> 		    
> 		// Wait for events
> 		while (true) {
> 		    try {
> 		    	// Wait for an event
> 		    	System.out.println("Waiting on selector...");
> 		        selector.select();
> 		    } catch (IOException e) {
> 		        // Handle error with selector
> 		    	e.printStackTrace();
> 		        break;
> 		    }
> 		}
> 		System.out.println("done...");
> 	}
> }
> Start the testcase, it will pause at "Waiting on selector..." message.  Bring down the
network connection ("ipconfig /release" I use), the following exception is thrown:
> selector open...
> Waiting on selector...
> java.net.SocketException: The connection was reset
>         at org.apache.harmony.luni.platform.OSNetworkSystem.readSocketImpl(OSNetworkSystem.java)
>         at org.apache.harmony.luni.platform.OSNetworkSystem.read(OSNetworkSystem.java:89)
>         at org.apache.harmony.nio.internal.SocketChannelImpl.readImpl(SocketChannelImpl.java:459)
>         at org.apache.harmony.nio.internal.SocketChannelImpl.read(SocketChannelImpl.java:377)
>         at org.apache.harmony.nio.internal.PipeImpl$SourceChannelImpl.read(PipeImpl.java:133)
>         at org.apache.harmony.nio.internal.SelectorImpl.processSelectResult(SelectorImpl.java:526)
>         at org.apache.harmony.nio.internal.SelectorImpl.selectInternal(SelectorImpl.java:474)
>         at org.apache.harmony.nio.internal.SelectorImpl.select(SelectorImpl.java:432)
>         at Test.main(Test.java:30)
> done...
> Again, J2SE 1.5 remains paused at "Waiting..." when the network is lost or regained.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message