From aebe313c48c1fa0519744d9f207a16c65b3682aa Mon Sep 17 00:00:00 2001 From: Ulugbek Abdullaev Date: Thu, 4 Feb 2021 16:50:11 +0500 Subject: [PATCH] fix log.debug use and its message --- src/not-so-smart/state_flow.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/not-so-smart/state_flow.ml b/src/not-so-smart/state_flow.ml index 3d2956038..a9a0217c7 100644 --- a/src/not-so-smart/state_flow.ml +++ b/src/not-so-smart/state_flow.ml @@ -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