[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.” 

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.

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.