harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Dmitriev (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4077) [classlib][portlib] socket related functions incorrectly work in socket > FD_SETSIZE
Date Mon, 18 Jun 2007 18:00:42 GMT

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

Sergey Dmitriev commented on HARMONY-4077:

Alexei, as I see the last version (r548279) is not good. I mean the
simple test (simple server which calls accept() and read()) does not
work. See below for the server3.java.

As it turned out the problem is in the selectRead(int uSecTimeout)
which takes timeout in millis despite of the naming. For example
Selector.select(int timeout) takes timeout in millis and passes it
down to selectRead(int). Note the Selector.select() calls
selectRead(-1). So in this case -1 disappears after

Please see the attached 4077_2.patch and server3.java:

import java.net.*;
import java.nio.*;
import java.nio.channels.*;

public class server3 {

    static int port = 9999;

    public static void main(String args[]) throws Exception {
        ServerSocketChannel sch = ServerSocketChannel.open();
        sch.socket().bind(new InetSocketAddress(port));

        for (;;) {
            System.err.print("listening... ");
            SocketChannel ch = sch.accept();

            try {
                ByteBuffer buf = ByteBuffer.allocate(1);
                while (ch.read(buf) != -1) {
            } finally {

Just launch "java server3" and execute "telnet localhost 9999" in
another shell and tap ENTER couple of times.

> [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, 4077_2.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