Cope with writing a frame failing

If a client disconnects suddenly then we may get an error trying to map
its grant to send the frame.

Fixes #8.
This commit is contained in:
Thomas Leonard 2016-06-26 12:04:47 +01:00
parent 0230cfaf1e
commit c11f245d64

View File

@ -16,7 +16,14 @@ let transmit ~frame iface =
cases. *)
let frame = fixup_checksums frame |> Cstruct.concat in
let packet = Cstruct.shift frame Wire_structs.sizeof_ethernet in
iface#writev [packet]
Lwt.catch
(fun () -> iface#writev [packet])
(fun ex ->
Log.warn (fun f -> f "Failed to write packet to %a: %s"
Ipaddr.V4.pp_hum iface#other_ip
(Printexc.to_string ex));
Lwt.return ()
)
let forward_ipv4 t frame =
let packet = Cstruct.shift frame Wire_structs.sizeof_ethernet in