From 7e6356e18ff21fdb0cecfd34a2da9d9752c75872 Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Tue, 15 Mar 2022 15:03:18 +0800 Subject: [PATCH] Make function neu_adapter_create more graceful Return NULL instead of panicking when plugin open fails --- src/adapter/adapter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/adapter/adapter.c b/src/adapter/adapter.c index fdfc4788..410b451f 100644 --- a/src/adapter/adapter.c +++ b/src/adapter/adapter.c @@ -1775,7 +1775,13 @@ neu_adapter_t *neu_adapter_create(neu_adapter_info_t *info, adapter->plugin_module = plugin_module; plugin = plugin_module->intf_funs->open(adapter, &callback_funs); if (plugin == NULL) { - neu_panic("Can't to open plugin(%s)", plugin_module->module_name); + log_error("Can't to open plugin(%s)", plugin_module->module_name); + free(adapter->name); + nng_mtx_free(adapter->mtx); + nng_mtx_free(adapter->sub_grp_mtx); + vector_uninit(&adapter->sub_grp_configs); + free(adapter); + return NULL; } if (!neu_plugin_common_check(plugin)) {