@@ -211,19 +211,52 @@ let test_signal_race () =
211211 (fun () -> Eio.Condition. await_no_mutex cond)
212212 (fun () -> ignore (Unix. setitimer ITIMER_REAL { it_interval = 0. ; it_value = 0.001 } : Unix.interval_timer_status ))
213213
214+ let test_alloc_fixed_or_wait () =
215+ Eio_linux. run ~n_blocks: 1 @@ fun _env ->
216+ let block = Eio_linux.Low_level. alloc_fixed_or_wait () in
217+ (* We have to wait for the block, but get cancelled while waiting. *)
218+ begin
219+ try
220+ Fiber. both
221+ (fun () -> ignore (Eio_linux.Low_level. alloc_fixed_or_wait () : Uring.Region. chunk))
222+ (fun () -> raise Exit );
223+ with Exit -> ()
224+ end ;
225+ (* We have to wait for the block, and get it when the old one is freed. *)
226+ Fiber. both
227+ (fun () ->
228+ let x = Eio_linux.Low_level. alloc_fixed_or_wait () in
229+ Eio_linux.Low_level. free_fixed x
230+ )
231+ (fun () ->
232+ Eio_linux.Low_level. free_fixed block
233+ );
234+ (* The old block is passed to the waiting fiber, but it's cancelled. *)
235+ let block = Eio_linux.Low_level. alloc_fixed_or_wait () in
236+ Fiber. both
237+ (fun () ->
238+ Fiber. first
239+ (fun () -> ignore (Eio_linux.Low_level. alloc_fixed_or_wait () ); assert false )
240+ (fun () -> () )
241+ )
242+ (fun () -> Eio_linux.Low_level. free_fixed block);
243+ let block = Eio_linux.Low_level. alloc_fixed_or_wait () in
244+ Eio_linux.Low_level. free_fixed block
245+
214246let () =
215247 let open Alcotest in
216248 run " eio_linux" [
217249 " io" , [
218- test_case " copy" `Quick test_copy;
219- test_case " direct_copy" `Quick test_direct_copy;
220- test_case " poll_add" `Quick test_poll_add;
221- test_case " poll_add_busy" `Quick test_poll_add_busy;
222- test_case " iovec" `Quick test_iovec;
223- test_case " no_sqe" `Quick test_no_sqe;
224- test_case " read_exact" `Quick test_read_exact;
225- test_case " expose_backend" `Quick test_expose_backend;
226- test_case " statx" `Quick test_statx;
227- test_case " signal_race" `Quick test_signal_race;
250+ test_case " copy" `Quick test_copy;
251+ test_case " direct_copy" `Quick test_direct_copy;
252+ test_case " poll_add" `Quick test_poll_add;
253+ test_case " poll_add_busy" `Quick test_poll_add_busy;
254+ test_case " iovec" `Quick test_iovec;
255+ test_case " no_sqe" `Quick test_no_sqe;
256+ test_case " read_exact" `Quick test_read_exact;
257+ test_case " expose_backend" `Quick test_expose_backend;
258+ test_case " statx" `Quick test_statx;
259+ test_case " signal_race" `Quick test_signal_race;
260+ test_case " alloc-fixed-or-wait" `Quick test_alloc_fixed_or_wait;
228261 ];
229262 ]
0 commit comments