Skip to content
Browse files

Don't abort when enif_send fails.

Either ignore the error assuming we're about to be garbage collected
or raise an error in the JS context. I need to figure out how to make
this exception uncatchable.
  • Loading branch information...
1 parent 5647e8f commit acd5638d5633c35a991457fd71393b53a1f4f2e1 @davisp committed Sep 2, 2010
Showing with 7 additions and 7 deletions.
  1. +7 −7 c_src/vm.c
View
14 c_src/vm.c
@@ -132,9 +132,12 @@ jserl_send(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
env = enif_alloc_env();
mesg = vm_mk_message(env, to_erl(env, cx, argv[0]));
+ // If pid is not alive, raise an error.
+ // XXX: Can I make this uncatchable?
if(!enif_send(NULL, &(vm->curr_job->pid), env, mesg))
{
- assert(0 && "Failed to send message.");
+ JS_ReportError(cx, "Context closing.");
+ return JS_FALSE;
}
job = queue_receive(vm->jobs);
@@ -306,11 +309,8 @@ vm_run(void* arg)
JS_EndRequest(cx);
JS_MaybeGC(cx);
- // XXX: Should we just log this? Or ignore it?
- if(!enif_send(NULL, &(job->pid), job->env, resp))
- {
- assert(0 && "Failed to send response for job.");
- }
+ // XXX: If pid is not alive, we just ignore it.
+ enif_send(NULL, &(job->pid), job->env, resp);
job_destroy(job);
}
@@ -551,4 +551,4 @@ vm_mk_message(ErlNifEnv* env, ENTERM data)
{
ENTERM message = util_mk_atom(env, "message");
return enif_make_tuple2(env, message, data);
-}
+}

0 comments on commit acd5638

Please sign in to comment.
Something went wrong with that request. Please try again.