You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Alexander Veit (JIRA)" <ji...@apache.org> on 2007/08/02 11:39:52 UTC

[jira] Created: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
----------------------------------------------------------------------------------------------------

                 Key: HTTPCORE-108
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
             Project: HttpComponents Core
          Issue Type: Bug
          Components: HttpCore NIO
    Affects Versions: 4.0-alpha5
         Environment: any
            Reporter: Alexander Veit
            Priority: Blocker


DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.

org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.

This leads to problems in all circumstances where the listener should be restarted within the same VM.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Resolved: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-108.
----------------------------------------

    Resolution: Fixed

Alexander,
I committed a slightly different version of the patch. Please re-test your application against SVN trunk and re-open the issue if the problem still persists.

Oleg

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Assignee: Oleg Kalnichevski
>            Priority: Blocker
>             Fix For: 4.0-alpha6
>
>         Attachments: listening-ioreactor.patch
>
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Updated: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-108:
---------------------------------------

    Fix Version/s: 4.0-alpha6

I'll look into it in the coming days

Oleg

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Priority: Blocker
>             Fix For: 4.0-alpha6
>
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Sam Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517716 ] 

Sam Berlin commented on HTTPCORE-108:
-------------------------------------

The line 'SelectionKey key = serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);' is registering the channel in the selector, which will keep a hard-reference around to the channel, and the channel keeps a hard reference to the socket.  It still might not be cleaned up correctly (if there's nothing that gets the channel from the SelectionKey from the Selector), but it wouldn't be because it's out-of-scope.

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Assignee: Oleg Kalnichevski
>            Priority: Blocker
>             Fix For: 4.0-alpha6
>
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Alexander Veit (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517207 ] 

Alexander Veit commented on HTTPCORE-108:
-----------------------------------------

Hi Oleg

Here's a short snippet that should suffice to show the problem:

public static void main(String[] args) throws Exception
{
	HttpParams params;
	DefaultListeningIOReactor ioReactor;

	params    = new BasicHttpParams();
	ioReactor = new DefaultListeningIOReactor(2, params);

	ioReactor.listen(new InetSocketAddress(8084));
	ioReactor.shutdown();

	ioReactor.listen(new InetSocketAddress(8084));
	ioReactor.shutdown();
}



> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Priority: Blocker
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Assigned: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski reassigned HTTPCORE-108:
------------------------------------------

    Assignee: Oleg Kalnichevski

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Assignee: Oleg Kalnichevski
>            Priority: Blocker
>             Fix For: 4.0-alpha6
>
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517255 ] 

Oleg Kalnichevski commented on HTTPCORE-108:
--------------------------------------------

Alexander,

I am pretty sure the port will not become available _immediately_ after the shutdown on some platforms. This is quite normal and there is nothing we can do about it. There is always a certain time lag involved depending on OS / JRE / TCP/IP stack implementation  Are you sure the port stays allocated for the entire JVM lifetime?

Oleg

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Priority: Blocker
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517192 ] 

Oleg Kalnichevski commented on HTTPCORE-108:
--------------------------------------------

Hi Alexander

Just to make sure I understand the problem, are you saying that calling DefaultListeningIOReactor#shutdown() does not correctly close ServerSocketChannels registered with the I/O selector? Please give me some more details on the issue. A test case would also be lovely.

Oleg

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Priority: Blocker
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Updated: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-108:
---------------------------------------

    Attachment: listening-ioreactor.patch

I find it really weird that ports stay allocated even after the selector (and I assume all server channels that are registered with it) get GCed. Anyways the patch attached fixed the problem for me. Please review.

Oleg

> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Assignee: Oleg Kalnichevski
>            Priority: Blocker
>             Fix For: 4.0-alpha6
>
>         Attachments: listening-ioreactor.patch
>
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


[jira] Commented: (HTTPCORE-108) DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket

Posted by "Alexander Veit (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12517269 ] 

Alexander Veit commented on HTTPCORE-108:
-----------------------------------------

Hi Oleg,

If you place

 Thread.sleep(LONG_TIME); 
 System.gc();
 System.runFinalization();
 System.gc();
 Thread.sleep(LONG_TIME);

between the the two blocks, the problem is still there. In

public SocketAddress listen(final SocketAddress address) throws IOException {
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        serverChannel.configureBlocking(false);
        serverChannel.socket().bind(address);
        SelectionKey key = serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);
        key.attach(null);
        return serverChannel.socket().getLocalSocketAddress();
}

serverChannel and socket have local scope. It's quite clear that nobody will free the system resources that were allocated by the socket bind operation.

Even if a garbage collector run would free the resources this would be due to implementation details in the Java system classes. However there seem to be various references to the created server socket hold by the system ShutdownHook, ThreadGroups and others.



> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-108
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-108
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: any
>            Reporter: Alexander Veit
>            Priority: Blocker
>
> DefaultListeningIOReactor does not provide access to the ServerSocketChannel nor to the bound socket.
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor#listen(SocketAddress) opens a ServerSocketChannel and bind to the given address. However there is no way to free the allocated system resources. They are being used unti the Java VM terminates.
> This leads to problems in all circumstances where the listener should be restarted within the same VM.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org