Open smondet opened 11 months ago
Actually with exactly the master
branch now (e5a66f1c1e7c2e5051723e09260222994dff40cf
) the /ok3
enpoint also causes the failure.
With this change, we get the behavior above (/ok3
succeeds. /ko
fails):
diff --git a/vendor/cohttp/cohttp-eio/src/utils.ml b/vendor/cohttp/cohttp-eio/src/utils.ml
index 8478eac4..8d1cee93 100644
--- a/vendor/cohttp/cohttp-eio/src/utils.ml
+++ b/vendor/cohttp/cohttp-eio/src/utils.ml
@@ -45,7 +45,7 @@ let flow_of_reader =
fun read_body_chunk -> Eio.Resource.T (Reader_flow.v read_body_chunk, handler)
let flow_to_writer flow writer write_body =
- let input = Eio.Buf_read.of_flow ~max_size:max_int flow in
+ let input = Eio.Buf_read.of_flow ~initial_size:1024 ~max_size:max_int flow in
let rec loop () =
let () =
let () = Eio.Buf_read.ensure input 1 in
With let input = Eio.Buf_read.of_flow ~initial_size:1023 ~max_size:max_int flow in
They both fail.
with let input = Eio.Buf_read.of_flow ~initial_size:1025 ~max_size:max_int flow in
They both succeed.
With:
let handler _socket request _body =
let u = Http.Request.resource request |> Uri.of_string in
match Uri.path u with
| "/" ->
(Http.Response.make (), Cohttp_eio.Body.of_string text) (* | "/body" -> *)
| "/body" ->
let size = Uri.get_query_param u "size" |> Option.get |> int_of_string in
(Http.Response.make (), Cohttp_eio.Body.of_string (String.make size 'B'))
| "/flow" ->
let size = Uri.get_query_param u "size" |> Option.get |> int_of_string in
(Http.Response.make (), Eio.Flow.string_source (String.make size 'B'))
We can make crash the Body.of_string
version too:
curl --verbose --fail-with-body http://localhost:2000/body?size=3_000_000 | wc -c
succeeds
but
curl --verbose --fail-with-body http://localhost:2000/body?size=6_000_000 | wc -c
fails, with the same server error.
OK This might be an Eio bug (?).
Playing with the initial-buffer-sizes and this:
diff --git a/vendor/eio/lib_eio_posix/flow.ml b/vendor/eio/lib_eio_posix/flow.ml
index 2588bf11..3ac9795a 100644
--- a/vendor/eio/lib_eio_posix/flow.ml
+++ b/vendor/eio/lib_eio_posix/flow.ml
@@ -43,6 +43,8 @@ module Impl = struct
try
Low_level.writev t (Array.of_list bufs)
with Unix.Unix_error (code, name, arg) ->
+ traceln "ERROR vendor/eio/lib_eio_posix/flow.ml bufs: %d"
+ (List.length bufs);
raise (Err.wrap code name arg)
let copy t ~src = Eio.Flow.Pi.simple_copy ~single_write t ~src
We can see that it fails when the call to posix-writev gets an array of more than 1024 buffers, which is indeed the value of IOV_MAX
on my system.
This may be related to observations in https://github.com/mirage/ocaml-cohttp/issues/1004
Using the
master
branch.I've modifed
cohttp-eio/examples/server1.ml
like this:When we call
/ko
, the server dies with:Here are the corresponding
curl
calls: