Fix bug 5697 nmbd spins in reload_interfaces when only loopback exists.
authorJeremy Allison <jra@samba.org>
Wed, 20 Aug 2008 01:13:25 +0000 (18:13 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 20 Aug 2008 01:13:25 +0000 (18:13 -0700)
Reported by Ted Percival <ted@midg3t.net>.
Jeremy.

source/lib/interface.c
source/nmbd/nmbd.c
source/nmbd/nmbd_subnetdb.c

index e2c9294..32a53f2 100644 (file)
@@ -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
   **************************************************************************/
index df38399..7daf62a 100644 (file)
@@ -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();
                }
index 61db70f..3732407 100644 (file)
@@ -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);
 
                /*