From a4fdb0f3bdbfff1924afefd19239260ed429c193 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Wed, 16 Apr 2014 13:33:26 -0700 Subject: [PATCH] netdev: Initialize netdev_class_mutex. This code path currently does not initialize netdev_class_mutex. dummy_enable ->netdev_dummy_register ->netdev_register_provider ->ovs_mutex_lock(&netdev_class_mutex) ovsdb-server on windows crashes without it. This commit adds a new initialization function. Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- lib/netdev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/netdev.c b/lib/netdev.c index 4736a97e6..45a416520 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -102,13 +102,25 @@ netdev_is_pmd(const struct netdev *netdev) } static void -netdev_initialize(void) +netdev_class_mutex_initialize(void) OVS_EXCLUDED(netdev_class_mutex, netdev_mutex) { static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; if (ovsthread_once_start(&once)) { ovs_mutex_init_recursive(&netdev_class_mutex); + ovsthread_once_done(&once); + } +} + +static void +netdev_initialize(void) + OVS_EXCLUDED(netdev_class_mutex, netdev_mutex) +{ + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + + if (ovsthread_once_start(&once)) { + netdev_class_mutex_initialize(); fatal_signal_add_hook(restore_all_flags, NULL, NULL, true); netdev_vport_patch_register(); @@ -190,6 +202,7 @@ netdev_register_provider(const struct netdev_class *new_class) { int error; + netdev_class_mutex_initialize(); ovs_mutex_lock(&netdev_class_mutex); if (netdev_lookup_class(new_class->type)) { VLOG_WARN("attempted to register duplicate netdev provider: %s", -- 2.43.0