Shell/P2p: propagate disconnection errors through the pool.

This commit is contained in:
Grégoire Henry 2017-04-10 00:40:47 +02:00
parent 4523a67e7d
commit c2a4db2d81

View File

@ -120,6 +120,10 @@ module Answerer = struct
| Ok (_, Disconnect)| Error [P2p_io_scheduler.Connection_closed] -> | Ok (_, Disconnect)| Error [P2p_io_scheduler.Connection_closed] ->
Canceler.cancel st.canceler >>= fun () -> Canceler.cancel st.canceler >>= fun () ->
Lwt.return_unit Lwt.return_unit
| Error [P2p_connection.Decoding_error] ->
(* TODO: Penalize peer... *)
Canceler.cancel st.canceler >>= fun () ->
Lwt.return_unit
| Error [Lwt_utils.Canceled] -> | Error [Lwt_utils.Canceled] ->
Lwt.return_unit Lwt.return_unit
| Error err -> | Error err ->
@ -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 () ; Lwt_condition.broadcast pool.events.too_many_connections () ;
log pool Too_many_connections ; log pool Too_many_connections ;
end ; end ;
Lwt_pipe.close messages ;
P2p_connection.close ~wait:conn.wait_close conn.conn P2p_connection.close ~wait:conn.wait_close conn.conn
end ; end ;
List.iter (fun f -> f peer_id conn) pool.new_connection_hook ; List.iter (fun f -> f peer_id conn) pool.new_connection_hook ;