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

Update source to 3.0.28a

Location:
branches/samba-3.0/source/nmbd
Files:
5 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}
  • branches/samba-3.0/source/nmbd/nmbd_namelistdb.c

    r105 r124  
    295295
    296296void standard_fail_register( struct subnet_record   *subrec,
    297                              struct response_record *rrec,
    298297                             struct nmb_name        *nmbname )
    299298{
  • branches/samba-3.0/source/nmbd/nmbd_nameregister.c

    r1 r124  
    154154                        (*(register_name_success_function)rrec->success_fn)(subrec, rrec->userdata, answer_name, nb_flags, ttl, register_ip);
    155155        } else {
     156                struct nmb_name qname = *question_name;
    156157                if( rrec->fail_fn)
    157158                        (*(register_name_fail_function)rrec->fail_fn)(subrec, rrec, question_name);
    158159                /* Remove the name. */
    159                 standard_fail_register( subrec, rrec, question_name);
     160                standard_fail_register( subrec, &qname);
    160161        }
    161162
     
    282283                        (*(register_name_success_function)rrec->success_fn)(subrec, rrec->userdata, question_name, nb_flags, ttl, registered_ip);
    283284        } else {
     285                struct nmb_name qname = *question_name;
    284286                if( rrec->fail_fn)
    285287                        (*(register_name_fail_function)rrec->fail_fn)(subrec, rrec, question_name);
    286288                /* Remove the name. */
    287                 standard_fail_register( subrec, rrec, question_name);
     289                standard_fail_register( subrec, &qname);
    288290        }
    289291
  • branches/samba-3.0/source/nmbd/nmbd_packets.c

    r108 r124  
    16071607                struct response_record *rrec, *nextrrec;
    16081608
     1609  restart:
     1610
    16091611                for (rrec = subrec->responselist; rrec; rrec = nextrrec) {
    16101612                        nextrrec = rrec->next;
     
    16451647                                                        remove_response_record(subrec, rrec);
    16461648                                                }
     1649                                                /* We have changed subrec->responselist,
     1650                                                 * restart from the beginning of this list. */
     1651                                                goto restart;
    16471652                                        } /* !rrec->in_expitation_processing */
    16481653                                } /* rrec->repeat_count > 0 */
  • branches/samba-3.0/source/nmbd/nmbd_responserecordsdb.c

    r1 r124  
    3333                                struct response_record *rrec)
    3434{
    35         struct response_record *rrec2;
    36 
    3735        num_response_packets++; /* count of total number of packets still around */
    3836
     
    4038                rrec->response_id, subrec->subnet_name, num_response_packets));
    4139
    42         if (!subrec->responselist) {
    43                 subrec->responselist = rrec;
    44                 rrec->prev = NULL;
    45                 rrec->next = NULL;
    46                 return;
    47         }
    48  
    49         for (rrec2 = subrec->responselist; rrec2->next; rrec2 = rrec2->next)
    50                 ;
    51  
    52         rrec2->next = rrec;
    53         rrec->next = NULL;
    54         rrec->prev = rrec2;
     40        DLIST_ADD_END(subrec->responselist, rrec, struct response_record *);
    5541}
    5642
     
    6248                                struct response_record *rrec)
    6349{
    64         if (rrec->prev)
    65                 rrec->prev->next = rrec->next;
    66         if (rrec->next)
    67                 rrec->next->prev = rrec->prev;
    68 
    69         if (subrec->responselist == rrec)
    70                 subrec->responselist = rrec->next;
     50        /* It is possible this can be called twice,
     51           with a rrec pointer that has been freed. So
     52           before we inderect into rrec, search for it
     53           on the responselist first. Bug #3617. JRA. */
     54
     55        struct response_record *p = NULL;
     56
     57        for (p = subrec->responselist; p; p = p->next) {
     58                if (p == rrec) {
     59                        break;
     60                }
     61        }
     62
     63        if (p == NULL) {
     64                /* We didn't find rrec on the list. */
     65                return;
     66        }
     67
     68        DLIST_REMOVE(subrec->responselist, rrec);
    7169
    7270        if(rrec->userdata) {
Note: See TracChangeset for help on using the changeset viewer.