git://git.onelab.eu
/
sliver-openvswitch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
01cdb3a
)
ofp-msgs: Make alloc_xid() thread-safe.
author
Ben Pfaff
<blp@nicira.com>
Fri, 26 Apr 2013 20:07:33 +0000
(13:07 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Tue, 23 Jul 2013 18:38:14 +0000
(11:38 -0700)
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
lib/ofp-msgs.c
patch
|
blob
|
history
diff --git
a/lib/ofp-msgs.c
b/lib/ofp-msgs.c
index
5e043d2
..
8bb1754
100644
(file)
--- a/
lib/ofp-msgs.c
+++ b/
lib/ofp-msgs.c
@@
-111,7
+111,14
@@
static ovs_be32
alloc_xid(void)
{
static uint32_t next_xid = 1;
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
}
\f
static uint32_t