P2p: fix for file-descriptor leak on incoming connections

This commit is contained in:
Grégoire Henry 2018-08-28 15:34:44 +02:00 committed by Pierre Chambart
parent 17ff89186e
commit 8e8fae23fd

View File

@ -733,6 +733,14 @@ let rec connect ?timeout pool point =
end end
and authenticate pool ?point_info canceler fd point = and authenticate pool ?point_info canceler fd point =
let fd = P2p_io_scheduler.register pool.io_sched fd in
raw_authenticate pool ?point_info canceler fd point >>= function
| Ok connection -> return connection
| Error _ as err ->
P2p_io_scheduler.close fd >>=? fun () ->
Lwt.return err
and raw_authenticate pool ?point_info canceler fd point =
let incoming = point_info = None in let incoming = point_info = None in
lwt_debug "authenticate: %a%s" lwt_debug "authenticate: %a%s"
P2p_point.Id.pp point P2p_point.Id.pp point
@ -740,7 +748,7 @@ and authenticate pool ?point_info canceler fd point =
protect ~canceler begin fun () -> protect ~canceler begin fun () ->
P2p_socket.authenticate P2p_socket.authenticate
~proof_of_work_target:pool.config.proof_of_work_target ~proof_of_work_target:pool.config.proof_of_work_target
~incoming (P2p_io_scheduler.register pool.io_sched fd) point ~incoming fd point
?listening_port:pool.config.listening_port ?listening_port:pool.config.listening_port
pool.config.identity pool.message_config.versions pool.config.identity pool.message_config.versions
pool.conn_meta_config pool.conn_meta_config