2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

ofp-msgs: Make alloc_xid() thread-safe.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
This commit is contained in:
Ben Pfaff
2013-04-26 13:07:33 -07:00
parent 01cdb3a111
commit d0c79f7fe0

View File

@@ -111,7 +111,14 @@ static ovs_be32
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);
}
static uint32_t