mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 16:33:34 +00:00
Add some read/write locking magic to make logger reload operate again.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81290 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -315,7 +315,7 @@ static struct logchannel *make_logchannel(char *channel, char *components, int l
|
|||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_logger_chain(int reload)
|
static void init_logger_chain(int reload, int locked)
|
||||||
{
|
{
|
||||||
struct logchannel *chan;
|
struct logchannel *chan;
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
@@ -327,9 +327,11 @@ static void init_logger_chain(int reload)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* delete our list of log channels */
|
/* delete our list of log channels */
|
||||||
|
if (!locked)
|
||||||
AST_RWLIST_WRLOCK(&logchannels);
|
AST_RWLIST_WRLOCK(&logchannels);
|
||||||
while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list)))
|
while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list)))
|
||||||
free(chan);
|
free(chan);
|
||||||
|
if (!locked)
|
||||||
AST_RWLIST_UNLOCK(&logchannels);
|
AST_RWLIST_UNLOCK(&logchannels);
|
||||||
|
|
||||||
global_logmask = 0;
|
global_logmask = 0;
|
||||||
@@ -347,8 +349,10 @@ static void init_logger_chain(int reload)
|
|||||||
return;
|
return;
|
||||||
chan->type = LOGTYPE_CONSOLE;
|
chan->type = LOGTYPE_CONSOLE;
|
||||||
chan->logmask = 28; /*warning,notice,error */
|
chan->logmask = 28; /*warning,notice,error */
|
||||||
|
if (!locked)
|
||||||
AST_RWLIST_WRLOCK(&logchannels);
|
AST_RWLIST_WRLOCK(&logchannels);
|
||||||
AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
|
AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
|
||||||
|
if (!locked)
|
||||||
AST_RWLIST_UNLOCK(&logchannels);
|
AST_RWLIST_UNLOCK(&logchannels);
|
||||||
global_logmask |= chan->logmask;
|
global_logmask |= chan->logmask;
|
||||||
return;
|
return;
|
||||||
@@ -392,6 +396,7 @@ static void init_logger_chain(int reload)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!locked)
|
||||||
AST_RWLIST_WRLOCK(&logchannels);
|
AST_RWLIST_WRLOCK(&logchannels);
|
||||||
var = ast_variable_browse(cfg, "logfiles");
|
var = ast_variable_browse(cfg, "logfiles");
|
||||||
for (; var; var = var->next) {
|
for (; var; var = var->next) {
|
||||||
@@ -400,6 +405,7 @@ static void init_logger_chain(int reload)
|
|||||||
AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
|
AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
|
||||||
global_logmask |= chan->logmask;
|
global_logmask |= chan->logmask;
|
||||||
}
|
}
|
||||||
|
if (!locked)
|
||||||
AST_RWLIST_UNLOCK(&logchannels);
|
AST_RWLIST_UNLOCK(&logchannels);
|
||||||
|
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
@@ -568,7 +574,7 @@ int reload_logger(int rotate)
|
|||||||
|
|
||||||
filesize_reload_needed = 0;
|
filesize_reload_needed = 0;
|
||||||
|
|
||||||
init_logger_chain(1);
|
init_logger_chain(1, 1);
|
||||||
|
|
||||||
if (logfiles.event_log) {
|
if (logfiles.event_log) {
|
||||||
snprintf(old, sizeof(old), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG);
|
snprintf(old, sizeof(old), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG);
|
||||||
@@ -593,7 +599,9 @@ int reload_logger(int rotate)
|
|||||||
|
|
||||||
qlog = fopen(old, "a");
|
qlog = fopen(old, "a");
|
||||||
if (qlog) {
|
if (qlog) {
|
||||||
|
AST_RWLIST_UNLOCK(&logchannels);
|
||||||
ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
|
ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
|
||||||
|
AST_RWLIST_WRLOCK(&logchannels);
|
||||||
ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n");
|
ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n");
|
||||||
if (option_verbose)
|
if (option_verbose)
|
||||||
ast_verbose("Asterisk Queue Logger restarted\n");
|
ast_verbose("Asterisk Queue Logger restarted\n");
|
||||||
@@ -886,7 +894,7 @@ int init_logger(void)
|
|||||||
ast_mkdir(ast_config_AST_LOG_DIR, 0777);
|
ast_mkdir(ast_config_AST_LOG_DIR, 0777);
|
||||||
|
|
||||||
/* create log channels */
|
/* create log channels */
|
||||||
init_logger_chain(0);
|
init_logger_chain(0, 0);
|
||||||
|
|
||||||
/* create the eventlog */
|
/* create the eventlog */
|
||||||
if (logfiles.event_log) {
|
if (logfiles.event_log) {
|
||||||
|
Reference in New Issue
Block a user