OSDN Git Service

libcom_err: Use thread local storage to fix reentrancy problems
authorTheodore Ts'o <tytso@mit.edu>
Sun, 10 Feb 2008 04:39:27 +0000 (23:39 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 10 Feb 2008 04:49:19 +0000 (23:49 -0500)
Address the theoretical problem of two threads trying to format a
different unknown error code by using TLS.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/et/error_message.c

index 708dd2f..2507fc0 100644 (file)
 #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;