summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-09-01 14:23:36 -0400
committerEliot Horowitz <eliot@10gen.com>2009-09-01 14:23:36 -0400
commit184870bf95a09ae696d0c1e2326d5145186b1170 (patch)
treea7dd2507a9c47d3d0bcc22660502b922db1715b7 /scripting
parent7e03b602ecf97eeaa61246de9fb6e5e2119d084d (diff)
downloadmongo-184870bf95a09ae696d0c1e2326d5145186b1170.tar.gz
support JS_SetOperationCallback in sm 1.8.1 SERVER-167
Diffstat (limited to 'scripting')
-rw-r--r--scripting/engine_spidermonkey.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp
index 878473fa164..80b01a5eb21 100644
--- a/scripting/engine_spidermonkey.cpp
+++ b/scripting/engine_spidermonkey.cpp
@@ -1126,7 +1126,7 @@ namespace mongo {
int count;
};
- static JSBool checkTimeout( JSContext *cx, JSScript *script ) {
+ static JSBool _checkTimeout( JSContext *cx ){
TimeoutSpec &spec = *(TimeoutSpec *)( JS_GetContextPrivate( cx ) );
if ( ++spec.count % 1000 != 0 )
return JS_TRUE;
@@ -1136,16 +1136,13 @@ namespace mongo {
}
JS_ReportError( cx, "Timeout exceeded" );
return JS_FALSE;
- }
-#ifdef SM181
-#warning JS_SetOperationCallback not supported yet
- void installCheckTimeout( int timeoutMs ) {
}
-
- void uninstallCheckTimeout( int timeoutMs ){
+ static JSBool checkTimeout( JSContext *cx, JSScript *script ){
+ return _checkTimeout( cx );
}
-#else
+
+
void installCheckTimeout( int timeoutMs ) {
if ( timeoutMs > 0 ) {
TimeoutSpec *spec = new TimeoutSpec;
@@ -1153,18 +1150,26 @@ namespace mongo {
spec->start = boost::posix_time::microsec_clock::local_time();
spec->count = 0;
JS_SetContextPrivate( _context, (void*)spec );
+#ifdef SM181
+ JS_SetOperationCallback( _context, _checkTimeout );
+#else
JS_SetBranchCallback( _context, checkTimeout );
+#endif
}
}
void uninstallCheckTimeout( int timeoutMs ) {
if ( timeoutMs > 0 ) {
+#ifdef SM181
+ JS_SetOperationCallback( _context , 0 );
+#else
JS_SetBranchCallback( _context, 0 );
+#endif
delete (TimeoutSpec *)JS_GetContextPrivate( _context );
JS_SetContextPrivate( _context, 0 );
}
}
-#endif
+
void precall(){
_error = "";
currentScope.reset( this );