Issue Details (XML | Word | Printable)

Key: DIRMINA-49
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Trustin Lee
Reporter: Julien Vermillard
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
MINA

MINA doesn't close unused selectors

Created: 01/Jun/05 05:08 PM   Updated: 07/Jun/05 05:54 PM
Return to search
Component/s: None
Affects Version/s: 0.7.1
Fix Version/s: 0.7.2

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works ConnectionTest.java 2005-06-01 05:28 PM Julien Vermillard 0.9 kB
Environment:
A computer try to connect to an unavaible TCP port, and retry every seconds simply using :
session = connector.connect(new InetSocketAddress(hostname, port),protocolProvider);
after some times this exception is fired :
java.io.IOException: Too many open files
at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:145)
at org.apache.mina.io.socket.SocketAcceptor$Worker.processSessions(SocketAcceptor.java:282)
at org.apache.mina.io.socket.SocketAcceptor$Worker.run(SocketAcceptor.java:233)

Resolution Date: 07/Jun/05 10:32 AM


 Description  « Hide
(09:56:19) vrm: ran in a strange exception :
(09:56:20) vrm: 1 juin 2005 09:53:56 org.apache.mina.common.DefaultExceptionMonitor exceptionCaught
ATTENTION: Unexpected exception.
java.io.IOException: Too many open files
at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:145)
at org.apache.mina.io.socket.SocketAcceptor$Worker.processSessions(SocketAcceptor.java:282)
at org.apache.mina.io.socket.SocketAcceptor$Worker.run(SocketAcceptor.java:233)
(09:56:46) trustin: Too many open files..
(09:57:13) vrm: yep I try to connect to some devices who are offlines
(09:57:20) vrm: and I retry every 2 seconds
(09:57:46) trustin: devices offline? Could you explain it more?
(09:58:43) vrm: my server try to connect to another computer (SockectConnector), but the computer is down
(09:59:15) vrm: session = connector.connect(new InetSocketAddress(hostname, port),protocolProvider);
(09:59:26) vrm: it throw an IOException
(09:59:31) vrm: (of course)
(09:59:47) vrm: and my program try to reconnect 2 seconds later
(09:59:57) trustin: Ahhhhh I see.
(10:00:08) trustin: It seems like the it doesn't clean up failed socket.
(10:00:15) trustin: Could you post it to JIRA?
(10:00:28) trustin: I'll try to fix it tonight or tomorrow morning.
(10:00:37) vrm: you know where I can see if it's cleaned or not ? (it's perhaps in my code)
(10:01:18) vrm: before I post a nobug in jira :)
(10:01:52) trustin: You can't see its cleaned or not from outside of MINA.
(10:02:36) vrm: ok
(10:02:41) vrm: I post it

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Julien Vermillard added a comment - 01/Jun/05 05:15 PM
The code exatly do that in the loop:
IoProtocolConnector connector = new IoProtocolConnector(new SocketConnector());
session = connector.connect(new InetSocketAddress(hostname, port),protocolProvider);

Julien Vermillard added a comment - 01/Jun/05 05:28 PM
test case trying to connect to localhost on 9999 port (should be unavaible) and wait for "Too many file open" for fail

Julien Vermillard added a comment - 01/Jun/05 05:41 PM
if I remove "connector = new IoProtocolConnector(new SocketConnector());" of the loop it works so it's my fault

Trustin Lee added a comment - 01/Jun/05 06:08 PM
Failed connection attempt doesn't seem to cause FD leak, but I forgot to close unused Selectors in SessionManager implementations. So this issue is still valid. Julien, Thanks for your report!

Trustin Lee added a comment - 07/Jun/05 10:32 AM
I cheked in the fix, and it seems to work great.

Julien Vermillard added a comment - 07/Jun/05 05:54 PM
tested works