File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -282,15 +282,22 @@ let tcp_keepintvl = 2
282282
283283(* CA-94829: Set the TCP keepalive options if it's a socket *)
284284let fix_fd fd =
285- let stats = Unix. fstat fd in
286- if stats.Unix. st_kind = Unix. S_SOCK then begin
287- Unix. setsockopt fd Unix. SO_KEEPALIVE true ;
288- Unixext. set_sock_keepalives fd tcp_keepcnt tcp_keepidle tcp_keepintvl;
289- debug " Set socket TCP keepalive values to TCP_KEEPCNT=%d TCP_KEEPIDLE=%d TCP_KEEPINTVL=%d" tcp_keepcnt tcp_keepidle tcp_keepintvl
290- end else begin
291- debug " Skipping TCP keepalive setting as fd is not a socket"
292- end
293-
285+ try
286+ let stats = Unix. fstat fd in
287+ if stats.Unix. st_kind = Unix. S_SOCK then begin
288+ Unix. setsockopt fd Unix. SO_KEEPALIVE true ;
289+ Unixext. set_sock_keepalives fd tcp_keepcnt tcp_keepidle tcp_keepintvl;
290+ debug " Set socket TCP keepalive values to TCP_KEEPCNT=%d TCP_KEEPIDLE=%d TCP_KEEPINTVL=%d" tcp_keepcnt tcp_keepidle tcp_keepintvl
291+ end else begin
292+ debug " Skipping TCP keepalive setting as fd is not a socket"
293+ end
294+ with
295+ | Unix. Unix_error (Unix. EOVERFLOW, _ , _ ) ->
296+ (* Ignoring EOVERFLOW: can't get this on a socket *)
297+ debug " Skipping TCP keepalive setting as fd is not a socket" ;
298+ ()
299+ | e ->
300+ debug " Caught exception: '%s' - ignoring" (Printexc. to_string e)
294301
295302(* main *)
296303let _ =
You can’t perform that action at this time.
0 commit comments