Skip to content

Commit 9537ca1

Browse files
authored
Merge pull request #640 from talex5/cancel-exn
Remove Cancel_hook_failed
2 parents bc1e231 + cf4da1a commit 9537ca1

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

HACKING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ They are run against whichever backend `Eio_main.run` selects, and therefore mus
7676

7777
`lib_eio/tests` tests some internal data structures, such as the lock-free cells abstraction.
7878
The `.md` files in that directory provide a simple walk-through to demonstrate the basic operation,
79-
while `lib_eio/tests/dscheck` uses [dscheck][] to perform exhaustive testing of all atomic interleavings
79+
while `lib_eio/tests/dscheck` uses [dscheck][] to perform exhaustive testing of all atomic interleavings.
8080

8181
At the time of writing, dscheck has some performance problems that make it unusable by default, so
82-
you must use the version in https://github.com/ocaml-multicore/dscheck/pull/3 instead.
82+
you must use the version in https://github.com/ocaml-multicore/dscheck/pull/22 instead.
8383

8484
### Benchmarks
8585

lib_eio/core/cancel.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
exception Cancelled = Exn.Cancelled
2-
exception Cancel_hook_failed = Exn.Cancel_hook_failed
32

43
type state =
54
| On
@@ -156,12 +155,16 @@ let cancel t ex =
156155
x.cancel_fn <- ignore;
157156
match fn cex with
158157
| () -> aux xs
159-
| exception ex2 -> ex2 :: aux xs
158+
| exception ex2 ->
159+
let bt = Printexc.get_raw_backtrace () in
160+
(ex2, bt) :: aux xs
160161
in
161162
if fibers <> [] then (
162163
match aux fibers with
163164
| [] -> ()
164-
| exns -> raise (Cancel_hook_failed exns)
165+
| ex :: exs ->
166+
let ex, bt = List.fold_left Exn.combine ex exs in
167+
Printexc.raise_with_backtrace ex bt
165168
)
166169

167170
let sub fn =

lib_eio/core/eio__core.mli

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,6 @@ module Cancel : sig
526526
527527
The nested exception is only intended for debug-level logging and should generally be ignored. *)
528528

529-
exception Cancel_hook_failed of exn list
530-
(** Raised by {!cancel} if any of the cancellation hooks themselves fail. *)
531-
532529
val sub : (t -> 'a) -> 'a
533530
(** [sub fn] installs a new cancellation context [t], runs [fn t] inside it, and then restores the old context.
534531
@@ -561,9 +558,7 @@ module Cancel : sig
561558
If [t] is already cancelled then this does nothing.
562559
563560
Note that the caller of this function is still responsible for handling the error somehow
564-
(e.g. reporting it to the user); it does not become the responsibility of the cancelled thread(s).
565-
566-
@raise Cancel_hook_failed if one or more hooks fail. *)
561+
(e.g. reporting it to the user); it does not become the responsibility of the cancelled thread(s). *)
567562

568563
val dump : t Fmt.t
569564
(** Show the cancellation sub-tree rooted at [t], for debugging. *)

lib_eio/core/exn.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ type err += Multiple_io of (err * context * Printexc.raw_backtrace) list
1616

1717
exception Cancelled of exn
1818

19-
exception Cancel_hook_failed of exn list
20-
2119
let create err = Io (err, { steps = [] })
2220

2321
let add_context ex fmt =
@@ -90,7 +88,6 @@ let () =
9088
Printexc.register_printer @@ function
9189
| Io _ as ex -> Some (Fmt.str "@[<v>%a@]" pp ex)
9290
| Multiple exns -> Some (Fmt.str "%a" pp_multiple exns)
93-
| Cancel_hook_failed exns -> Some ("During cancellation:\n" ^ String.concat "\nand\n" (List.map Printexc.to_string exns))
9491
| Cancelled ex -> Some ("Cancelled: " ^ Printexc.to_string ex)
9592
| _ -> None
9693

lib_eio/core/switch.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let fail ?(bt=Printexc.get_raw_backtrace ()) t ex =
5555
t.exs <- Some (combine_exn (ex, bt) t.exs);
5656
try
5757
Cancel.cancel t.cancel ex
58-
with Exn.Cancel_hook_failed _ as ex ->
58+
with ex ->
5959
let bt = Printexc.get_raw_backtrace () in
6060
t.exs <- Some (combine_exn (ex, bt) t.exs)
6161

0 commit comments

Comments
 (0)