[PATCH] fix dhcp log concurrency problem

Rongxing Liu motion at liurongxing.com
Wed Dec 23 03:32:11 UTC 2020


Nice patch!

On Wed, Dec 23, 2020 at 11:21 AM QiuXi <qiuxi1 at huawei.com> wrote:

> 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
>
> _______________________________________________
> ISC funds the development of this software with paid support
> subscriptions. Contact us at https://www.isc.org/contact/ for more
> information.
>
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20201223/267ae440/attachment-0001.htm>


More information about the dhcp-users mailing list