I did not have much time to investigate but have found out that session.close() would always work when invoked inside the NIOProcessor thread but would always fail when invoked from my thread pool...
If somebody ever finds out why, please let me know ;.P Simon -----Original Message----- From: Simon Trudeau [mailto:[EMAIL PROTECTED] Sent: October-23-08 6:26 PM To: [email protected] Subject: Mina 2.0-M3 problem with closing a session I am using mina 2.0-M3 and trying a close a session. It is very weird because when I invoke the iosession.close(), the IoFutureListener<CloseFuture> never gets invoked. It looks like it is waiting indefinitely. Is there a threading requirement for invoking the iosession.close() method? I am currently invoking this method from a threadpool. What would make the iosession.close() block (not execute) What is very weird is that a session will properly close on an idle timeout if I set one and it will also properly close if the remote peer closes the connection. I tried running jhat on my software and no deadlocks were found. Here's my code that invokes the iosession.close: ***************************************** public void disconnect(InetSocketAddress remoteAddress) { String address = remoteAddress.getAddress().getHostAddress()+":"+remoteAddress.getPort(); ConnectFuture future = pendingSessionMap.get(address); if(future != null) { /* * If there is an ongoing connection attempt, cancel it. */ synchronized(pendingSessionMap) { future.cancel(); pendingSessionMap.remove(address); } try { IoSession session = future.getSession(); if(session != null ) { System.out.println("attempting to close the session"); CloseFuture closeFuture = session.close(false); closeFuture.addListener(new IoFutureListener<CloseFuture>(){ public void operationComplete(CloseFuture future) { IoSession session = future.getSession(); ModemStatusMsg modemStatusMsg = (ModemStatusMsg)session.getAttribute("modem.modemStatusMsg"); modemStatusMsg.setStatus(ModemNetworkStatus.MODEM_DISCONNECTING); jmsSender.send(modemStatusMsg); if(logger.isDebugEnabled()) { logger.debug("Closed session to "+future.getSession().getAttribute("session.remoteAddress")+" (Normal termination)"); } }}); } } catch(RuntimeIoException ex) { if(logger.isDebugEnabled()) { logger.debug("Failed closing session to "+remoteAddress.getAddress().toString()+":"+remoteAddress.getPort(), ex); } } } System.out.println("done"); } ******************************** Any ideas would be really appreciated, Thanks, Simon
