#include "ofpbuf.h"
#include "openflow/nicira-ext.h"
#include "openflow/openflow.h"
+#include "ovs-thread.h"
#include "vlog.h"
VLOG_DEFINE_THIS_MODULE(ofp_msgs);
static ovs_be32
alloc_xid(void)
{
- static uint32_t next_xid = 1;
- return htonl(next_xid++);
+ static atomic_uint32_t next_xid = ATOMIC_VAR_INIT(1);
+ uint32_t xid;
+
+ atomic_add(&next_xid, 1, &xid);
+ return htonl(xid);
}
\f
static uint32_t
static void
ofpmsgs_init(void)
{
+ static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
const struct raw_info *info;
- if (raw_instance_map.buckets) {
+ if (!ovsthread_once_start(&once)) {
return;
}
ofphdrs_hash(&inst->hdrs));
}
}
+
+ ovsthread_once_done(&once);
}