mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
SERVER-1841 don't allow client js to catch timeout/interrupt
This commit is contained in:
parent
2c041513a0
commit
e593c1fe4c
@ -63,6 +63,5 @@ doIt( "while( 1 ) { for( var i = 0; i < 10000; ++i ) {;} db.jstests_evald.count(
|
||||
doIt( "while( 1 ) { for( var i = 0; i < 10000; ++i ) {;} db.jstests_evald.count(); }", true );
|
||||
doIt( "while( 1 ) { for( var i = 0; i < 10000; ++i ) {;} db.jstests_evald.count(); }", false );
|
||||
|
||||
// these two are SERVER-1841
|
||||
//doIt( "while( 1 ) { try { db.jstests_evald.count( {i:10} ); } catch ( e ) { } }", true );
|
||||
//doIt( "while( 1 ) { try { while( 1 ) { ; } } catch ( e ) { } }", true );
|
||||
doIt( "while( 1 ) { try { db.jstests_evald.count( {i:10} ); } catch ( e ) { } }", true );
|
||||
doIt( "while( 1 ) { try { while( 1 ) { ; } } catch ( e ) { } }", true );
|
||||
|
@ -1352,13 +1352,15 @@ namespace mongo {
|
||||
int count;
|
||||
};
|
||||
|
||||
// should not generate exceptions, as those can be caught in
|
||||
// javascript code; returning false without an exception exits
|
||||
// immediately
|
||||
static JSBool _interrupt( JSContext *cx ){
|
||||
TimeoutSpec &spec = *(TimeoutSpec *)( JS_GetContextPrivate( cx ) );
|
||||
if ( ++spec.count % 1000 != 0 )
|
||||
return JS_TRUE;
|
||||
const char * interrupt = ScriptEngine::checkInterrupt();
|
||||
if ( interrupt && interrupt[ 0 ] ) {
|
||||
JS_ReportError( cx, interrupt );
|
||||
return JS_FALSE;
|
||||
}
|
||||
if ( spec.timeout.ticks() == 0 ) {
|
||||
@ -1368,7 +1370,6 @@ namespace mongo {
|
||||
if ( elapsed < spec.timeout ) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError( cx, "Timeout exceeded" );
|
||||
return JS_FALSE;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user