From: Samuel Cabrero Date: Fri, 14 May 2021 10:35:44 +0000 (+0200) Subject: nmbd: Reduce the wait interface loop sleep time X-Git-Tag: tevent-0.11.0~874 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=52744d35a37680c382800539a4c88d553496dbec;p=thirdparty%2Fsamba.git nmbd: Reduce the wait interface loop sleep time Under some circumstances the network-online.target can be reached without an IPv4 address, for example when using systemd-networkd and having systemd-networkd-wait-online.service disabled. This will trigger a five seconds sleep which seems a bit excessive. It is specially critical when winbind.service is enabled as it won't be started until nmbd.service is running, delaying the systemd-logind.service five seconds. Reduce the sleep time from 5 seconds to 250ms to exit the loop as soon as possible. Signed-off-by: Samuel Cabrero Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri May 14 20:52:47 UTC 2021 on sn-devel-184 --- diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 05645967e05..c33d3a441ae 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -370,7 +370,7 @@ static void reload_interfaces(time_t t) /* We only count IPv4, non-loopback interfaces here. */ while (iface_count_v4_nl() == 0) { - sleep(5); + usleep(NMBD_WAIT_INTERFACES_TIME_USEC); load_interfaces(); } diff --git a/source3/nmbd/nmbd.h b/source3/nmbd/nmbd.h index 551868e29ad..f207eb9304e 100644 --- a/source3/nmbd/nmbd.h +++ b/source3/nmbd/nmbd.h @@ -28,6 +28,8 @@ #include "libsmb/nmblib.h" #include "nmbd/nmbd_proto.h" +#define NMBD_WAIT_INTERFACES_TIME_USEC (250 * 1000) + /**************************************************************************** true if two IPv4 addresses are equal ****************************************************************************/ diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c index 983369f0c6f..b2bcedddc35 100644 --- a/source3/nmbd/nmbd_subnetdb.c +++ b/source3/nmbd/nmbd_subnetdb.c @@ -264,7 +264,7 @@ bool create_subnets(void) saved_handler = CatchSignal(SIGTERM, SIG_DFL); - sleep(5); + usleep(NMBD_WAIT_INTERFACES_TIME_USEC); load_interfaces(); /* @@ -325,7 +325,7 @@ bool create_subnets(void) saved_handler = CatchSignal(SIGTERM, SIG_DFL); - sleep(5); + usleep(NMBD_WAIT_INTERFACES_TIME_USEC); load_interfaces(); CatchSignal(SIGTERM, saved_handler);