[ 
https://issues.apache.org/jira/browse/DIRMINA-382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506934
 ] 

Kenji Hollis commented on DIRMINA-382:
--------------------------------------

Well, to me, "shutdown()" implies that the socket will not only close, but also 
refuse further connections.

Why not "closeOnFlush()" or "closeOnDrain()"?  AFAIK, there's no way to find 
out if a write session has more bytes to empty to a connected socket, ie. 
"bytesRemaining()" method.  One way this could be accomplished is if the close 
flag is set, and the bytesRemaining() is greater than 0, the socket will not 
close unless the socket data has been drained.

Of course, this would imply that "close()" means an immediate close, regardless 
of whether or not data is remaining to send in the IoSession object.  You could 
also handle this in the overridden IoFilter, or in the IoHandlerAdapter class, 
checking in the messageSent() element.  I believe "getScheduledWriteBytes() == 
0" would be a good way to close the connection after the write completes, but 
I've not tested how accurate this function is, or if it actually returns the 
number of bytes left to drain, accurately.  It always returns a 0 for me ...

> Provide a close() method that doesn't close the connection until all messages 
> are written.
> ------------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-382
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-382
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Trustin Lee
>             Fix For: 2.0.0-M1
>
>
> Currently, IoSession.close() closes the connection immediately no matter how 
> many messages are not written yet.  Calling close() will discard all pending 
> writes and close the connection immediately.  Although we can add a 
> IoFutureListener.CLOSE to the last WriteFuture, it will be more convenient to 
> provide another close method that doesn't close the connection until all 
> message are written.  
> Adding a boolean parameter to the close method will be fine. Of course, 
> original method without a parameter will be retained.
> To implement this, the implementation should satisfy the following condition.
> 1) IoSession.isClosing() must return true after close() is called no matter 
> what boolean parameter is specified.
> 2) The session should be closed after all messages are written out.

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

Reply via email to