File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ let clear_input fd =
278278 loop () ;
279279 Unix. clear_nonblock fd
280280
281- let ip_watcher () =
281+ let rec ip_watcher () =
282282 let cmd = Network_utils. iproute2 in
283283 let args = [" monitor" ; " address" ] in
284284 let readme, writeme = Unix. pipe () in
@@ -299,12 +299,26 @@ let ip_watcher () =
299299 end ;
300300 loop ()
301301 in
302+ let restart_ip_watcher () = begin
303+ Unix. close readme;
304+ Thread. delay 5.0 ;
305+ ip_watcher () ;
306+ end
307+ in
302308 while true do
303309 try
304310 info " (Re)started IP watcher thread" ;
305311 loop ()
306312 with e ->
307- warn " Error in IP watcher: %s\n %s" (Printexc. to_string e) (Printexc. get_backtrace () )
313+ warn " Error in IP watcher: %s\n %s" (Printexc. to_string e) (Printexc. get_backtrace () );
314+ match ! watcher_pid with
315+ | None -> restart_ip_watcher ()
316+ | Some pid ->
317+ let quitted, _ = Forkhelpers. waitpid_nohang pid in
318+ if quitted <> 0 then begin
319+ warn " address monitoring process quitted, try to restart it" ;
320+ restart_ip_watcher ()
321+ end
308322 done
309323
310324let start () =
You can’t perform that action at this time.
0 commit comments