mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
fix echo_client to actually do its work
This commit is contained in:
parent
b991a78f3e
commit
e789cbe4f7
1 changed files with 22 additions and 12 deletions
|
|
@ -19,19 +19,28 @@ let main ~port ~runner ~n ~n_conn () : unit Lwt.t =
|
||||||
(* Printf.printf "running task\n%!"; *)
|
(* Printf.printf "running task\n%!"; *)
|
||||||
let n = Atomic.fetch_and_add remaining (-1) in
|
let n = Atomic.fetch_and_add remaining (-1) in
|
||||||
if n > 0 then (
|
if n > 0 then (
|
||||||
( (* let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "connect.client" in *)
|
(let _sp =
|
||||||
M_lwt.TCP_client.with_connect addr
|
Trace.enter_manual_toplevel_span ~__FILE__ ~__LINE__ "connect.client"
|
||||||
@@ fun ic oc ->
|
in
|
||||||
let buf = Bytes.create 32 in
|
Trace.message "connecting new client…";
|
||||||
|
M_lwt.TCP_client.with_connect addr @@ fun ic oc ->
|
||||||
|
let buf = Bytes.create 32 in
|
||||||
|
|
||||||
for _j = 1 to 100 do
|
for _j = 1 to 100 do
|
||||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "write.loop" in
|
let _sp =
|
||||||
M_lwt.IO_out.output_string oc "hello";
|
Trace.enter_manual_sub_span ~parent:_sp ~__FILE__ ~__LINE__
|
||||||
|
"write.loop"
|
||||||
|
in
|
||||||
|
|
||||||
(* read back something *)
|
M_lwt.IO_out.output_string oc "hello";
|
||||||
let _n = M_lwt.IO_in.really_input ic buf in
|
M_lwt.IO_out.flush oc;
|
||||||
()
|
|
||||||
done );
|
(* read back something *)
|
||||||
|
M_lwt.IO_in.really_input ic buf 0 (String.length "hello");
|
||||||
|
Trace.exit_manual_span _sp;
|
||||||
|
()
|
||||||
|
done;
|
||||||
|
Trace.exit_manual_span _sp);
|
||||||
|
|
||||||
(* run another task *) M.Runner.run_async runner run_task
|
(* run another task *) M.Runner.run_async runner run_task
|
||||||
) else (
|
) else (
|
||||||
|
|
@ -55,6 +64,7 @@ let main ~port ~runner ~n ~n_conn () : unit Lwt.t =
|
||||||
let () =
|
let () =
|
||||||
let@ () = Trace_tef.with_setup () in
|
let@ () = Trace_tef.with_setup () in
|
||||||
Trace.set_thread_name "main";
|
Trace.set_thread_name "main";
|
||||||
|
|
||||||
let port = ref 0 in
|
let port = ref 0 in
|
||||||
let j = ref 4 in
|
let j = ref 4 in
|
||||||
let n_conn = ref 100 in
|
let n_conn = ref 100 in
|
||||||
|
|
@ -63,7 +73,7 @@ let () =
|
||||||
let opts =
|
let opts =
|
||||||
[
|
[
|
||||||
"-p", Arg.Set_int port, " port";
|
"-p", Arg.Set_int port, " port";
|
||||||
"j", Arg.Set_int j, " number of threads";
|
"-j", Arg.Set_int j, " number of threads";
|
||||||
"-n", Arg.Set_int n, " total number of connections";
|
"-n", Arg.Set_int n, " total number of connections";
|
||||||
"--n-conn", Arg.Set_int n_conn, " number of parallel connections";
|
"--n-conn", Arg.Set_int n_conn, " number of parallel connections";
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue