Skip to content

Commit

Permalink
fix log.debug use and its message
Browse files Browse the repository at this point in the history
  • Loading branch information
ulugbekna committed Feb 4, 2021
1 parent c65344e commit aebe313
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/not-so-smart/state_flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,19 @@ struct
Log.err (fun m -> m "Got an error: %a." _Flow.pp_error err);
failwithf "%a" _Flow.pp_error err)
| Write { k; buffer; off; len } ->
(* TODO: Avoid writing by loop if we can;
otherwise, the loop writes once and terminates *)
let rec loop tmp =
if Cstruct.is_empty tmp then unwrap (k len)
else
_Flow.send flow tmp >>= function
| Ok shift -> loop (Cstruct.shift tmp shift)
| Ok shift ->
Log.debug (fun m ->
m "Wrote %d byte(s). %s" shift (Cstruct.to_string tmp));
loop (Cstruct.shift tmp shift)
| Error err -> failwithf "%a" _Flow.pp_error err
in
Log.debug (fun m -> m "Write %d byte(s). %s" len buffer);
loop (Cstruct.of_string buffer ~off ~len)
Cstruct.of_string buffer ~off ~len |> loop
in

unwrap state
Expand Down

0 comments on commit aebe313

Please sign in to comment.