Commit 0998fa33 authored by Jeremy Hylton's avatar Jeremy Hylton

Call notifyDisconnected() on the object handled by a Connection.

parent e80d0649
...@@ -116,20 +116,19 @@ class ZEOStorage: ...@@ -116,20 +116,19 @@ class ZEOStorage:
self.__storage_id = "uninitialized" self.__storage_id = "uninitialized"
self._transaction = None self._transaction = None
def close(self): def notifyConnected(self, conn):
self._conn = conn
self.client = ClientStub.ClientStorage(conn)
def notifyDisconnected(self):
# When this storage closes, we must ensure that it aborts # When this storage closes, we must ensure that it aborts
# any pending transaction. Not sure if this is the clearest way. # any pending transaction. Not sure if this is the clearest way.
if self._transaction is not None: if self._transaction is not None:
self._log("close during transaction %s" % self._transaction, self._log("disconnected during transaction %s" % self._transaction,
zLOG.BLATHER) zLOG.BLATHER)
self.tpc_abort(self._transaction.id) self.tpc_abort(self._transaction.id)
else: else:
self._log("close", zLOG.BLATHER) self._log("disconnected", zLOG.BLATHER)
self._conn.close()
def notifyConnected(self, conn):
self._conn = conn
self.client = ClientStub.ClientStorage(conn)
def __repr__(self): def __repr__(self):
tid = self._transaction and repr(self._transaction.id) tid = self._transaction and repr(self._transaction.id)
...@@ -392,7 +391,7 @@ class ZEOStorage: ...@@ -392,7 +391,7 @@ class ZEOStorage:
except: except:
self._log("Unexpected error handling waiting transaction", self._log("Unexpected error handling waiting transaction",
level=zLOG.WARNING, error=sys.exc_info()) level=zLOG.WARNING, error=sys.exc_info())
zeo_storage.close() zeo_storage._conn.close()
return 0 return 0
else: else:
return 1 return 1
......
...@@ -389,9 +389,10 @@ class ManagedServerConnection(ServerConnection): ...@@ -389,9 +389,10 @@ class ManagedServerConnection(ServerConnection):
def __init__(self, sock, addr, obj, mgr): def __init__(self, sock, addr, obj, mgr):
self.__mgr = mgr self.__mgr = mgr
self.__super_init(sock, addr, obj) self.__super_init(sock, addr, obj)
obj.notifyConnected(self) self.obj.notifyConnected(self)
def close(self): def close(self):
self.obj.notifyDisconnected()
self.__super_close() self.__super_close()
self.__mgr.close(self) self.__mgr.close(self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment