File tree Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 1
- (* mirage >= 4.6.0 & < 4.7 .0 *)
1
+ (* mirage >= 4.6.0 & < 4.10 .0 *)
2
2
3
3
open Mirage
4
4
Original file line number Diff line number Diff line change @@ -178,15 +178,17 @@ let listen t ~port ?keepalive callback =
178
178
Lwt. catch
179
179
(fun () -> callback afd)
180
180
(fun exn ->
181
- Log. warn (fun m -> m " error %s in callback" (Printexc. to_string exn )) ;
181
+ Log. warn (fun m -> m " tcp error on port %u in callback %s " port (Printexc. to_string exn )) ;
182
182
close afd));
183
183
`Continue )
184
184
(function
185
185
| Unix. Unix_error (Unix. EBADF, _ , _ ) ->
186
- Log. warn (fun m -> m " error bad file descriptor in accept" ) ;
186
+ (match Hashtbl. find_opt t.listen_sockets port with
187
+ | None -> ()
188
+ | Some _ -> Log. warn (fun m -> m " tcp error bad file descriptor in accept on port %u" port)) ;
187
189
Lwt. return `Stop
188
190
| exn ->
189
- Log. warn (fun m -> m " error %s in accept" (Printexc. to_string exn )) ;
191
+ Log. warn (fun m -> m " tcp error on port %u in accept: %s " port (Printexc. to_string exn )) ;
190
192
Lwt. return `Continue ) >> = function
191
193
| `Continue -> loop ()
192
194
| `Stop -> Lwt. return_unit
Original file line number Diff line number Diff line change @@ -190,22 +190,19 @@ let listen t ~port callback =
190
190
| Some v4 -> Ipaddr. V4 v4
191
191
in
192
192
let dst = Ipaddr. (V6 V6. unspecified) in (* TODO *)
193
- let buf =
194
- (* Use Cstruct.sub_copy once it exists in a
195
- reasonably mature cstruct release *)
196
- let b = Cstruct. create_unsafe len in
197
- Cstruct. blit buf 0 b 0 len;
198
- b
199
- in
193
+ let buf = Cstruct. sub_copy buf 0 len in
200
194
callback ~src ~dst ~src_port buf
201
195
| _ -> Lwt. return_unit) > |= fun () ->
202
196
`Continue )
203
197
(function
204
198
| Unix. Unix_error (Unix. EBADF, _ , _ ) ->
205
- Log. warn (fun m -> m " error bad file descriptor in accept" ) ;
199
+ (match Hashtbl. find_opt t.listen_fds port with
200
+ | None -> ()
201
+ | Some _ ->
202
+ Log. info (fun m -> m " udp error bad file descriptor in accept on port %u" port)) ;
206
203
Lwt. return `Stop
207
204
| exn ->
208
- Log. warn (fun m -> m " exception %s in recvfrom" (Printexc. to_string exn )) ;
205
+ Log. warn (fun m -> m " udp exception on port %u in recvfrom: %s " port (Printexc. to_string exn )) ;
209
206
Lwt. return `Continue ) >> = function
210
207
| `Continue -> loop ()
211
208
| `Stop -> Lwt. return_unit
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ depends: [
27
27
"dune" {>= "2.7.0"}
28
28
"bisect_ppx" {dev & >= "2.5.0"}
29
29
"ocaml" {>= "4.08.0"}
30
- "cstruct" {>= "6.0 .0"}
30
+ "cstruct" {>= "6.2 .0"}
31
31
"cstruct-lwt"
32
32
"mirage-net" {>= "3.0.0"}
33
33
"mirage-mtime" {>= "4.0.0"}
You can’t perform that action at this time.
0 commit comments