|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 3/3] libxl: ocaml: use 'for_app_registration' in osevent callbacks
I forgot to reply to this:
On 12 Dec 2013, at 17:40, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
>> [...]
>> + for_app = malloc(sizeof(value));
>> + if (for_app) {
>> + *for_app = caml_callbackN(*func, 4, args);
>
> Can the callbackN fail, eg. returning an exception or something?
Yes, it can:
"If the function f does not return, but raises an exception that escapes the
scope of the application, then this exception is propagated to the next
enclosing OCaml code, skipping over the C code. That is, if an OCaml function f
calls a C function g that calls back an OCaml function h that raises a stray
exception, then the execution of g is interrupted and the exception is
propagated back into f.”
[http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual033.html#toc148]
It is possible to catch the exception in C, e.g.:
res = caml_callbackN_exn(*func, 4, args);
if(Is_exception_result(res)) {
res = Extract_exception(res);
...
Perhaps it makes sense to do this, and return ERROR_OSEVENT_REG_FAIL when we
catch an exception.
Cheers,
Rob
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |