aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-05-31 07:34:39 -0700
committerDave Barach <openvpp@barachs.net>2019-06-04 16:05:11 +0000
commitd31a59806aa8f0e4c6d8ce7857f543ed9814c69a (patch)
tree327b4cc9be0bb31eea7df887fb3c3a6488384006
parent68577d2982a345537e300e99a8c0e0311fe08ce1 (diff)
elog: make elog_string() multi-thread safe
elog is supposed to be thread safe. Yet elog_string() is not. To fulfill that promise, let's make elog_string() thread safe to avoid surprises. Change-Id: Iab82faa7cb6719777a66c3ff14775e59a6a68a20 Signed-off-by: Steven Luong <sluong@cisco.com>
-rw-r--r--src/vppinfra/elog.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/vppinfra/elog.c b/src/vppinfra/elog.c
index 6daed96719c..e28217cd590 100644
--- a/src/vppinfra/elog.c
+++ b/src/vppinfra/elog.c
@@ -563,6 +563,7 @@ elog_string (elog_main_t * em, char *fmt, ...)
u32 offset;
va_list va;
+ elog_lock (em);
va_start (va, fmt);
offset = vec_len (em->string_table);
em->string_table = (char *) va_format ((u8 *) em->string_table, fmt, &va);
@@ -571,6 +572,7 @@ elog_string (elog_main_t * em, char *fmt, ...)
/* Null terminate string if it is not already. */
if (vec_end (em->string_table)[-1] != 0)
vec_add1 (em->string_table, 0);
+ elog_unlock (em);
return offset;
}