X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fofp-msgs.c;h=d136f73d47cefd457a249d2c0a21d360d3178db3;hb=d6fb622dcb9cb048b564621a73cf4165edc857ea;hp=efc4198af2928132e040274ce55c4d1a64fa202f;hpb=964a5f60c0b38e59993e92425709579b3394349a;p=sliver-openvswitch.git diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index efc4198af..d136f73d4 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -23,6 +23,7 @@ #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); @@ -109,8 +110,11 @@ static enum ofperr ofpraw_from_ofphdrs(enum ofpraw *, const struct ofphdrs *); 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); } static uint32_t @@ -851,6 +855,8 @@ ofpmp_reserve(struct list *replies, size_t len) 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); @@ -986,9 +992,10 @@ ofpraw_from_ofphdrs(enum ofpraw *raw, const struct ofphdrs *hdrs) 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; } @@ -1006,4 +1013,6 @@ ofpmsgs_init(void) ofphdrs_hash(&inst->hdrs)); } } + + ovsthread_once_done(&once); }