#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);
alloc_xid(void)
{
static uint32_t next_xid = 1;
- return htonl(next_xid++);
+ static pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER;
+ uint32_t xid;
+
+ xpthread_mutex_lock(&mutex);
+ xid = next_xid++;
+ xpthread_mutex_unlock(&mutex);
+
+ return htonl(xid);
}
\f
static uint32_t
next = ofpbuf_new(MAX(1024, hdrs_len + len));
ofpbuf_put(next, msg->data, hdrs_len);
+ next->l2 = next->data;
+ next->l3 = ofpbuf_tail(next);
list_push_back(replies, &next->list_node);
*ofpmp_flags__(msg->data) |= htons(OFPSF_REPLY_MORE);
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);
}