[PATCH] fix dhcp log concurrency problem
QiuXi
qiuxi1 at huawei.com
Wed Dec 23 03:20:27 UTC 2020
When running dhcp client on Linux, it gets corrupted randomly.
Then we found in function log_debug/log_info/log_error..,there exists
a concurrency problem, now to fix it.
modified: omapip/errwarn.c
diff --git a/omapip/errwarn.c b/omapip/errwarn.c
index 6317fe4c..46d13fe9 100644
--- a/omapip/errwarn.c
+++ b/omapip/errwarn.c
@@ -45,14 +45,14 @@ int log_perror = 1;
void (*log_cleanup) (void);
#define CVT_BUF_MAX 1023
-static char mbuf [CVT_BUF_MAX + 1];
-static char fbuf [CVT_BUF_MAX + 1];
/* Log an error message, then exit... */
void log_fatal (const char * fmt, ... )
{
va_list list;
+ char mbuf [CVT_BUF_MAX + 1];
+ char fbuf [CVT_BUF_MAX + 1];
do_percentm (fbuf, sizeof fbuf, fmt);
@@ -92,6 +92,8 @@ void log_fatal (const char * fmt, ... )
int log_error (const char * fmt, ...)
{
va_list list;
+ char mbuf [CVT_BUF_MAX + 1];
+ char fbuf [CVT_BUF_MAX + 1];
do_percentm (fbuf, sizeof fbuf, fmt);
@@ -119,6 +121,8 @@ int log_error (const char * fmt, ...)
int log_info (const char *fmt, ...)
{
va_list list;
+ char mbuf [CVT_BUF_MAX + 1];
+ char fbuf [CVT_BUF_MAX + 1];
do_percentm (fbuf, sizeof fbuf, fmt);
@@ -146,6 +150,8 @@ int log_info (const char *fmt, ...)
int log_debug (const char *fmt, ...)
{
va_list list;
+ char mbuf [CVT_BUF_MAX + 1];
+ char fbuf [CVT_BUF_MAX + 1];
do_percentm (fbuf, sizeof fbuf, fmt);
--
2.12.3
More information about the dhcp-users
mailing list