clang: Add annotations for thread safety check.
[sliver-openvswitch.git] / lib / jsonrpc.c
index a7d89f7..e02f035 100644 (file)
@@ -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);
 }