File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 26
26
#include "caml/memory.h"
27
27
#include "caml/mlvalues.h"
28
28
#include "caml/platform.h"
29
+ #include "caml/signals.h"
29
30
30
31
/* A note about callbacks and GC. For best performance, a callback such as
31
32
[caml_callback_exn(value closure, value arg)]
@@ -494,8 +495,15 @@ CAMLprim value caml_with_async_exns(value body_callback)
494
495
res = caml_callback_exn (body_callback , Val_unit );
495
496
496
497
/* raised as a normal exn, even if it was asynchronous */
497
- if (Is_exception_result (res ))
498
- caml_raise (Extract_exception (res ));
498
+ if (Is_exception_result (res )) {
499
+ /* Drain the queue of pending actions. We may need to do
500
+ this several times if some raise */
501
+ do {
502
+ res = Extract_exception (res );
503
+ res = caml_process_pending_actions_with_root_exn (res );
504
+ } while (Is_exception_result (res ));
505
+ caml_raise (res );
506
+ }
499
507
500
508
return res ;
501
509
}
Original file line number Diff line number Diff line change 23
23
#include "caml/fail.h"
24
24
#include "caml/memory.h"
25
25
#include "caml/mlvalues.h"
26
+ #include "caml/signals.h"
26
27
27
28
static value raise_if_exception (value res )
28
29
{
@@ -278,8 +279,15 @@ CAMLprim value caml_with_async_exns(value body_callback)
278
279
res = caml_callback_exn (body_callback , Val_unit );
279
280
280
281
/* raised as a normal exn, even if it was asynchronous */
281
- if (Is_exception_result (res ))
282
- caml_raise (Extract_exception (res ));
282
+ if (Is_exception_result (res )) {
283
+ /* Drain the queue of pending actions. We may need to do
284
+ this several times if some raise */
285
+ do {
286
+ res = Extract_exception (res );
287
+ res = caml_process_pending_actions_with_root_exn (res );
288
+ } while (Is_exception_result (res ));
289
+ caml_raise (res );
290
+ }
283
291
284
292
return res ;
285
293
}
You can’t perform that action at this time.
0 commit comments