Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26330/Modeling
Modified Files:
DatabaseChannel.py
Log Message:
* Fixed: DatabaseChannel.fetchObject(): it was possible for a snapshot to
be cleared from the cache while initializeObject() was in progress (this
could happen when another EC was garbage-collected in another thread e.g.)
This happened because at this point, the database's lock is released. To
prevent the problem, the snapshot's count is incremented before releasing
the database's lock, and decremented only after initialzeObject() has
returned.
Index: DatabaseChannel.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseChannel.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** DatabaseChannel.py 20 Jul 2004 06:21:36 -0000 1.18
--- DatabaseChannel.py 25 Feb 2006 12:32:33 -0000 1.19
***************
*** 133,143 ****
import time
currentTimestamp=time.time() # for snapshots
! dict=self._adaptorChannel.fetchRow()
! if dict is None:
self.cancelFetch() # No more objects
return None
! globalID=self._currentEntity.globalIDForRow(dict)
if self.fetchesRawRows():
--- 133,143 ----
import time
currentTimestamp=time.time() # for snapshots
! raw_row=self._adaptorChannel.fetchRow()
! if raw_row is None:
self.cancelFetch() # No more objects
return None
! globalID=self._currentEntity.globalIDForRow(raw_row)
if self.fetchesRawRows():
***************
*** 153,163 ****
return registeredSnapshot
else:
! return dict
else:
! return dict
# Get snapshot
! #snapshot=self._currentEntity.snapshotForRow(dict)
! snapshot=dict
database=self.databaseContext().database()
--- 153,163 ----
return registeredSnapshot
else:
! return raw_row
else:
! return raw_row
# Get snapshot
! #snapshot=self._currentEntity.snapshotForRow(raw_row)
! snapshot=raw_row
database=self.databaseContext().database()
***************
*** 189,192 ****
--- 189,193 ----
# since the corresponding snapshot has been thrown away.
#
+ snapshot_refcount_incremented = False
database.lock()
try:
***************
*** 260,272 ****
ec.recordObject(object, globalID)
! # Initialize the new object or the cleared fault
! try:
! object.clearFault()
! except:
! pass
! ec.initializeObject(object, globalID, ec)
finally:
database.unlock()
return object
--- 261,282 ----
ec.recordObject(object, globalID)
!
! database.incrementSnapshotCountForGlobalID(globalID)
! snapshot_refcount_incremented = True
finally:
database.unlock()
+ # Initialize the new object or the cleared fault
+ try:
+ object.clearFault()
+ except:
+ pass
+
+ try:
+ ec.initializeObject(object, globalID, ec)
+ finally:
+ if snapshot_refcount_incremented:
+ database.decrementSnapshotCountForGlobalID(globalID)
+
return object
|