Hi Hans,
In version 2 of the patch, I have removed the thread-local declaration
of svc_to_mds_info as your suggestion and use it as local variable for
each MDS service request to avoid Data race issues.
Please help review it again.
Thank you.
--
Best regards,
Hoa Le
On 03/27/2018 01:41 PM, Hans Nordebäck wrote:
Hi Hoa,
Do we need the svc_to_mds_info to be tls? I used it in the sample added to
ticket
to reduce number of helgrind warnings when I verified safe_printf and
safe_fflush.
It should have been removed in the sample, as it was not fully verified.
/Thanks HansN
-----Original Message-----
From: Hoa Le [mailto:[email protected]]
Sent: den 27 mars 2018 03:47
To: Anders Widell <[email protected]>; Hans Nordebäck
<[email protected]>
Cc: [email protected]; Hoa Le <[email protected]>
Subject: [PATCH 1/1] mds: improve thread safety in mdstest - part 2 [#2746]
- Use __thread if _Thread_local is not supported in GCC version lower than 4.9
---
src/mds/apitest/mdstipc.h | 6 ++++++
src/mds/apitest/mdstipc_api.c | 2 +-
src/mds/apitest/mdstipc_conf.c | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/mds/apitest/mdstipc.h b/src/mds/apitest/mdstipc.h index
01b58c4..f67890a 100644
--- a/src/mds/apitest/mdstipc.h
+++ b/src/mds/apitest/mdstipc.h
@@ -21,6 +21,12 @@
#include "base/ncssysf_tsk.h"
#include "base/ncssysf_def.h"
+#if !defined(_Thread_local)
+#define MDS_THREAD_LOCAL __thread
+#else
+#define MDS_THREAD_LOCAL _Thread_local
+#endif
+
typedef struct tet_task {
NCS_OS_CB entry;
void *arg;
diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
index 669c770..2ff8238 100644
--- a/src/mds/apitest/mdstipc_api.c
+++ b/src/mds/apitest/mdstipc_api.c
@@ -33,7 +33,7 @@ static MDS_CLIENT_MSG_FORMAT_VER gl_set_msg_fmt_ver;
MDS_SVC_ID svc_ids[3] = {2006, 2007, 2008};
-_Thread_local NCSMDS_INFO svc_to_mds_info;
+MDS_THREAD_LOCAL NCSMDS_INFO svc_to_mds_info;
pthread_mutex_t safe_printf_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t gl_mutex = PTHREAD_MUTEX_INITIALIZER;
diff --git a/src/mds/apitest/mdstipc_conf.c b/src/mds/apitest/mdstipc_conf.c index c2d7d01..d6ee48e 100644
--- a/src/mds/apitest/mdstipc_conf.c
+++ b/src/mds/apitest/mdstipc_conf.c
@@ -25,7 +25,7 @@ extern int fill_syncparameters(int); extern uint32_t
mds_vdest_tbl_get_role(MDS_VDEST_ID vdest_id, V_DEST_RL *role); extern
pthread_mutex_t gl_mds_library_mutex;
-extern _Thread_local NCSMDS_INFO svc_to_mds_info;
+extern MDS_THREAD_LOCAL NCSMDS_INFO svc_to_mds_info;
extern pthread_mutex_t safe_printf_mutex; extern pthread_mutex_t gl_mutex;
--
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel