Changeset 124 for branches/samba-3.0/source/nmbd
- Timestamp:
- Mar 12, 2008, 9:08:18 AM (17 years ago)
- Location:
- branches/samba-3.0/source/nmbd
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/nmbd/nmbd.c
r1 r124 151 151 /************************************************************************** ** 152 152 Reload the list of network interfaces. 153 Doesn't return until a network interface is up. 153 154 ************************************************************************** */ 154 155 155 static BOOLreload_interfaces(time_t t)156 static void reload_interfaces(time_t t) 156 157 { 157 158 static time_t lastt; … … 159 160 struct subnet_record *subrec; 160 161 161 if (t && ((t - lastt) < NMBD_INTERFACES_RELOAD)) return False; 162 if (t && ((t - lastt) < NMBD_INTERFACES_RELOAD)) { 163 return; 164 } 162 165 lastt = t; 163 166 164 if (!interfaces_changed()) return False; 167 if (!interfaces_changed()) { 168 return; 169 } 165 170 166 171 /* the list of probed interfaces has changed, we may need to add/remove 167 172 some subnets */ 168 173 load_interfaces(); 174 175 try_again: 169 176 170 177 /* find any interfaces that need adding */ … … 222 229 } 223 230 } 224 231 225 232 rescan_listen_set = True; 226 233 227 /* We need to shutdownif there are no subnets... */234 /* We need to wait if there are no subnets... */ 228 235 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 } 233 260 } 234 261 … … 268 295 /**************************************************************************** ** 269 296 * 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.272 297 **************************************************************************** */ 273 298 … … 279 304 reload_nmbd_services( True ); 280 305 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); 289 307 } 290 308 … … 349 367 { 350 368 BOOL run_election; 351 BOOL no_subnets;352 369 353 370 while( True ) { … … 559 576 DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) ); 560 577 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); 564 579 reload_after_sighup = 0; 565 580 } … … 567 582 /* check for new network interfaces */ 568 583 569 if(reload_interfaces(t)) 570 return; 584 reload_interfaces(t); 571 585 572 586 /* free up temp memory */ 573 587 lp_TALLOC_FREE(); 574 588 } 575 589 } -
branches/samba-3.0/source/nmbd/nmbd_namelistdb.c
r105 r124 295 295 296 296 void standard_fail_register( struct subnet_record *subrec, 297 struct response_record *rrec,298 297 struct nmb_name *nmbname ) 299 298 { -
branches/samba-3.0/source/nmbd/nmbd_nameregister.c
r1 r124 154 154 (*(register_name_success_function)rrec->success_fn)(subrec, rrec->userdata, answer_name, nb_flags, ttl, register_ip); 155 155 } else { 156 struct nmb_name qname = *question_name; 156 157 if( rrec->fail_fn) 157 158 (*(register_name_fail_function)rrec->fail_fn)(subrec, rrec, question_name); 158 159 /* Remove the name. */ 159 standard_fail_register( subrec, rrec, question_name);160 standard_fail_register( subrec, &qname); 160 161 } 161 162 … … 282 283 (*(register_name_success_function)rrec->success_fn)(subrec, rrec->userdata, question_name, nb_flags, ttl, registered_ip); 283 284 } else { 285 struct nmb_name qname = *question_name; 284 286 if( rrec->fail_fn) 285 287 (*(register_name_fail_function)rrec->fail_fn)(subrec, rrec, question_name); 286 288 /* Remove the name. */ 287 standard_fail_register( subrec, rrec, question_name);289 standard_fail_register( subrec, &qname); 288 290 } 289 291 -
branches/samba-3.0/source/nmbd/nmbd_packets.c
r108 r124 1607 1607 struct response_record *rrec, *nextrrec; 1608 1608 1609 restart: 1610 1609 1611 for (rrec = subrec->responselist; rrec; rrec = nextrrec) { 1610 1612 nextrrec = rrec->next; … … 1645 1647 remove_response_record(subrec, rrec); 1646 1648 } 1649 /* We have changed subrec->responselist, 1650 * restart from the beginning of this list. */ 1651 goto restart; 1647 1652 } /* !rrec->in_expitation_processing */ 1648 1653 } /* rrec->repeat_count > 0 */ -
branches/samba-3.0/source/nmbd/nmbd_responserecordsdb.c
r1 r124 33 33 struct response_record *rrec) 34 34 { 35 struct response_record *rrec2;36 37 35 num_response_packets++; /* count of total number of packets still around */ 38 36 … … 40 38 rrec->response_id, subrec->subnet_name, num_response_packets)); 41 39 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 *); 55 41 } 56 42 … … 62 48 struct response_record *rrec) 63 49 { 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); 71 69 72 70 if(rrec->userdata) {
Note:
See TracChangeset
for help on using the changeset viewer.