If 'lacp' is NULL, then lacp_create() might not have been called to indirectly initialize the mutex via lacp_init(), so call lacp_init() from lacp_status().
Signed-off-by: Ben Pfaff <b...@nicira.com> Acked-by: Andy Zhou <az...@nicira.com> --- lib/lacp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index 4aee64f..dfb7159 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -199,21 +199,23 @@ parse_lacp_packet(const struct ofpbuf *b) void lacp_init(void) { - unixctl_command_register("lacp/show", "[port]", 0, 1, - lacp_unixctl_show, NULL); + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + + if (ovsthread_once_start(&once)) { + ovs_mutex_init_recursive(&mutex); + unixctl_command_register("lacp/show", "[port]", 0, 1, + lacp_unixctl_show, NULL); + ovsthread_once_done(&once); + } } /* Creates a LACP object. */ struct lacp * lacp_create(void) OVS_EXCLUDED(mutex) { - static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; struct lacp *lacp; - if (ovsthread_once_start(&once)) { - ovs_mutex_init_recursive(&mutex); - ovsthread_once_done(&once); - } + lacp_init(); lacp = xzalloc(sizeof *lacp); hmap_init(&lacp->slaves); @@ -347,6 +349,8 @@ lacp_status(const struct lacp *lacp) OVS_EXCLUDED(mutex) { enum lacp_status ret; + lacp_init(); + ovs_mutex_lock(&mutex); if (!lacp) { ret = LACP_DISABLED; -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev