summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Millington <kenny@helios.(none)>2010-10-18 12:44:02 +0100
committerMichael P. Soulier <msoulier@digitaltorque.ca>2010-10-22 20:33:23 -0400
commita6cff4f0b23068218849e44718e7255b634a9872 (patch)
treeba5042b98901a37eee9b381c909f78bf79dd4c3d
parent71d827dd89b78424f5d89e712e0a189ca2fcc71d (diff)
downloadtftpy-a6cff4f0b23068218849e44718e7255b634a9872.tar.gz
Fix exceptions propagating out of TftpServer.listen()
Signed-off-by: Michael P. Soulier <msoulier@digitaltorque.ca>
-rw-r--r--tftpy/TftpServer.py7
-rw-r--r--tftpy/TftpStates.py2
2 files changed, 7 insertions, 2 deletions
diff --git a/tftpy/TftpServer.py b/tftpy/TftpServer.py
index f943b93..9e64d83 100644
--- a/tftpy/TftpServer.py
+++ b/tftpy/TftpServer.py
@@ -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??")
diff --git a/tftpy/TftpStates.py b/tftpy/TftpStates.py
index c521e51..142029c 100644
--- a/tftpy/TftpStates.py
+++ b/tftpy/TftpStates.py
@@ -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()