diff options
author | Ethan Jackson <ethan@nicira.com> | 2013-07-30 15:31:48 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-07-30 21:30:45 -0700 |
commit | 97be153858b4cd175cbe7862b8e1624bf22ab98a (patch) | |
tree | ab1e518bef4e8bbc97fe8a069d9b91541bb9c4d4 /lib/jsonrpc.c | |
parent | 2b51596fdeba7fbf4caff323dd6af375e7f84596 (diff) |
clang: Add annotations for thread safety check.
This commit adds annotations for thread safety check. And the
check can be conducted by using -Wthread-safety flag in clang.
Co-authored-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/jsonrpc.c')
-rw-r--r-- | lib/jsonrpc.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index a7d89f70..e02f0357 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -515,14 +515,10 @@ jsonrpc_create(enum jsonrpc_msg_type type, const char *method, static struct json * jsonrpc_create_id(void) { - static pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER; - static unsigned int next_id; + static atomic_uint next_id = ATOMIC_VAR_INIT(0); unsigned int id; - xpthread_mutex_lock(&mutex); - id = next_id++; - xpthread_mutex_unlock(&mutex); - + atomic_add(&next_id, 1, &id); return json_integer_create(id); } |