diff --git a/CHANGES.md b/CHANGES.md index 7ff1bcf..2faddef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +### v2.8.0 (2020-09-28) + +* Netif.listen: do not catch out of memory exception (#49 @hannesm) + ### v2.7.0 (30-Oct-2019) * Adapt to mirage-net 3.0.0 changes (@hannesm) diff --git a/src/netif.ml b/src/netif.ml index 1c99ea9..b708417 100644 --- a/src/netif.ml +++ b/src/netif.ml @@ -103,16 +103,6 @@ let rec read t buf = | Error `Disconnected -> Lwt.return (Error `Disconnected) | Ok buf -> Lwt.return (Ok buf) -let safe_apply f x = - Lwt.catch - (fun () -> f x) - (function - | Out_of_memory -> Lwt.fail Out_of_memory - | exn -> - Log.err (fun m -> m "[listen] error while handling %s, continuing. bt: %s" - (Printexc.to_string exn) (Printexc.get_backtrace ())); - Lwt.return_unit) - (* Loop and listen for packets permanently *) (* this function has to be tail recursive, since it is called at the top level, otherwise memory of received packets and all reachable @@ -123,7 +113,7 @@ let rec listen t ~header_size fn = let buf = Cstruct.create (t.mtu + header_size) in let process () = read t buf >|= function - | Ok buf -> Lwt.async (fun () -> safe_apply fn buf) ; Ok () + | Ok buf -> Lwt.async (fun () -> fn buf) ; Ok () | Error `Canceled -> Error `Disconnected | Error `Disconnected -> t.active <- false ; Error `Disconnected in