File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -181,19 +181,22 @@ let listen t ~port callback =
181181 if not (Lwt. is_sleeping t.switched_off) then raise Lwt. Canceled ;
182182 Lwt. catch (fun () ->
183183 Lwt_cstruct. recvfrom fd buf [] >> = fun (len , sa ) ->
184- (match sa with
185- | Lwt_unix. ADDR_INET (addr , src_port ) ->
186- let src = Ipaddr_unix. of_inet_addr addr in
187- let src =
188- match Ipaddr. to_v4 src with
189- | None -> src
190- | Some v4 -> Ipaddr. V4 v4
191- in
192- let dst = Ipaddr. (V6 V6. unspecified) in (* TODO *)
193- let buf = Cstruct. sub_copy buf 0 len in
194- callback ~src ~dst ~src_port buf
195- | _ -> Lwt. return_unit) > |= fun () ->
196- `Continue )
184+ if len = 0 then
185+ Lwt. return `Stop
186+ else
187+ (match sa with
188+ | Lwt_unix. ADDR_INET (addr , src_port ) ->
189+ let src = Ipaddr_unix. of_inet_addr addr in
190+ let src =
191+ match Ipaddr. to_v4 src with
192+ | None -> src
193+ | Some v4 -> Ipaddr. V4 v4
194+ in
195+ let dst = Ipaddr. (V6 V6. unspecified) in (* TODO *)
196+ let buf = Cstruct. sub_copy buf 0 len in
197+ callback ~src ~dst ~src_port buf
198+ | _ -> Lwt. return_unit) > |= fun () ->
199+ `Continue )
197200 (function
198201 | Unix. Unix_error (Unix. EBADF, _ , _ ) ->
199202 (match Hashtbl. find_opt t.listen_fds port with
You can’t perform that action at this time.
0 commit comments