From c2a4db2d81737c8e1649d579ad87987de3d4492f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 10 Apr 2017 00:40:47 +0200 Subject: [PATCH] Shell/P2p: propagate disconnection errors through the `pool`. --- src/node/net/p2p_connection_pool.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/net/p2p_connection_pool.ml b/src/node/net/p2p_connection_pool.ml index 450f6e026..61bab5608 100644 --- a/src/node/net/p2p_connection_pool.ml +++ b/src/node/net/p2p_connection_pool.ml @@ -117,7 +117,11 @@ module Answerer = struct | Ok (size, Message msg) -> st.callback.message size msg >>= fun () -> worker_loop st - | Ok (_, Disconnect) | Error [P2p_io_scheduler.Connection_closed] -> + | Ok (_, Disconnect)| Error [P2p_io_scheduler.Connection_closed] -> + Canceler.cancel st.canceler >>= fun () -> + Lwt.return_unit + | Error [P2p_connection.Decoding_error] -> + (* TODO: Penalize peer... *) Canceler.cancel st.canceler >>= fun () -> Lwt.return_unit | Error [Lwt_utils.Canceled] -> @@ -916,6 +920,7 @@ and create_connection pool p2p_conn id_point point_info peer_info _version = Lwt_condition.broadcast pool.events.too_many_connections () ; log pool Too_many_connections ; end ; + Lwt_pipe.close messages ; P2p_connection.close ~wait:conn.wait_close conn.conn end ; List.iter (fun f -> f peer_id conn) pool.new_connection_hook ;