P2p: missing Lwt_utils.protect in the reader worker.

This commit is contained in:
Grégoire Henry 2017-11-08 16:10:40 +01:00 committed by Benjamin Canou
parent c9fe53eb10
commit cb1e5cc396

View File

@ -261,16 +261,19 @@ module Reader = struct
let rec worker_loop st init_mbytes = let rec worker_loop st init_mbytes =
Lwt_unix.yield () >>= fun () ->
begin begin
read_message st init_mbytes >>=? fun msg -> read_message st init_mbytes >>=? fun msg ->
match msg with match msg with
| None -> | None ->
Lwt_pipe.push st.messages (Error [Decoding_error]) >>= fun () -> Lwt_utils.protect ~canceler:st.canceler begin fun () ->
return None Lwt_pipe.push st.messages (Error [Decoding_error]) >>= fun () ->
return None
end
| Some (msg, size, rem_mbytes) -> | Some (msg, size, rem_mbytes) ->
Lwt_pipe.push st.messages (Ok (size, msg)) >>= fun () -> Lwt_utils.protect ~canceler:st.canceler begin fun () ->
return (Some rem_mbytes) Lwt_pipe.push st.messages (Ok (size, msg)) >>= fun () ->
return (Some rem_mbytes)
end
end >>= function end >>= function
| Ok Some rem_mbytes -> | Ok Some rem_mbytes ->
worker_loop st rem_mbytes worker_loop st rem_mbytes