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
/* We only count IPv4, non-loopback interfaces here. */
while (iface_count_v4_nl() == 0) {
- sleep(5);
+ usleep(NMBD_WAIT_INTERFACES_TIME_USEC);
load_interfaces();
}
#include "libsmb/nmblib.h"
#include "nmbd/nmbd_proto.h"
+#define NMBD_WAIT_INTERFACES_TIME_USEC (250 * 1000)
+
/****************************************************************************
true if two IPv4 addresses are equal
****************************************************************************/
saved_handler = CatchSignal(SIGTERM, SIG_DFL);
- sleep(5);
+ usleep(NMBD_WAIT_INTERFACES_TIME_USEC);
load_interfaces();
/*
saved_handler = CatchSignal(SIGTERM, SIG_DFL);
- sleep(5);
+ usleep(NMBD_WAIT_INTERFACES_TIME_USEC);
load_interfaces();
CatchSignal(SIGTERM, saved_handler);