harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-4077) [classlib][portlib] socket related functions incorrectly work in socket > FD_SETSIZE
Date Sat, 09 Jun 2007 14:20:26 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-4077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Alexei Zakharov resolved HARMONY-4077.

    Resolution: Fixed

Sergey, thanks for the patch - looks good in general. However, I have a few comments - please
see below.

1. I think there is no great need to remove the content of hysock_fdset_init(). It's a part
of portlib and user may want to use it in conjunction with hysock_select() that still uses
system select(). Moreover, if we remove the content of this function the description becomes
completely outdated and misleading. IMO such a step can be a part of bigger procces of redesign
of portlib if you suppose that select() is unsafe. I don't think we should do it here, in
this JIRA.

2. I have updated hysock_select_read() in hysock.c a bit. The function 
description states: "If the timeout is 0, skip this function (and thus the caller of a subsequent
read operation may block)". So I've corrected the code to reflect this behavior. BTW it looks
like the "accept" parameter isn't used at all.

3. Timeout issues (most important): 
hysock_connect_with_timeout() in hysock.c:
in the original code timeout was truncated to be less or equal to 100 milliseconds; fixed

selectRead() in OSNetworkSystemLinux.c:
the original code treats the value uSecTime parameter as a number of microseconds rather than
milliseconds; fixed 

hysock_select_read() in hysock.c:
Looks like the timeout convertion from (sec, microsec) -> millisec
"sec * 1000 + microsec / 1000"
wasn't completely correct since it converts (0, 1) to 0 but zero timeout has a specific meaning.
The following LUNI tests constantly fails because of this issue:

java.lang.Exception: java.io.IOException: Connection was closed at 
at org.apache.harmony.luni.tests.internal.net.www.protocol.https.HttpsURLConnectionTest.doInteraction(HttpsURLConnectionTest.java:829)
at org.apache.harmony.luni.tests.internal.net.www.protocol.https.HttpsURLConnectionTest.testProxyConnection(HttpsURLConnectionTest.java:434)
at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
Caused by: java.io.IOException: Connection was closed
at org.apache.harmony.xnet.provider.jsse.SSLSocketImpl.doHandshake
at  org.apache.harmony.xnet.provider.jsse.SSLSocketImpl.startHandshake
at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection$HttpsEngine.wrapConnection(HttpsURLConnection.java:433)

4. java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl() in OSNetworkSystemLinux.c
I've made small correction to the code to let it better follow the original behavior.

5. I've seen that some sort of select() is used also in the code for windows version of "hysock.c".
Is the described problem UNIX-only or we should look / rework Windows code as well?

Reworked version of your patch was applied at the repository revision 545748. Please verify
it is ok (if it is) and solves the original issue.

> [classlib][portlib] socket related functions incorrectly work in socket > FD_SETSIZE
> ------------------------------------------------------------------------------------
>                 Key: HARMONY-4077
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4077
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: linux only
>            Reporter: Sergey Dmitriev
>            Assignee: Alexei Zakharov
>         Attachments: 4077.patch
> Socket related functions incorrectly work with sockets if socket no > FD_SETSIZE.
On "SUSE LINUX Enterprise Server 9" FD_SETSIZE is 1024.
> The following functions:
>  Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
>  Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl
>  hysock_select_read
>  getNextNetlinkMsg
>  hysock_connect_with_timeout
> use system select() to wait for event on only one file descriptor (socket). In case socket
number is greater than maximum fdset_t size (FD_SETSIZE) we can have SIGSEGV. Satellite functins
FD_SET, FD_ISSET, FD_CLR can cause SIGSEGV as well.
> One of possible solutions here can be to use poll() instead of select() since we're talking
about wait for event on the single file descriptor.

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

View raw message