P2p: tentative fix for #98
This commit is contained in:
parent
e7483ff392
commit
ea500256f0
@ -484,7 +484,10 @@ let catch_closed_pipe f =
|
||||
Lwt.catch f begin function
|
||||
| Lwt_pipe.Closed -> fail P2p_io_scheduler.Connection_closed
|
||||
| exn -> fail (Exn exn)
|
||||
end
|
||||
end >>= function
|
||||
| Error [Exn Lwt_pipe.Closed] ->
|
||||
fail P2p_io_scheduler.Connection_closed
|
||||
| Error _ | Ok _ as v -> Lwt.return v
|
||||
|
||||
let pp_json encoding ppf msg =
|
||||
Format.pp_print_string ppf
|
||||
|
@ -311,15 +311,17 @@ module Close_on_read = struct
|
||||
|
||||
let simple_msg = random_bytes (1 lsl 4)
|
||||
|
||||
let server _ch sched socket =
|
||||
let server ch sched socket =
|
||||
accept sched socket >>=? fun (_info, auth_fd) ->
|
||||
P2p_connection.accept auth_fd encoding >>=? fun conn ->
|
||||
sync ch >>=? fun () ->
|
||||
P2p_connection.close conn >>= fun _stat ->
|
||||
return ()
|
||||
|
||||
let client _ch sched addr port =
|
||||
let client ch sched addr port =
|
||||
connect sched addr port id2 >>=? fun auth_fd ->
|
||||
P2p_connection.accept auth_fd encoding >>=? fun conn ->
|
||||
sync ch >>=? fun () ->
|
||||
P2p_connection.read conn >>= fun err ->
|
||||
_assert (is_connection_closed err) __LOC__ "" >>=? fun () ->
|
||||
P2p_connection.close conn >>= fun _stat ->
|
||||
@ -346,6 +348,7 @@ module Close_on_write = struct
|
||||
connect sched addr port id2 >>=? fun auth_fd ->
|
||||
P2p_connection.accept auth_fd encoding >>=? fun conn ->
|
||||
sync ch >>=? fun ()->
|
||||
Lwt_unix.sleep 0.1 >>= fun () ->
|
||||
P2p_connection.write_sync conn simple_msg >>= fun err ->
|
||||
_assert (is_connection_closed err) __LOC__ "" >>=? fun () ->
|
||||
P2p_connection.close conn >>= fun _stat ->
|
||||
|
Loading…
Reference in New Issue
Block a user