Issue Details (XML | Word | Printable)

Key: DIRMINA-110
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Trustin Lee
Reporter: Trustin Lee
Votes: 0
Watchers: 0
Operations

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

Exceptions thrown while writing data are not reported.

Created: 28/Oct/05 11:28 PM   Updated: 28/Oct/05 11:31 PM
Return to search
Component/s: None
Affects Version/s: 0.8.0
Fix Version/s: 0.8.1

Time Tracking:
Not Specified

Resolution Date: 28/Oct/05 11:31 PM


 Description  « Hide
Niklas Therning wrote:

Hi,

While working on the traffic control implementation I stumbled across a rather nasty bug. When the remote side of a connection has disconnected ch.write() will throw an IOException in the following piece of code. What I've found is that the that exception won't be propagated to the caller (flushSessions()) which has a catch clause for IOException scheduling the session for removal.

for (;;)
{
 ...
 try
 {
   writtenBytes = ch.write( buf.buf() );
 }
 finally
 {
   ...
   if( buf.hasRemaining() )
   {
     ...
     break;
   }
   ...
 }
}

The reason why the exception isn't propagated is the break statement in the finally block. The break causes the thrown IOException to be discarded and the program counter will be positioned right after the end of the for-loop. Since there are still unwritten bytes OP_WRITE will remain on and the selector will wake up immediately on the next iteration. The process will be repeated indefinitely and the CPU will be on 100%.

This bug has probably never appeared before since OP_READ has always been on. If OP_READ is on when the remote side disconnects SocketIoProcessor.read() will handle the removal of the session.

This could be fixed by removing the try and finally statements around this piece of code leaving:

for (;;)
{
 ...
 writtenBytes = ch.write( buf.buf() );
 ...
 if( buf.hasRemaining() )
 {
   ...
   break;
 }
 ...
}


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Trustin Lee made changes - 28/Oct/05 11:31 PM
Field Original Value New Value
Resolution Fixed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]