mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Trudeau" <strud...@bluetreewireless.com>
Subject Mina 2.0-M3 problem with closing a session
Date Thu, 23 Oct 2008 22:25:42 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message