Commit 0fe92131 authored by Shane Hathaway's avatar Shane Hathaway

Fixed a race condition in close callbacks and corrected what may have been

a memory leak in mounted databases.
parent 7d0a92de
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
"""Database connection support """Database connection support
$Id: Connection.py,v 1.38 2000/09/07 21:53:47 jim Exp $""" $Id: Connection.py,v 1.39 2000/09/21 21:34:31 shane Exp $"""
__version__='$Revision: 1.38 $'[11:-2] __version__='$Revision: 1.39 $'[11:-2]
from cPickleCache import PickleCache from cPickleCache import PickleCache
from POSException import ConflictError, ExportError from POSException import ConflictError, ExportError
...@@ -242,11 +242,8 @@ class Connection(ExportImport.ExportImport): ...@@ -242,11 +242,8 @@ class Connection(ExportImport.ExportImport):
def close(self): def close(self):
self._incrgc() # This is a good time to do some GC self._incrgc() # This is a good time to do some GC
db=self._db db=self._db
self._db=self._storage=self._tmp=self.new_oid=self._opened=None
self._debug_info=()
db._closeConnection(self)
# Call the close callback # Call the close callbacks.
for f in self.__onCloseCallbacks: for f in self.__onCloseCallbacks:
try: f() try: f()
except: except:
...@@ -254,7 +251,11 @@ class Connection(ExportImport.ExportImport): ...@@ -254,7 +251,11 @@ class Connection(ExportImport.ExportImport):
LOG('ZODB',ERROR, 'Close callback failed for %s' % f, LOG('ZODB',ERROR, 'Close callback failed for %s' % f,
error=sys.exc_info()) error=sys.exc_info())
self.__onCloseCallbacks=() self.__onCloseCallbacks=()
self._db=self._storage=self._tmp=self.new_oid=self._opened=None
self._debug_info=()
# Return the connection to the pool.
db._closeConnection(self)
def commit(self, object, transaction, _type=type, _st=type('')): def commit(self, object, transaction, _type=type, _st=type('')):
oid=object._p_oid oid=object._p_oid
invalid=self._invalid invalid=self._invalid
......
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
"""Mounted database support """Mounted database support
$Id: Mount.py,v 1.5 2000/08/03 19:56:35 shane Exp $""" $Id: Mount.py,v 1.6 2000/09/21 21:34:31 shane Exp $"""
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
import Globals, thread, Persistence, Acquisition import Globals, thread, Persistence, Acquisition
import ExtensionClass, string, time, sys import ExtensionClass, string, time, sys
...@@ -202,6 +202,7 @@ class MountPoint(Persistence.Persistent, Acquisition.Implicit): ...@@ -202,6 +202,7 @@ class MountPoint(Persistence.Persistent, Acquisition.Implicit):
# and possibly the database itself. # and possibly the database itself.
t = self._v_data t = self._v_data
if t is not None: if t is not None:
self._v_data = None
data = t[0] data = t[0]
if getattr(data, '_v__object_deleted__', 0): if getattr(data, '_v__object_deleted__', 0):
# This mount point has been deleted. # This mount point has been deleted.
...@@ -212,8 +213,8 @@ class MountPoint(Persistence.Persistent, Acquisition.Implicit): ...@@ -212,8 +213,8 @@ class MountPoint(Persistence.Persistent, Acquisition.Implicit):
if conn is not None: if conn is not None:
try: del conn._mount_parent_jar try: del conn._mount_parent_jar
except: pass except: pass
conn.close() if conn._db is not None:
self._v_data = None conn.close()
if self._v_close_db: if self._v_close_db:
# Stop using this database. Close it if no other # Stop using this database. Close it if no other
# MountPoint is using it. # MountPoint is using it.
......
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