SourceForge has been redesigned. Learn more.
Close

#20 TelnetD.shutdown() does not shut down completely

v1.0
open
nobody
5
2006-05-15
2006-05-15
No

After calling TelnetD.shutdown(), the PortListener is
not taken down. Even though the socket is closed, the
accept keeps on waiting for connection forever.

This is my modified code of the run() method (from line
88). It sets SoTimeout and catches and ignores
InterruptedIOException.

[code]
public void run() {
try {
/*
A server socket is opened with a connectivity
queue of a size specified
in int floodProtection. Concurrent login
handling under normal circumstances
should be handled properly, but denial of
service attacks via massive parallel
program logins should be prevented with this.
*/
m_ServerSocket = new ServerSocket(m_Port,
m_FloodProtection);
m_ServerSocket.setSoTimeout(5000);

//log entry
Object[] args = {new Integer(m_Port), new
Integer(m_FloodProtection)};
TelnetD.syslog.write(MessageFormat.format(logmsg,
args));

//Infinite loop, taking care of resources in case
of a lot of parallel logins
do {
try {
Socket s = m_ServerSocket.accept();
if (m_Available) {
m_ConnectionManager.makeConnection(s);
} else {
//just shut down the socket
s.close();
}
this.yield();
} catch (java.io.InterruptedIOException e) { }
} while (true);

} catch (IOException e) {
TelnetD.syslog.writeStackTrace(e);
//FIXME: this is a major failure, we should consider
//how to handle it (Recovery?)
System.out.println("OHOH");
}
System.out.println("OHOH");

}//run
[/code]

Discussion


Log in to post a comment.