Commit 2f16f60a authored by Hardy Simpson's avatar Hardy Simpson

bugfix: memory errors when doing zlog_init/zlog_fini multiple times

parent 6a762aed
......@@ -486,7 +486,7 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, int *time_c
switch (*p) {
case '%':
/* a string begin with %: %12.35d(%F %X,%l) */
/* a string begin with %: %12.35d(%F %X) */
/* process width and precision char in %-12.35P */
nread = 0;
......
This diff is collapsed.
......@@ -36,29 +36,32 @@ int main(int argc, char** argv)
printf("init fail");
return -2;
}
zc = zlog_get_category("my_cat");
if (!zc) {
printf("zlog_get_category fail\n");
zlog_fini();
return -1;
}
zlog_info(zc, "before update");
sleep(3);
sleep(1);
rc = zlog_reload("test_init.2.conf");
if (rc) {
printf("update fail\n");
}
zlog_info(zc, "after update");
zlog_profile();
zlog_fini();
sleep(1);
zlog_init("test_init.conf");
zc = zlog_get_category("my_cat");
if (!zc) {
printf("zlog_get_category fail\n");
zlog_fini();
return -1;
}
zlog_info(zc, "init again");
zlog_fini();
return 0;
}
[global]
strict init = true
buffer min = 100
buffer max = 200
default format = "%m%n"
[rules ]
*.* >stdout;
......@@ -32,7 +32,7 @@ int main(int argc, char** argv)
int i;
if (argc != 2) {
printf("test_init ntime\n");
printf("test_leak ntime\n");
return -1;
}
......@@ -41,16 +41,20 @@ int main(int argc, char** argv)
k = atoi(argv[1]);
while (k-- > 0) {
i = rand();
switch (i % 3) {
switch (i % 4) {
case 0:
rc = zlog_init("zlog.conf");
printf("init\n");
rc = dzlog_init("test_leak.conf", "xxx");
dzlog_info("init");
break;
case 1:
rc = zlog_reload(NULL);
printf("update\n");
dzlog_info("reload null");
break;
case 2:
rc = zlog_reload("test_leak.2.conf");
dzlog_info("reload 2");
break;
case 3:
zlog_fini();
printf("fini\n");
// printf("zlog_finish\tj=[%d], rc=[%d]\n", j, rc);
......@@ -58,7 +62,6 @@ int main(int argc, char** argv)
}
}
zlog_fini();
return 0;
}
......@@ -3,11 +3,10 @@ strict init = true
buffer min = 2048
buffer max = 4096
rotate lock file = /tmp/zlog.lock
default format = "%d(%F %T.%l) %-6V (%c:%F:%L) - %m%n"
default format = "%d(%F %T).%ms %-6V (%c:%F:%L) - %m%n"
[ levels ]
TEST = 40, LOG_INFO
[rules ]
my_cat.* >stderr;
*.* >stderr;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment