bus: Fix maximum log level for different groups after removal of a logger
authorTobias Brunner <tobias@strongswan.org>
Wed, 9 Nov 2016 17:29:46 +0000 (18:29 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 11 Nov 2016 14:33:44 +0000 (15:33 +0100)
The log level was incorrectly set to the same value for all groups.

Fixes: dac15e03c828 ("bus: Fix maximum log levels when mixing log/vlog
implementing loggers")

src/libcharon/bus/bus.c

index 6b3cea8..8e1e72b 100644 (file)
@@ -233,6 +233,7 @@ static inline void unregister_logger(private_bus_t *this, logger_t *logger)
        enumerator_t *enumerator;
        linked_list_t *loggers;
        log_entry_t *entry, *found = NULL;
+       debug_t group;
 
        loggers = this->loggers[DBG_MAX];
        enumerator = loggers->create_enumerator(loggers);
@@ -249,17 +250,16 @@ static inline void unregister_logger(private_bus_t *this, logger_t *logger)
 
        if (found)
        {
-               level_t level = LEVEL_SILENT, vlevel = LEVEL_SILENT;
-               debug_t group;
-
                for (group = 0; group < DBG_MAX; group++)
                {
                        if (found->levels[group] > LEVEL_SILENT)
                        {
+                               level_t level = LEVEL_SILENT, vlevel = LEVEL_SILENT;
+
                                loggers = this->loggers[group];
                                loggers->remove(loggers, found, NULL);
-                               loggers->find_first(loggers, (linked_list_match_t)find_max_levels, NULL,
-                                                                       &group, &level, &vlevel);
+                               loggers->find_first(loggers, (linked_list_match_t)find_max_levels,
+                                                                       NULL, group, &level, &vlevel);
                                set_level(&this->max_level[group], level);
                                set_level(&this->max_vlevel[group], vlevel);
                        }