Fix for AVATAR_JS-149, IdleHandle to process ticks in case of fatal error.
Reviewed-by: asquare
This commit is contained in:
parent
0dbecd53e6
commit
dc6cfa955f
|
@ -72,7 +72,7 @@ public final class EventLoop {
|
|||
private Callback isHandlerRegistered = null;
|
||||
private Callback uncaughtExceptionHandler = null;
|
||||
private Exception pendingException = null;
|
||||
|
||||
private boolean syncEventsProcessing = true;
|
||||
private ScriptObjectMirror domain;
|
||||
|
||||
public static final class Handle implements AutoCloseable {
|
||||
|
@ -164,10 +164,19 @@ public final class EventLoop {
|
|||
} else {
|
||||
processEvent(event);
|
||||
}
|
||||
|
||||
if (!syncEventsProcessing) {
|
||||
// Will be handled in an IdleHandle
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableSyncEventsProcessing(boolean enable) {
|
||||
syncEventsProcessing = enable;
|
||||
}
|
||||
|
||||
private void processEvent(final Event event) throws Exception {
|
||||
processEvent(event.getName(), event.getCallback(), event.getContext(), event.getArgs());
|
||||
}
|
||||
|
|
|
@ -248,8 +248,11 @@ var gc = global.gc;
|
|||
// exit is handled in the class that is catching the rethrown er
|
||||
if (!caught) {
|
||||
throw er;
|
||||
} else {
|
||||
// if we handled an error, then make sure any ticks get processed
|
||||
process._needTickCallback();
|
||||
}
|
||||
|
||||
|
||||
return caught;
|
||||
};
|
||||
|
||||
|
|
|
@ -643,7 +643,7 @@ exports._usingDomains = function() {
|
|||
}, process.domain)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, 'domain', {
|
||||
enumerable : true,
|
||||
|
@ -670,6 +670,26 @@ checkHandle.unref();
|
|||
var idleHandle = new IdleHandle(eventloop.loop());
|
||||
idleHandle.setIdleCallback(IdleCallbackHandler);
|
||||
|
||||
// Handle the nextTick in a UV callback
|
||||
var spinnerHandle = new IdleHandle(eventloop.loop());
|
||||
spinnerHandle.setIdleCallback(spin);
|
||||
var need_tick_cb = false;
|
||||
function spin() {
|
||||
if (!need_tick_cb) {
|
||||
return;
|
||||
}
|
||||
need_tick_cb = false;
|
||||
eventloop.enableSyncEventsProcessing(true);
|
||||
spinnerHandle.stop();
|
||||
exports._tickCallback();
|
||||
}
|
||||
|
||||
exports._needTickCallback = function() {
|
||||
need_tick_cb = true;
|
||||
eventloop.enableSyncEventsProcessing(false);
|
||||
spinnerHandle.start();
|
||||
}
|
||||
|
||||
function checkImmediate() {
|
||||
// This needs to be treated as a callback, all ticked events need to be handled.
|
||||
if (exports._immediateCallback) {
|
||||
|
|
Loading…
Reference in New Issue