Navigation



Ignore:
Timestamp:
Apr 9, 2019, 10:46:50 PM (5 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
histedit_source:
4e04e2f73d936608db88f0e70d10049fcaf66190
Message:

rt_default: add reload support.

When SIGUSR1 is sent to the freeDiameter process, rt_default reloads
its config file.

Written for Effortel Technologies SA, published with their consent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rt_default/rtd_rules.c

    r1179 r1336  
    4747 *  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.
    4848 *
    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.
    5050 */
    5151
     
    390390}
    391391
    392 /* Destroy the module's data */
    393 void rtd_fini(void)
     392static void free_targets(void)
    394393{
    395394        int i;
    396        
    397         TRACE_ENTRY();
    398395
    399396        for (i = 0; i < RTD_TAR_MAX; i++) {
     
    402399                }
    403400        }
    404        
     401}
     402
     403/* Destroy the module's data */
     404void rtd_fini(void)
     405{
     406        TRACE_ENTRY();
     407
     408        free_targets();
    405409}
    406410
     
    493497       
    494498        return 0;
     499}
     500
     501void 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        }
    495533}
    496534
Note: See TracChangeset for help on using the changeset viewer.