[SNMP4J] resource leak on failed connect in AgentXSubagent.connect()

Sachs, Larry lsachs at c-cor.com
Fri Mar 16 19:21:18 CET 2007


Hi,

 

One last request (seems only to be necessary for solaris).  In
DefaultTcpTransportMapping.ServerThread.close(), please add the
following to ensure that the selector is closed.  

 

      public void close() {

        stop = true;

        ServerThread st = server;

        if (st != null) {

          st.interrupt();

        }

+       if ((selector != null) && selector.isOpen()) {

+         try {

+           selector.close();

+         }

+         catch (IOException e) {

+           logger.error(e);

+         }

+       }

      }

    }

 

It seems that on solaris, when the connection to the master agent fails,
ServerThread.run() never starts so that the previous code that works for
linux and windows is never executed and selectors are left open.  Along
with the previous change, this will prevent resource leaks on failed
connections.

 

Thank you,

ls





More information about the SNMP4J mailing list