Author: rhs
Date: Thu Jan 22 10:55:12 2009
New Revision: 736742

URL: http://svn.apache.org/viewvc?rev=736742&view=rev
Log:
ensure that we always close the socket, even if the other end doesn't

Modified:
    qpid/trunk/qpid/python/qpid/connection.py
    qpid/trunk/qpid/python/qpid/delegates.py

Modified: qpid/trunk/qpid/python/qpid/connection.py
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/connection.py?rev=736742&r1=736741&r2=736742&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/connection.py (original)
+++ qpid/trunk/qpid/python/qpid/connection.py Thu Jan 22 10:55:12 2009
@@ -71,8 +71,11 @@
     self.sessions = {}
 
     self.condition = Condition()
+    # XXX: we should combine this into a single comprehensive state
+    # model (whatever that means)
     self.opened = False
     self.failed = False
+    self.closed = False
     self.close_code = (None, "connection aborted")
 
     self.thread = Thread(target=self.run)
@@ -160,15 +163,14 @@
       raise ConnectionFailed(*self.close_code)
 
   def run(self):
-    # XXX: we don't really have a good way to exit this loop without
-    # getting the other end to kill the socket
-    while True:
+    while not self.closed:
       try:
         seg = self.read_segment()
       except Closed:
         self.detach_all()
         break
       self.delegate.received(seg)
+    self.sock.close()
 
   def close(self, timeout=None):
     if not self.opened: return

Modified: qpid/trunk/qpid/python/qpid/delegates.py
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/delegates.py?rev=736742&r1=736741&r2=736742&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/delegates.py (original)
+++ qpid/trunk/qpid/python/qpid/delegates.py Thu Jan 22 10:55:12 2009
@@ -59,6 +59,7 @@
 
   def connection_close_ok(self, ch, close_ok):
     self.connection.opened = False
+    self.connection.closed = True
     notify(self.connection.condition)
 
   def connection_heartbeat(self, ch, hrt):



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscr...@qpid.apache.org

Reply via email to