Author: jra
Date: 2007-06-05 01:59:37 +0000 (Tue, 05 Jun 2007)
New Revision: 23349

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23349

Log:
Fix from Steve Langasek <[EMAIL PROTECTED]> to
allow SIGTERM to cause nmbd to exit on awaiting
an interface to come up. Debian bug #168079
Jeremy.

Modified:
   branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c
   branches/SAMBA_3_0_25/source/nmbd/nmbd_subnetdb.c
   branches/SAMBA_3_0_26/source/nmbd/nmbd_subnetdb.c


Changeset:
Modified: branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c
===================================================================
--- branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c      2007-06-04 23:51:19 UTC 
(rev 23348)
+++ branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c      2007-06-05 01:59:37 UTC 
(rev 23349)
@@ -185,12 +185,28 @@
        struct in_addr unicast_ip, ipzero;
 
        if(num_interfaces == 0) {
+               void (*saved_handler)(int);
+
                DEBUG(0,("create_subnets: No local interfaces !\n"));
                DEBUG(0,("create_subnets: Waiting for an interface to appear 
...\n"));
+
+               /* 
+                * Whilst we're waiting for an interface, allow SIGTERM to
+                * cause us to exit.
+                */
+
+               saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
+
                while (iface_count() == 0) {
                        sleep(5);
                        load_interfaces();
                }
+
+               /* 
+                * We got an interface, restore our normal term handler.
+                */
+
+               CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
        }
 
        num_interfaces = iface_count();

Modified: branches/SAMBA_3_0_25/source/nmbd/nmbd_subnetdb.c
===================================================================
--- branches/SAMBA_3_0_25/source/nmbd/nmbd_subnetdb.c   2007-06-04 23:51:19 UTC 
(rev 23348)
+++ branches/SAMBA_3_0_25/source/nmbd/nmbd_subnetdb.c   2007-06-05 01:59:37 UTC 
(rev 23349)
@@ -185,12 +185,28 @@
        struct in_addr unicast_ip, ipzero;
 
        if(num_interfaces == 0) {
+               void (*saved_handler)(int);
+
                DEBUG(0,("create_subnets: No local interfaces !\n"));
                DEBUG(0,("create_subnets: Waiting for an interface to appear 
...\n"));
+
+               /* 
+                * Whilst we're waiting for an interface, allow SIGTERM to
+                * cause us to exit.
+                */
+
+               saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
+
                while (iface_count() == 0) {
                        sleep(5);
                        load_interfaces();
                }
+
+               /* 
+                * We got an interface, restore our normal term handler.
+                */
+
+               CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
        }
 
        num_interfaces = iface_count();

Modified: branches/SAMBA_3_0_26/source/nmbd/nmbd_subnetdb.c
===================================================================
--- branches/SAMBA_3_0_26/source/nmbd/nmbd_subnetdb.c   2007-06-04 23:51:19 UTC 
(rev 23348)
+++ branches/SAMBA_3_0_26/source/nmbd/nmbd_subnetdb.c   2007-06-05 01:59:37 UTC 
(rev 23349)
@@ -185,12 +185,28 @@
        struct in_addr unicast_ip, ipzero;
 
        if(num_interfaces == 0) {
+               void (*saved_handler)(int);
+
                DEBUG(0,("create_subnets: No local interfaces !\n"));
                DEBUG(0,("create_subnets: Waiting for an interface to appear 
...\n"));
+
+               /* 
+                * Whilst we're waiting for an interface, allow SIGTERM to
+                * cause us to exit.
+                */
+
+               saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
+
                while (iface_count() == 0) {
                        sleep(5);
                        load_interfaces();
                }
+
+               /* 
+                * We got an interface, restore our normal term handler.
+                */
+
+               CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
        }
 
        num_interfaces = iface_count();

Reply via email to