projects
/
yaz-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1cb13d3
)
Make yaz_log_reopen async-signal safe YAZ-845
author
Adam Dickmeiss
<adam@indexdata.dk>
Thu, 11 Jun 2015 18:25:08 +0000
(20:25 +0200)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Thu, 11 Jun 2015 18:25:08 +0000
(20:25 +0200)
src/log.c
patch
|
blob
|
history
diff --git
a/src/log.c
b/src/log.c
index
8bc5ad0
..
d005378
100644
(file)
--- a/
src/log.c
+++ b/
src/log.c
@@
-103,8
+103,12
@@
static struct {
static unsigned int next_log_bit = YLOG_LAST_BIT<<1; /* first dynamic bit */
static unsigned int next_log_bit = YLOG_LAST_BIT<<1; /* first dynamic bit */
+static int yaz_log_reopen_flag = 0;
+
static YAZ_MUTEX log_mutex = 0;
static YAZ_MUTEX log_mutex = 0;
+static void yaz_log_open(void);
+
void yaz_log_lock(void)
{
yaz_mutex_enter(log_mutex);
void yaz_log_lock(void)
{
yaz_mutex_enter(log_mutex);
@@
-169,7
+173,7
@@
void yaz_log_init_file(const char *fname)
yaz_log_info.type = use_none; /* NULL name; use no file at all */
yaz_log_info.l_fname[0] = '\0';
}
yaz_log_info.type = use_none; /* NULL name; use no file at all */
yaz_log_info.l_fname[0] = '\0';
}
- yaz_log_reopen();
+ yaz_log_open();
}
static void rotate_log(const char *cur_fname)
}
static void rotate_log(const char *cur_fname)
@@
-216,7
+220,7
@@
void yaz_log_init_level(int level)
if ( (l_level & YLOG_FLUSH) != (level & YLOG_FLUSH) )
{
l_level = level;
if ( (l_level & YLOG_FLUSH) != (level & YLOG_FLUSH) )
{
l_level = level;
- yaz_log_reopen(); /* make sure we set buffering right */
+ yaz_log_open(); /* make sure we set buffering right */
}
else
l_level = level;
}
else
l_level = level;
@@
-306,6
+310,11
@@
static void yaz_log_open_check(struct tm *tm, int force, const char *filemode)
if (yaz_log_info.type != use_file)
return;
if (yaz_log_info.type != use_file)
return;
+ if (yaz_log_reopen_flag)
+ {
+ force = 1;
+ yaz_log_reopen_flag = 0;
+ }
if (*yaz_log_info.l_fname)
{
strftime(new_filename, sizeof(new_filename)-1, yaz_log_info.l_fname,
if (*yaz_log_info.l_fname)
{
strftime(new_filename, sizeof(new_filename)-1, yaz_log_info.l_fname,
@@
-368,9
+377,13
@@
static void yaz_log_do_reopen(const char *filemode)
yaz_log_unlock();
}
yaz_log_unlock();
}
-
void yaz_log_reopen()
{
void yaz_log_reopen()
{
+ yaz_log_reopen_flag = 1;
+}
+
+static void yaz_log_open()
+{
yaz_log_do_reopen("a");
}
yaz_log_do_reopen("a");
}