Changeset 1336:cec0812038bb in freeDiameter for extensions/rt_default/rtd_rules.c
- Timestamp:
- Apr 9, 2019, 10:46:50 PM (5 years ago)
- Branch:
- default
- Phase:
- public
- histedit_source:
- 4e04e2f73d936608db88f0e70d10049fcaf66190
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rt_default/rtd_rules.c
r1179 r1336 47 47 * Under each TARGET element, we have the list of RULES that are defined for this target, ordered by CRITERIA type, then is_regex, then string value. 48 48 * 49 * Note: Except during configuration parsing and module termination, the lists are only ever accessed read-only, so we do not need a lock.49 * Note: Access these only when holding rtd_lock; config reload may change the underlying data. 50 50 */ 51 51 … … 390 390 } 391 391 392 /* Destroy the module's data */ 393 void rtd_fini(void) 392 static void free_targets(void) 394 393 { 395 394 int i; 396 397 TRACE_ENTRY();398 395 399 396 for (i = 0; i < RTD_TAR_MAX; i++) { … … 402 399 } 403 400 } 404 401 } 402 403 /* Destroy the module's data */ 404 void rtd_fini(void) 405 { 406 TRACE_ENTRY(); 407 408 free_targets(); 405 409 } 406 410 … … 493 497 494 498 return 0; 499 } 500 501 void rtd_conf_reload(char *config_file) 502 { 503 /* save old config in case reload goes wrong */ 504 struct fd_list old_config[RTD_TAR_MAX]; 505 int i; 506 507 for (i = 0; i < RTD_TAR_MAX; i++) { 508 old_config[i] = TARGETS[i]; 509 } 510 memset(TARGETS, 0, sizeof(*TARGETS) * RTD_TAR_MAX); 511 for (i = 0; i < RTD_TAR_MAX; i++) { 512 fd_list_init(&TARGETS[i], NULL); 513 } 514 515 if (rtd_conf_handle(config_file) != 0) { 516 fd_log_notice("rt_default: error reloading configuration, restoring previous configuration"); 517 free_targets(); 518 for (i = 0; i < RTD_TAR_MAX; i++) { 519 TARGETS[i] = old_config[i]; 520 } 521 } else { 522 /* this has to be done in this weird way because the items contain back pointers referencing TARGETS */ 523 struct fd_list save_config[RTD_TAR_MAX]; 524 for (i = 0; i < RTD_TAR_MAX; i++) { 525 save_config[i] = TARGETS[i]; 526 TARGETS[i] = old_config[i]; 527 } 528 free_targets(); 529 for (i = 0; i < RTD_TAR_MAX; i++) { 530 TARGETS[i] = save_config[i]; 531 } 532 } 495 533 } 496 534
Note: See TracChangeset
for help on using the changeset viewer.