You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Trustin Lee (JIRA)" <ji...@apache.org> on 2007/02/14 11:31:06 UTC
[jira] Resolved: (DIRMINA-347) Server: StreamIoHandler does not
close InputStream and OutputStream on sessionClosed()
[ https://issues.apache.org/jira/browse/DIRMINA-347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Trustin Lee resolved DIRMINA-347.
---------------------------------
Resolution: Fixed
Fix Version/s: 1.0.2
Assignee: Trustin Lee
Your patch has been applied to all branches. Thanks!
> Server: StreamIoHandler does not close InputStream and OutputStream on sessionClosed()
> --------------------------------------------------------------------------------------
>
> Key: DIRMINA-347
> URL: https://issues.apache.org/jira/browse/DIRMINA-347
> Project: MINA
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.0.1
> Environment: Ubuntu 6.06
> Reporter: Eric Fitchett
> Assigned To: Trustin Lee
> Priority: Minor
> Fix For: 1.0.2
>
> Attachments: StreamIoHandler_CloseStreams.diff
>
>
> When reading from the InputStream provided by StreamIoHandler, the read can block indefinitely if the client closes the connection.
> This is caused by the StreamIoHandler not closing the provided streams in the sessionClosed() method. The InputStream remains open, waiting for more data. After many connections, there may be a large number of "zombie" threads that will never wake up.
> I will upload a patch to fix this problem. In the mean time, a workaround I am currently using follows. It keeps track of the InputStream for each session, and closes it when the session closes. This ensures the thread has a chance to terminate properly.
> protected final void processStreamIo(
> IoSession session,
> InputStream in,
> OutputStream out) {
> sessionStreams.put(session, in);
> // Process the streams in a separate thread
> new Worker(in, out).start();
> }
> // Ensures session's InputStream gets closed, so the thread doesn't lock up
> private Map<IoSession,InputStream> sessionStreams = new HashMap<IoSession, InputStream>();
> @Override
> public void sessionClosed(IoSession session) throws Exception {
> super.sessionClosed(session);
> InputStream is = sessionStreams.get(session);
> if(null != is) {
> try {
> is.close();
> } catch(IOException ioe) {
> // Ignore
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.