Ignore:
Timestamp:
Mar 12, 2008, 9:08:18 AM (17 years ago)
Author:
Paul Smedley
Message:

Update source to 3.0.28a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/nmbd/nmbd.c

    r1 r124  
    151151/************************************************************************** **
    152152 Reload the list of network interfaces.
     153 Doesn't return until a network interface is up.
    153154 ************************************************************************** */
    154155
    155 static BOOL reload_interfaces(time_t t)
     156static void reload_interfaces(time_t t)
    156157{
    157158        static time_t lastt;
     
    159160        struct subnet_record *subrec;
    160161
    161         if (t && ((t - lastt) < NMBD_INTERFACES_RELOAD)) return False;
     162        if (t && ((t - lastt) < NMBD_INTERFACES_RELOAD)) {
     163                return;
     164        }
    162165        lastt = t;
    163166
    164         if (!interfaces_changed()) return False;
     167        if (!interfaces_changed()) {
     168                return;
     169        }
    165170
    166171        /* the list of probed interfaces has changed, we may need to add/remove
    167172           some subnets */
    168173        load_interfaces();
     174
     175  try_again:
    169176
    170177        /* find any interfaces that need adding */
     
    222229                }
    223230        }
    224        
     231
    225232        rescan_listen_set = True;
    226233
    227         /* We need to shutdown if there are no subnets... */
     234        /* We need to wait if there are no subnets... */
    228235        if (FIRST_SUBNET == NULL) {
    229                 DEBUG(0,("reload_interfaces: No subnets to listen to. Shutting down...\n"));
    230                 return True;
    231         }
    232         return False;
     236                void (*saved_handler)(int);
     237
     238                DEBUG(0,("reload_interfaces: "
     239                        "No subnets to listen to. Waiting..\n"));
     240
     241                /*
     242                 * Whilst we're waiting for an interface, allow SIGTERM to
     243                 * cause us to exit.
     244                 */
     245
     246                saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
     247
     248                while (iface_count() == 0) {
     249                        sleep(5);
     250                        load_interfaces();
     251                }
     252
     253                /*
     254                 * We got an interface, restore our normal term handler.
     255                 */
     256
     257                CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
     258                goto try_again;
     259        }
    233260}
    234261
     
    268295/**************************************************************************** **
    269296 * React on 'smbcontrol nmbd reload-config' in the same way as to SIGHUP
    270  * We use buf here to return BOOL result to process() when reload_interfaces()
    271  * detects that there are no subnets.
    272297 **************************************************************************** */
    273298
     
    279304        reload_nmbd_services( True );
    280305        reopen_logs();
    281        
    282         if(buf) {
    283                 /* We were called from process() */
    284                 /* If reload_interfaces() returned True */
    285                 /* we need to shutdown if there are no subnets... */
    286                 /* pass this info back to process() */
    287                 *((BOOL*)buf) = reload_interfaces(0); 
    288         }
     306        reload_interfaces(0);
    289307}
    290308
     
    349367{
    350368        BOOL run_election;
    351         BOOL no_subnets;
    352369
    353370        while( True ) {
     
    559576                        DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) );
    560577                        msg_reload_nmbd_services(MSG_SMB_CONF_UPDATED,
    561                                                  pid_to_procid(0), (void*) &no_subnets, 0, NULL);
    562                         if(no_subnets)
    563                                 return;
     578                                                 pid_to_procid(0), NULL, 0, NULL);
    564579                        reload_after_sighup = 0;
    565580                }
     
    567582                /* check for new network interfaces */
    568583
    569                 if(reload_interfaces(t))
    570                         return;
     584                reload_interfaces(t);
    571585
    572586                /* free up temp memory */
    573                         lp_TALLOC_FREE();
     587                lp_TALLOC_FREE();
    574588        }
    575589}
Note: See TracChangeset for help on using the changeset viewer.