Fix exceptions propagating out of TftpServer.listen()

Signed-off-by: Michael P. Soulier <msoulier@digitaltorque.ca>
master
Kenny Millington 2010-10-18 12:44:02 +01:00 committed by Michael P. Soulier
parent 71d827dd89
commit a6cff4f0b2
2 changed files with 7 additions and 2 deletions

View File

@ -107,7 +107,12 @@ class TftpServer(TftpSession):
timeout,
self.root,
self.dyn_file_func)
self.sessions[key].start(buffer)
try:
self.sessions[key].start(buffer)
except TftpException, err:
deletion_list.append(key)
log.error("Fatal exception thrown from "
"session %s: %s" % (key, str(err)))
else:
log.warn("received traffic on main socket for "
"existing session??")

View File

@ -115,7 +115,7 @@ class TftpContext(object):
called explicitely by the calling code, this works better than the
destructor."""
log.debug("in TftpContext.end")
if not self.fileobj.closed:
if self.fileobj is not None and not self.fileobj.closed:
log.debug("self.fileobj is open - closing")
self.fileobj.close()