From 47526e3568f93a13caa347408496f1f1d48af74c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 9 Feb 2008 23:39:27 -0500 Subject: [PATCH] libcom_err: Use thread local storage to fix reentrancy problems Address the theoretical problem of two threads trying to format a different unknown error code by using TLS. Signed-off-by: "Theodore Ts'o" --- lib/et/error_message.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/et/error_message.c b/lib/et/error_message.c index 708dd2f..2507fc0 100644 --- a/lib/et/error_message.c +++ b/lib/et/error_message.c @@ -38,7 +38,13 @@ #include "error_table.h" #include "internal.h" -static char buffer[25]; +#ifdef TLS +#define THREAD_LOCAL static TLS +#else +#define THREAD_LOCAL static +#endif + +THREAD_LOCAL char buffer[25]; struct et_list * _et_list = (struct et_list *) NULL; struct et_list * _et_dynamic_list = (struct et_list *) NULL; -- 1.8.3.1