diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/logger.c | 33 | ||||
-rw-r--r-- | main/taskprocessor.c | 17 |
2 files changed, 18 insertions, 32 deletions
diff --git a/main/logger.c b/main/logger.c index 73b8ee1a2..fac68d9b6 100644 --- a/main/logger.c +++ b/main/logger.c @@ -560,13 +560,14 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo } /* \brief Read config, setup channels. - * \param locked The logchannels list is locked and this is a reload * \param altconf Alternate configuration file to read. * + * \pre logchannels list is write locked + * * \retval 0 Success * \retval -1 No config found or Failed */ -static int init_logger_chain(int locked, const char *altconf) +static int init_logger_chain(const char *altconf) { struct logchannel *chan; struct ast_config *cfg; @@ -578,10 +579,6 @@ static int init_logger_chain(int locked, const char *altconf) cfg = NULL; } - if (!locked) { - AST_RWLIST_WRLOCK(&logchannels); - } - /* Set defaults */ hostname[0] = '\0'; display_callids = 1; @@ -597,9 +594,6 @@ static int init_logger_chain(int locked, const char *altconf) ast_free(chan); } global_logmask = 0; - if (!locked) { - AST_RWLIST_UNLOCK(&logchannels); - } errno = 0; /* close syslog */ @@ -615,14 +609,8 @@ static int init_logger_chain(int locked, const char *altconf) chan->logmask = __LOG_WARNING | __LOG_NOTICE | __LOG_ERROR; memcpy(&chan->formatter, &logformatter_default, sizeof(chan->formatter)); - if (!locked) { - AST_RWLIST_WRLOCK(&logchannels); - } AST_RWLIST_INSERT_HEAD(&logchannels, chan, list); global_logmask |= chan->logmask; - if (!locked) { - AST_RWLIST_UNLOCK(&logchannels); - } return -1; } @@ -675,9 +663,6 @@ static int init_logger_chain(int locked, const char *altconf) } } - if (!locked) { - AST_RWLIST_WRLOCK(&logchannels); - } var = ast_variable_browse(cfg, "logfiles"); for (; var; var = var->next) { if (!(chan = make_logchannel(var->name, var->value, var->lineno, 0))) { @@ -697,10 +682,6 @@ static int init_logger_chain(int locked, const char *altconf) qlog = NULL; } - if (!locked) { - AST_RWLIST_UNLOCK(&logchannels); - } - ast_config_destroy(cfg); return 0; @@ -1055,7 +1036,7 @@ static int reload_logger(int rotate, const char *altconf) filesize_reload_needed = 0; - init_logger_chain(1 /* locked */, altconf); + init_logger_chain(altconf); ast_unload_realtime("queue_log"); if (logfiles.queue_log) { @@ -1153,7 +1134,7 @@ int ast_logger_rotate_channel(const char *log_channel) } } - init_logger_chain(1 /* locked */, NULL); + init_logger_chain(NULL); AST_RWLIST_UNLOCK(&logchannels); @@ -1725,7 +1706,9 @@ int init_logger(void) ast_mkdir(ast_config_AST_LOG_DIR, 0777); /* create log channels */ - res = init_logger_chain(0 /* locked */, NULL); + AST_RWLIST_WRLOCK(&logchannels); + res = init_logger_chain(NULL); + AST_RWLIST_UNLOCK(&logchannels); ast_verb_update(); logger_initialized = 1; if (res) { diff --git a/main/taskprocessor.c b/main/taskprocessor.c index a45be1a17..5b8ff08f1 100644 --- a/main/taskprocessor.c +++ b/main/taskprocessor.c @@ -332,10 +332,11 @@ static void *tps_task_free(struct tps_task *task) } /* taskprocessor tab completion */ -static char *tps_taskprocessor_tab_complete(struct ast_taskprocessor *p, struct ast_cli_args *a) +static char *tps_taskprocessor_tab_complete(struct ast_cli_args *a) { int tklen; int wordnum = 0; + struct ast_taskprocessor *p; char *name = NULL; struct ao2_iterator i; @@ -347,10 +348,10 @@ static char *tps_taskprocessor_tab_complete(struct ast_taskprocessor *p, struct while ((p = ao2_iterator_next(&i))) { if (!strncasecmp(a->word, p->name, tklen) && ++wordnum > a->n) { name = ast_strdup(p->name); - ao2_ref(p, -1); + ast_taskprocessor_unreference(p); break; } - ao2_ref(p, -1); + ast_taskprocessor_unreference(p); } ao2_iterator_destroy(&i); return name; @@ -372,7 +373,7 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args const char *name; struct timeval when; struct timespec ts; - struct ast_taskprocessor *tps = NULL; + struct ast_taskprocessor *tps; switch (cmd) { case CLI_INIT: @@ -382,7 +383,7 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args " Displays the time required for a task to be processed\n"; return NULL; case CLI_GENERATE: - return tps_taskprocessor_tab_complete(tps, a); + return tps_taskprocessor_tab_complete(a); } if (a->argc != 4) @@ -410,7 +411,7 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args if (ast_taskprocessor_push(tps, tps_ping_handler, 0) < 0) { ast_mutex_unlock(&cli_ping_cond_lock); ast_cli(a->fd, "\nping failed: could not push task to %s\n\n", name); - ao2_ref(tps, -1); + ast_taskprocessor_unreference(tps); return CLI_FAILURE; } ast_cond_timedwait(&cli_ping_cond, &cli_ping_cond_lock, &ts); @@ -419,7 +420,7 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args end = ast_tvnow(); delta = ast_tvsub(end, begin); ast_cli(a->fd, "\n\t%24s ping time: %.1ld.%.6ld sec\n\n", name, (long)delta.tv_sec, (long int)delta.tv_usec); - ao2_ref(tps, -1); + ast_taskprocessor_unreference(tps); return CLI_SUCCESS; } @@ -673,6 +674,8 @@ static struct ast_taskprocessor *__allocate_taskprocessor(const char *name, stru if (!(ao2_link(tps_singletons, p))) { ast_log(LOG_ERROR, "Failed to add taskprocessor '%s' to container\n", p->name); + listener->tps = NULL; + ao2_ref(p, -1); return NULL; } |