take only the first address returned by host
[sliver-openvswitch.git] / lib / jsonrpc.c
index b4bbc84..e02f035 100644 (file)
@@ -26,6 +26,7 @@
 #include "json.h"
 #include "list.h"
 #include "ofpbuf.h"
+#include "ovs-thread.h"
 #include "poll-loop.h"
 #include "reconnect.h"
 #include "stream.h"
@@ -351,7 +352,7 @@ void
 jsonrpc_recv_wait(struct jsonrpc *rpc)
 {
     if (rpc->status || rpc->received || !byteq_is_empty(&rpc->input)) {
-        (poll_immediate_wake)(rpc->name);
+        poll_immediate_wake_at(rpc->name);
     } else {
         stream_recv_wait(rpc->stream);
     }
@@ -514,8 +515,11 @@ jsonrpc_create(enum jsonrpc_msg_type type, const char *method,
 static struct json *
 jsonrpc_create_id(void)
 {
-    static unsigned int id;
-    return json_integer_create(id++);
+    static atomic_uint next_id = ATOMIC_VAR_INIT(0);
+    unsigned int id;
+
+    atomic_add(&next_id, 1, &id);
+    return json_integer_create(id);
 }
 
 struct jsonrpc_msg *