From 6d9201bc1b80f991e1aad8c0016a52cbbd6016d5 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Mon, 28 Sep 2020 17:57:27 +0200 Subject: [PATCH 1/2] [ci skip] changes for 2.8.0 --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) 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) From c2f8500caede981586db904cbc97d76d90ecbdfe Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Mon, 21 Feb 2022 12:46:34 +0100 Subject: [PATCH 2/2] Do not Lwt.catch on the listen callback. This is a semantics change discussion https://github.com/mirage/mirage/issues/1036 --- src/netif.ml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) 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