Signed-off-by: Ben Pfaff <[email protected]>
---
lib/netdev-dummy.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index a940df8..82473a1 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -241,8 +241,15 @@ static int
netdev_dummy_create(const struct netdev_class *class, const char *name,
struct netdev **netdevp)
{
- static unsigned int n = 0xaa550000;
+ static unsigned int next_n = 0xaa550000;
+ static pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER;
+
struct netdev_dummy *netdev;
+ unsigned int n;
+
+ xpthread_mutex_lock(&mutex);
+ n = next_n++;
+ xpthread_mutex_unlock(&mutex);
netdev = xzalloc(sizeof *netdev);
netdev_init(&netdev->up, name, class);
@@ -265,8 +272,6 @@ netdev_dummy_create(const struct netdev_class *class, const
char *name,
shash_add(&dummy_netdevs, name, netdev);
- n++;
-
*netdevp = &netdev->up;
return 0;
--
1.7.2.5
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev