summaryrefslogtreecommitdiff
path: root/src/mongo/scripting
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2013-04-03 16:50:46 -0400
committerMathias Stearn <mathias@10gen.com>2013-04-03 17:24:19 -0400
commited3b8e1af9b629c99b433c818c0e9314bce405ee (patch)
tree9c599b22e78e927e5592cb7764063cd9b0a97dbd /src/mongo/scripting
parent8911cdf312fba509ab20f31b56fc614d13e0d1ee (diff)
downloadmongo-ed3b8e1af9b629c99b433c818c0e9314bce405ee.tar.gz
SERVER-9230: fix issue causing persistent v8 objects not to be tracked
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r--src/mongo/scripting/engine_v8.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/scripting/engine_v8.h b/src/mongo/scripting/engine_v8.h
index 06cc7c37e29..28cd25494f6 100644
--- a/src/mongo/scripting/engine_v8.h
+++ b/src/mongo/scripting/engine_v8.h
@@ -64,17 +64,18 @@ namespace mongo {
*/
void track(v8::Persistent<v8::Value> instanceHandle, _ObjType* instance) {
TrackedPtr* collectionHandle = new TrackedPtr(instance, this);
+ _container.insert(collectionHandle);
instanceHandle.MakeWeak(collectionHandle, deleteOnCollect);
}
/**
- * Free any remaining objects which are being tracked. Invoked when
- * the V8Scope is destructed.
+ * Free any remaining objects and their TrackedPtrs. Invoked when the
+ * V8Scope is destructed.
*/
~ObjTracker() {
if (!_container.empty())
LOG(1) << "freeing " << _container.size() << " uncollected "
<< typeid(_ObjType).name() << " objects" << endl;
- typename set<_ObjType*>::iterator it = _container.begin();
+ typename set<TrackedPtr*>::iterator it = _container.begin();
while (it != _container.end()) {
delete *it;
_container.erase(it++);
@@ -91,7 +92,7 @@ namespace mongo {
TrackedPtr(_ObjType* instance, ObjTracker<_ObjType>* tracker) :
_objPtr(instance),
_tracker(tracker) { }
- _ObjType* _objPtr;
+ scoped_ptr<_ObjType> _objPtr;
ObjTracker<_ObjType>* _tracker;
};
@@ -103,14 +104,13 @@ namespace mongo {
*/
static void deleteOnCollect(v8::Persistent<v8::Value> instanceHandle, void* rawData) {
TrackedPtr* trackedPtr = static_cast<TrackedPtr*>(rawData);
- trackedPtr->_tracker->_container.erase(trackedPtr->_objPtr);
- delete trackedPtr->_objPtr;
+ trackedPtr->_tracker->_container.erase(trackedPtr);
delete trackedPtr;
instanceHandle.Dispose();
}
- // container for all instances of the tracked _ObjType
- set<_ObjType*> _container;
+ // container for all TrackedPtrs created by this ObjTracker instance
+ set<TrackedPtr*> _container;
};
/**