]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
nmbd: Reduce the wait interface loop sleep time
authorSamuel Cabrero <scabrero@samba.org>
Fri, 14 May 2021 10:35:44 +0000 (12:35 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 14 May 2021 20:52:47 +0000 (20:52 +0000)
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 <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 14 20:52:47 UTC 2021 on sn-devel-184

source3/nmbd/nmbd.c
source3/nmbd/nmbd.h
source3/nmbd/nmbd_subnetdb.c

index 05645967e053a3e2ac8d4d98d11016c2337d404b..c33d3a441ae2d3bc2c92cb3069d7631590d11b34 100644 (file)
@@ -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();
                }
 
index 551868e29adc84ebd58d5433e30b4230ec17d663..f207eb9304ebdfd5956f3aa1dcf0a97eb8a99d77 100644 (file)
@@ -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
 ****************************************************************************/
index 983369f0c6fd2f77e6aaee56db66eb16c784bf31..b2bcedddc3509f0284169bcdf6b32708ebbc78bc 100644 (file)
@@ -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);