The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #89 from edwintorok/master

Fix SIGSEGV on `Uring.wait`

authored by

Thomas Leonard and committed by
GitHub
8769bb1a 9496b836

+31 -5
+1 -2
vendor/opam/uring/lib/uring/region.ml
··· 5 5 type t = { 6 6 buf: Cstruct.buffer; 7 7 block_size: int; 8 - slots: int; 9 8 freelist: int Queue.t; 10 9 } 11 10 ··· 18 17 for i = 0 to slots - 1 do 19 18 Queue.push (i*block_size) freelist 20 19 done; 21 - { freelist; slots; block_size; buf } 20 + { freelist; block_size; buf } 22 21 23 22 let alloc t = 24 23 match Queue.pop t.freelist with
+2
vendor/opam/uring/lib/uring/uring_stubs.c
··· 687 687 unix_error(-res, "io_uring_wait_cqe_timeout", Nothing); 688 688 } 689 689 } else { 690 + if (!cqe) 691 + CAMLreturn(Val_cqe_none); 690 692 id = (long)io_uring_cqe_get_data(cqe); 691 693 io_uring_cqe_seen(ring, cqe); 692 694 CAMLreturn(Val_cqe_some(Val_int(id), Val_int(cqe->res)));
+28 -3
vendor/opam/uring/tests/main.md
··· 733 733 Timeout should return (-ETIME). This is defined in https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno.h#L45 734 734 735 735 ```ocaml 736 - # let t = Uring.create ~queue_depth:1 ();; 737 - val t : '_weak13 Uring.t = <abstr> 736 + # let t : [`Timeout] Uring.t = Uring.create ~queue_depth:1 ();; 737 + val t : [ `Timeout ] Uring.t = <abstr> 738 738 739 739 # let ns1 = Int64.(mul 10L 1_000_000L) in 740 740 Uring.(timeout t Boottime ns1 `Timeout);; 741 - - : _[> `Timeout ] Uring.job option = Some <abstr> 741 + - : [ `Timeout ] Uring.job option = Some <abstr> 742 742 743 743 # Uring.submit t;; 744 744 - : int = 1 ··· 766 766 # Uring.exit t;; 767 767 - : unit = () 768 768 ``` 769 + 770 + If there is a timeout but we did submit something, `io_uring_submit_and_wait_timeout` returns success instead: 771 + 772 + ```ocaml 773 + # let t : [`Timeout | `Cancel] Uring.t = Uring.create ~queue_depth:1 ();; 774 + val t : [ `Cancel | `Timeout ] Uring.t = <abstr> 775 + 776 + # let job = 777 + let ns = Int64.(mul 10L 1_000_000_000L) in 778 + Uring.(timeout t Boottime ns `Timeout);; 779 + val job : [ `Cancel | `Timeout ] Uring.job option = Some <abstr> 780 + 781 + # Uring.wait ~timeout:0.01 t;;Uring.wait ~timeout:0.01 t;; 782 + - : [ `Cancel | `Timeout ] Uring.completion_option = Uring.None 783 + 784 + # Uring.cancel t (Option.get job) `Cancel;; 785 + - : [ `Cancel | `Timeout ] Uring.job option = Some <abstr> 786 + 787 + # ignore (Uring.wait ~timeout:10.0 t, Uring.wait ~timeout:10.0 t);; 788 + - : unit = () 789 + 790 + # Uring.exit t;; 791 + - : unit = () 792 + ``` 793 + 769 794 770 795 ## Probing 771 796