mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
test: use async spans for lwt echo server
This commit is contained in:
parent
6bf58e3e62
commit
bd00e0838a
1 changed files with 5 additions and 5 deletions
|
|
@ -19,15 +19,14 @@ let main ~port ~runner () : unit Lwt.t =
|
||||||
Printf.printf "listening on port %d\n%!" port;
|
Printf.printf "listening on port %d\n%!" port;
|
||||||
|
|
||||||
let handle_client client_addr ic oc =
|
let handle_client client_addr ic oc =
|
||||||
let@ _sp =
|
let _sp =
|
||||||
Trace.with_span ~__FILE__ ~__LINE__ "handle.client" ~data:(fun () ->
|
Trace.enter_manual_toplevel_span ~__FILE__ ~__LINE__ "handle.client"
|
||||||
[ "addr", `String (str_of_sockaddr client_addr) ])
|
~data:(fun () -> [ "addr", `String (str_of_sockaddr client_addr) ])
|
||||||
in
|
in
|
||||||
|
|
||||||
let buf = Bytes.create 32 in
|
let buf = Bytes.create 32 in
|
||||||
let continue = ref true in
|
let continue = ref true in
|
||||||
while !continue do
|
while !continue do
|
||||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "read.loop" in
|
|
||||||
Trace.message "read";
|
Trace.message "read";
|
||||||
let n = M_lwt.IO_in.input ic buf 0 (Bytes.length buf) in
|
let n = M_lwt.IO_in.input ic buf 0 (Bytes.length buf) in
|
||||||
if n = 0 then
|
if n = 0 then
|
||||||
|
|
@ -36,9 +35,10 @@ let main ~port ~runner () : unit Lwt.t =
|
||||||
Trace.messagef (fun k -> k "got %dB" n);
|
Trace.messagef (fun k -> k "got %dB" n);
|
||||||
M_lwt.IO_out.output oc buf 0 n;
|
M_lwt.IO_out.output oc buf 0 n;
|
||||||
M_lwt.IO_out.flush oc;
|
M_lwt.IO_out.flush oc;
|
||||||
Trace.message "write" (* MU.sleep_s 0.02 *)
|
Trace.message "write"
|
||||||
)
|
)
|
||||||
done;
|
done;
|
||||||
|
Trace.exit_manual_span _sp;
|
||||||
Trace.message "exit handle client"
|
Trace.message "exit handle client"
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue