closes #19: kill underlings with system level interrupts
This commit is contained in:
@@ -88,10 +88,29 @@ JSC_CCALL(os_mailbox_push,
|
||||
|
||||
const char *id = JS_ToCString(js, argv[0]);
|
||||
int exist = actor_exists(id);
|
||||
JS_FreeCString(js,id);
|
||||
if (!exist)
|
||||
return JS_ThrowInternalError(js, "No mailbox found for given ID");
|
||||
|
||||
if (!exist) {
|
||||
JS_FreeCString(js,id);
|
||||
return JS_ThrowInternalError(js, "No mailbox found for given ID");
|
||||
}
|
||||
|
||||
cell_rt *target = get_actor(id);
|
||||
JS_FreeCString(js,id);
|
||||
|
||||
JSValue sys = JS_GetPropertyStr(js, argv[1], "__SYSTEM__");
|
||||
if (!JS_IsUndefined(sys)) {
|
||||
const char *k = JS_ToCString(js,sys);
|
||||
int stop = 0;
|
||||
if (strcmp(k, "stop") == 0) {
|
||||
stop = 1;
|
||||
actor_disrupt(target);
|
||||
}
|
||||
JS_FreeValue(js,sys);
|
||||
JS_FreeCString(js,k);
|
||||
|
||||
if (stop) return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
void *data = value2wota(js, argv[1], JS_UNDEFINED);
|
||||
|
||||
const char *err = send_message(id, data);
|
||||
@@ -138,11 +157,6 @@ JSC_SCALL(actor_setname,
|
||||
rt->name = strdup(str);
|
||||
)
|
||||
|
||||
JSC_CCALL(actor_testfn,
|
||||
cell_rt *crt = js2actor(js, argv[0]);
|
||||
printf("actor? %p\n", crt);
|
||||
)
|
||||
|
||||
JSC_CCALL(actor_on_exception,
|
||||
cell_rt *rt = JS_GetContextOpaque(js);
|
||||
JS_FreeValue(js, rt->on_exception);
|
||||
@@ -159,7 +173,6 @@ static const JSCFunctionListEntry js_actor_funcs[] = {
|
||||
MIST_FUNC_DEF(os, unneeded, 2),
|
||||
MIST_FUNC_DEF(actor, disrupt, 0),
|
||||
MIST_FUNC_DEF(actor, setname, 1),
|
||||
MIST_FUNC_DEF(actor, testfn, 1),
|
||||
MIST_FUNC_DEF(actor, on_exception, 1),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user