From 4883eae0c8fab812a011c64f4c302597e852d76c Mon Sep 17 00:00:00 2001 From: fengzero Date: Wed, 15 Jun 2022 01:53:53 +0000 Subject: [PATCH 1/2] fix persist plugin info --- src/adapter/adapter.c | 4 +++- src/core/pluginx_manager.h | 2 +- src/persist/persist.c | 4 ++-- src/persist/persist.h | 1 - src/utils/neu_jwt.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/adapter/adapter.c b/src/adapter/adapter.c index afa84756..1fea4139 100644 --- a/src/adapter/adapter.c +++ b/src/adapter/adapter.c @@ -79,7 +79,9 @@ static int persister_singleton_load_plugins(neu_adapter_t *adapter) nlog_info("%s load plugin %s, lib:%s", adapter->name, ok_or_err, *name); } - neu_persist_plugin_infos_free(plugin_infos); + utarray_foreach(plugin_infos, char **, name) { free(*name); } + utarray_free(plugin_infos); + return rv; } diff --git a/src/core/pluginx_manager.h b/src/core/pluginx_manager.h index d1ebc422..4ded9754 100644 --- a/src/core/pluginx_manager.h +++ b/src/core/pluginx_manager.h @@ -44,7 +44,7 @@ int neu_plugin_manager_add(neu_plugin_manager_t *mgr, const char * plugin_lib_name); int neu_plugin_manager_del(neu_plugin_manager_t *mgr, const char *plugin_name); -// neu_plugin_lib_info_t array +// neu_resp_plugin_info_t array UT_array *neu_plugin_manager_get(neu_plugin_manager_t *mgr); int neu_plugin_manager_find(neu_plugin_manager_t *mgr, const char *plugin_name, neu_resp_plugin_info_t *info); diff --git a/src/persist/persist.c b/src/persist/persist.c index 0b069401..0d1dc37d 100644 --- a/src/persist/persist.c +++ b/src/persist/persist.c @@ -798,9 +798,9 @@ int neu_persister_store_plugins(neu_persister_t *persister, plugin_resp.plugins = calloc(utarray_len(plugin_infos), sizeof(char *)); - utarray_foreach(plugin_infos, char **, name) + utarray_foreach(plugin_infos, neu_resp_plugin_info_t *, plugin) { - plugin_resp.plugins[index] = *name; + plugin_resp.plugins[index] = plugin->library; index++; } diff --git a/src/persist/persist.h b/src/persist/persist.h index f4c2244a..2e64c208 100644 --- a/src/persist/persist.h +++ b/src/persist/persist.h @@ -58,7 +58,6 @@ static inline void neu_persist_adapter_infos_free(UT_array *adapter_infos) static inline void neu_persist_plugin_infos_free(UT_array *plugin_infos) { - utarray_foreach(plugin_infos, neu_persist_plugin_info_t **, p) { free(*p); } utarray_free(plugin_infos); } diff --git a/src/utils/neu_jwt.c b/src/utils/neu_jwt.c index cd5aa759..431c9400 100644 --- a/src/utils/neu_jwt.c +++ b/src/utils/neu_jwt.c @@ -153,7 +153,7 @@ int neu_jwt_new(char **token) goto err_out; } - ret = jwt_add_grant_int(jwt, "exp", tv.tv_sec + 60 * 60 * 24 * 365); + ret = jwt_add_grant_int(jwt, "exp", tv.tv_sec + 60 * 60); if (ret != 0) { goto err_out; } From 85dd49a7abfbcf60f9110469abac3fabce545244 Mon Sep 17 00:00:00 2001 From: fengzero Date: Wed, 15 Jun 2022 02:15:43 +0000 Subject: [PATCH 2/2] fix /api/v2/group cros --- plugins/restful/handle.c | 2 +- src/adapter/adapter.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/restful/handle.c b/plugins/restful/handle.c index 363e09e8..c292323a 100644 --- a/plugins/restful/handle.c +++ b/plugins/restful/handle.c @@ -65,7 +65,7 @@ struct neu_rest_handler cors_handler[] = { .url = "/api/v2/tags", }, { - .url = "/api/v2/gconfig", + .url = "/api/v2/group", }, { .url = "/api/v2/node", diff --git a/src/adapter/adapter.c b/src/adapter/adapter.c index 1fea4139..576a0285 100644 --- a/src/adapter/adapter.c +++ b/src/adapter/adapter.c @@ -460,7 +460,7 @@ static int adapter_command(neu_adapter_t *adapter, neu_reqresp_head_t header, msg = neu_msg_gen(&header, data); - ret = nng_sendmsg(adapter->nng.sock, msg, NNG_FLAG_NONBLOCK); + ret = nng_sendmsg(adapter->nng.sock, msg, 0); if (ret != 0) { nng_msg_free(msg); } @@ -686,6 +686,7 @@ int neu_adapter_init(neu_adapter_t *adapter) assert(rv == 0); + nng_socket_set_ms(adapter->nng.sock, NNG_OPT_SENDTIMEO, 100); nng_socket_get_int(adapter->nng.sock, NNG_OPT_RECVFD, &adapter->recv_fd); param.fd = adapter->recv_fd;