From: Jeremy Allison Date: Wed, 20 Aug 2008 01:13:25 +0000 (-0700) Subject: Fix bug 5697 nmbd spins in reload_interfaces when only loopback exists. X-Git-Tag: release-3-0-32~5 X-Git-Url: http://git.samba.org/samba.git/?p=tprouty%2Fsamba.git;a=commitdiff_plain;h=6acd5c086b0019f54749a67756975b3c0ba35ac0 Fix bug 5697 nmbd spins in reload_interfaces when only loopback exists. Reported by Ted Percival . Jeremy. --- diff --git a/source/lib/interface.c b/source/lib/interface.c index e2c9294b28..32a53f25ab 100644 --- a/source/lib/interface.c +++ b/source/lib/interface.c @@ -300,6 +300,23 @@ int iface_count(void) return ret; } +/**************************************************************************** + how many non-loopback interfaces do we have + **************************************************************************/ +int iface_count_nl(void) +{ + int ret = 0; + struct interface *i; + + for (i=local_interfaces;i;i=i->next) { + if (ip_equal(i->ip, loopback_ip)) { + continue; + } + ret++; + } + return ret; +} + /**************************************************************************** return the Nth interface **************************************************************************/ diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index df383996fd..7daf62ac21 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -248,7 +248,7 @@ static void reload_interfaces(time_t t) BlockSignals(false, SIGTERM); - while (iface_count() == 0 && !got_sig_term) { + while (iface_count_nl() == 0 && !got_sig_term) { sleep(5); load_interfaces(); } diff --git a/source/nmbd/nmbd_subnetdb.c b/source/nmbd/nmbd_subnetdb.c index 61db70fae0..3732407c87 100644 --- a/source/nmbd/nmbd_subnetdb.c +++ b/source/nmbd/nmbd_subnetdb.c @@ -186,12 +186,12 @@ BOOL create_subnets(void) try_interfaces_again: - if (iface_count() == 0) { - DEBUG(0,("create_subnets: No local interfaces !\n")); + if (iface_count_nl() == 0) { + DEBUG(0,("create_subnets: No non-loopback local interfaces !\n")); DEBUG(0,("create_subnets: Waiting for an interface to appear ...\n")); } - while (iface_count() == 0) { + while (iface_count_nl() == 0) { void (*saved_handler)(int); /*