mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel L├ęcharny <elecha...@gmail.com>
Subject [MINA 3] NioTcpServer bind() potential issue
Date Sun, 22 Jul 2012 20:21:51 GMT

while checking the Mina 3 code, I saw that the NioTcpServer bind() 
method might potentially leads to losing some events, if I'm not wrong.

The bind() method does this :

     public synchronized void bind(final SocketAddress localAddress) 
throws IOException {
         serverChannel = ServerSocketChannel.open(); <<---------- here, 
the channel is not ready to accept incoming requests
         serverChannel.socket().bind(address); <<---- !!! Now, the 
server can receive incoming connections

         acceptProcessor = this.strategy.getSelectorForBindNewAddress();

         acceptProcessor.addServer(this); <<--- We then create the 
selector here

So we can open a serveur socket, but we are not ready yet to process the 
requests...Woudln't it make more sense to let the acceptProcessor do the 
bind ?

Emmanuel L├ęcharny

View raw message