Compare commits

..

No commits in common. "main" and "v1.3" have entirely different histories.
main ... v1.3

4 changed files with 77 additions and 39 deletions

View File

@ -150,8 +150,8 @@ let any_gen ~return ~combine fs =
)
in
match !r, Cancel.get_error parent_c with
| OK r, _ -> r
| New, Some ex -> raise ex
| OK r, None -> r
| (OK _ | New), Some ex -> raise ex
| Ex (ex, bt), None -> Printexc.raise_with_backtrace ex bt
| Ex ex1, Some ex2 ->
let bt2 = Printexc.get_raw_backtrace () in

View File

@ -213,9 +213,7 @@ let test_signal_race () =
let test_alloc_fixed_or_wait () =
Eio_linux.run ~n_blocks:1 @@ fun _env ->
match Eio_linux.Low_level.alloc_fixed_or_wait () with
| exception (Failure "No fixed buffer available") [@warning "-52"] -> Alcotest.skip ()
| block ->
let block = Eio_linux.Low_level.alloc_fixed_or_wait () in
(* We have to wait for the block, but get cancelled while waiting. *)
begin
try

42
lib_eio_windows/unix_cstruct.ml Executable file
View File

@ -0,0 +1,42 @@
(* See the end of the file for the license *)
external stub_write : Unix.file_descr -> Cstruct.t -> int = "eio_windows_cstruct_write"
let rec write fd buf =
if Cstruct.length buf > 0 then begin
let n = stub_write fd buf in
write fd @@ Cstruct.shift buf n
end
let writev fd bufs = List.iter (write fd) bufs
external read : Unix.file_descr -> Cstruct.t -> int = "eio_windows_cstruct_read"
(* From mirage/ocaml-cstruct
Copyright (c) 2012 Anil Madhavapeddy <anil@recoil.org>
Copyright (c) 2012 Pierre Chambart
Copyright (c) Christiano F. Haesbaert <haesbaert@haesbaert.org>
Copyright (c) Citrix Inc
Copyright (c) David Sheets <sheets@alum.mit.edu>
Copyright (c) Drup <drupyog@zoho.com>
Copyright (c) Hannes Mehnert <hannes@mehnert.org>
Copyright (c) Jeremy Yallop <yallop@gmail.com>
Copyright (c) Mindy Preston <meetup@yomimono.org>
Copyright (c) Nicolas Ojeda Bar <n.oje.bar@gmail.com>
Copyright (c) Richard Mortier <mort@cantab.net>
Copyright (c) Rudi Grinberg <rudi.grinberg@gmail.com>
Copyright (c) Thomas Gazagnaire <thomas@gazagnaire.com>
Copyright (c) Thomas Leonard <talex5@gmail.com>
Copyright (c) Vincent Bernardoff <vb@luminar.eu.org>
Copyright (c) pqwy <david@numm.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)

View File

@ -191,23 +191,21 @@ Cancelled from parent:
Exception: Failure "Parent cancel".
```
Cancelled from parent while already cancelling
(we return the value despite the cancellation):
Cancelled from parent while already cancelling:
```ocaml
# run @@ fun () ->
Fiber.both
(fun () ->
traceln "%s" @@ Fiber.first
let _ = Fiber.first
(fun () -> "a")
(fun () -> Fiber.yield (); failwith "cancel-b");
Fiber.check ();
(fun () -> Fiber.yield (); failwith "cancel-b")
in
traceln "Parent cancel failed"
)
(fun () -> traceln "Cancelling parent"; failwith "Parent cancel");
"not-reached";;
+Cancelling parent
+a
Exception: Failure "Parent cancel".
```