Skip to content

Commit 496d508

Browse files
committed
Merge pull request 'Catch also exception when we read on TCP and TLS for DNS packets' (#18) from fix-dns into main
Reviewed-on: https://git.robur.coop/robur/mnet/pulls/18
2 parents a4b5626 + 4097f5b commit 496d508

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mnet_dns.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ module Transport = struct
275275

276276
let rec read_from_tcp t ke buf flow =
277277
match Mnet.TCP.read flow buf with
278-
| (exception _) | 0 -> ()
278+
| 0 -> Log.debug (fun m -> m "TCP connection closed by peer")
279+
| exception exn ->
280+
Log.err (fun m ->
281+
m "TCP connection failed with: %s" (Printexc.to_string exn))
279282
| len ->
280283
let str = Bytes.sub_string buf 0 len in
281284
Ke.push ke str;
@@ -284,7 +287,10 @@ module Transport = struct
284287

285288
let rec read_from_tls t ke buf flow =
286289
match Mnet_tls.read flow buf with
287-
| (exception _) | 0 -> ()
290+
| 0 -> Log.debug (fun m -> m "TLS connection closed by peer")
291+
| exception exn ->
292+
Log.err (fun m ->
293+
m "TLS connection failed with: %s" (Printexc.to_string exn))
288294
| len ->
289295
let str = Bytes.sub_string buf 0 len in
290296
Ke.push ke str;

0 commit comments

Comments
 (0)