From 584732fe8c646c9f4de2e45676e0353c5bedede7 Mon Sep 17 00:00:00 2001 From: fengzero Date: Wed, 12 Nov 2025 01:49:09 +0000 Subject: [PATCH 1/2] rm unused node cache sql --- include/neuron/define.h | 2 +- persistence/0002_2.3.0_node_cache.sql | 36 --------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 persistence/0002_2.3.0_node_cache.sql diff --git a/include/neuron/define.h b/include/neuron/define.h index 9f43d49e..3adeb790 100644 --- a/include/neuron/define.h +++ b/include/neuron/define.h @@ -23,7 +23,7 @@ #include #define NEU_VERSION_MAJOR 2 -#define NEU_VERSION_MINOR 12 +#define NEU_VERSION_MINOR 14 #define NEU_VERSION_FIX 0 #define NEU_GET_VERSION_MAJOR(V) ((0xffff0000 & V) >> 16) diff --git a/persistence/0002_2.3.0_node_cache.sql b/persistence/0002_2.3.0_node_cache.sql deleted file mode 100644 index 4fa69f44..00000000 --- a/persistence/0002_2.3.0_node_cache.sql +++ /dev/null @@ -1,36 +0,0 @@ -/** -* NEURON IIoT System for Industry 4.0 -* Copyright (C) 2020-2023 EMQ Technologies Co., Ltd All rights reserved. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - ---- fix primary key --- -BEGIN; - -DROP TABLE IF EXISTS old_node_cache; -ALTER TABLE node_cache RENAME TO old_node_cache; - -CREATE TABLE IF NOT EXISTS node_cache ( - node_name TEXT PRIMARY KEY, - CACHE TEXT NOT NULL, - FOREIGN KEY (node_name) REFERENCES nodes (name) ON UPDATE CASCADE ON DELETE CASCADE -); - -INSERT OR REPLACE INTO node_cache SELECT * FROM old_node_cache; - -DROP TABLE old_node_cache; - -COMMIT; From 82615c0908353b7044b820ec8b90fb543885e3ed Mon Sep 17 00:00:00 2001 From: fengzero Date: Wed, 26 Nov 2025 03:09:07 +0000 Subject: [PATCH 2/2] event: log category --- .github/workflows/ci.yml | 2 +- src/event/event_linux.c | 39 +++++++++++++++++----------------- tests/ft/plugin/test_plugin.py | 2 +- tests/plugins/c1/c1_2.c | 2 +- version | 2 +- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbf8c2d6..dd891c76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - published env: - VERSION: 2.12.0 + VERSION: 2.14.0 UI_VERSION: 2.6.1 BRANCH: main diff --git a/src/event/event_linux.c b/src/event/event_linux.c index b872ad81..21da7de5 100644 --- a/src/event/event_linux.c +++ b/src/event/event_linux.c @@ -72,7 +72,8 @@ struct neu_events { int epoll_fd; pthread_t thread; bool stop; - char * name; + + zlog_category_t *log; pthread_mutex_t mtx; int n_event; @@ -123,8 +124,8 @@ static void *event_loop(void *arg) } if (ret == -1 || events->stop) { - zlog_warn(neuron, "event loop(%s) exit, errno: %s(%d), stop: %d", - events->name, strerror(errno), errno, events->stop); + zlog_warn(events->log, "event loop exit, errno: %s(%d), stop: %d", + strerror(errno), errno, events->stop); break; } @@ -182,14 +183,14 @@ neu_events_t *neu_event_new(const char *name) { neu_events_t *events = calloc(1, sizeof(struct neu_events)); + events->log = zlog_get_category(name); events->epoll_fd = epoll_create(1); - nlog_notice("create epoll(%s): %d(%d)", name, events->epoll_fd, errno); + zlog_notice(events->log, "create epoll: %d(%d)", events->epoll_fd, errno); assert(events->epoll_fd > 0); events->stop = false; events->n_event = 0; - events->name = strdup(name); pthread_mutex_init(&events->mtx, NULL); pthread_create(&events->thread, NULL, event_loop, events); @@ -201,7 +202,6 @@ int neu_event_close(neu_events_t *events) { events->stop = true; close(events->epoll_fd); - free(events->name); pthread_join(events->thread, NULL); pthread_mutex_destroy(&events->mtx); @@ -223,8 +223,7 @@ neu_event_timer_t *neu_event_add_timer(neu_events_t * events, }; int index = get_free_event(events); if (index < 0) { - zlog_fatal(neuron, "no free event(%s): %d", events->name, - events->epoll_fd); + zlog_fatal(events->log, "no free event: %d", events->epoll_fd); } assert(index >= 0); @@ -253,21 +252,20 @@ neu_event_timer_t *neu_event_add_timer(neu_events_t * events, ret = epoll_ctl(events->epoll_fd, EPOLL_CTL_ADD, timer_fd, &event); - zlog_notice(neuron, + zlog_notice(events->log, "add timer, second: %" PRId64 ", millisecond: %" PRId64 - ", timer: %d in epoll(%s) %d, " + ", timer: %d in epoll %d, " "ret: %d, index: %d", - timer.second, timer.millisecond, timer_fd, events->name, - events->epoll_fd, ret, index); + timer.second, timer.millisecond, timer_fd, events->epoll_fd, + ret, index); return timer_ctx; } int neu_event_del_timer(neu_events_t *events, neu_event_timer_t *timer) { - zlog_notice(neuron, "del timer: %d from epoll(%s): %d, index: %d", - timer->fd, events->name, events->epoll_fd, - timer->event_data->index); + zlog_notice(events->log, "del timer: %d from epoll: %d, index: %d", + timer->fd, events->epoll_fd, timer->event_data->index); timer->stop = true; epoll_ctl(events->epoll_fd, EPOLL_CTL_DEL, timer->fd, NULL); @@ -286,7 +284,7 @@ neu_event_io_t *neu_event_add_io(neu_events_t *events, neu_event_io_param_t io) int ret = 0; int index = get_free_event(events); - nlog_notice("add io, fd: %d, epoll(%s): %d, index: %d", io.fd, events->name, + zlog_notice(events->log, "add io, fd: %d, epoll: %d, index: %d", io.fd, events->epoll_fd, index); assert(index >= 0); @@ -308,8 +306,9 @@ neu_event_io_t *neu_event_add_io(neu_events_t *events, neu_event_io_param_t io) ret = epoll_ctl(events->epoll_fd, EPOLL_CTL_ADD, io.fd, &event); - nlog_notice("add io, fd: %d, epoll(%s): %d, ret: %d(%d), index: %d", io.fd, - events->name, events->epoll_fd, ret, errno, index); + zlog_notice(events->log, + "add io, fd: %d, epoll: %d, ret: %d(%d), index: %d", io.fd, + events->epoll_fd, ret, errno, index); assert(ret == 0); return io_ctx; @@ -321,8 +320,8 @@ int neu_event_del_io(neu_events_t *events, neu_event_io_t *io) return 0; } - zlog_notice(neuron, "del io: %d from epoll(%s): %d, index: %d", io->fd, - events->name, events->epoll_fd, io->event_data->index); + zlog_notice(events->log, "del io: %d from epoll: %d, index: %d", io->fd, + events->epoll_fd, io->event_data->index); epoll_ctl(events->epoll_fd, EPOLL_CTL_DEL, io->fd, NULL); free_event(events, io->event_data->index); diff --git a/tests/ft/plugin/test_plugin.py b/tests/ft/plugin/test_plugin.py index e38f4fb4..78ffcb3e 100644 --- a/tests/ft/plugin/test_plugin.py +++ b/tests/ft/plugin/test_plugin.py @@ -244,7 +244,7 @@ class TestPlugin: assert 200 == response.status_code for plugin in response.json().get("plugins"): if plugin['name'] == 'c1': - assert plugin['version'] == '2.12.99' + assert plugin['version'] == '2.14.99' @description(given="incorrect configuration", when="update plugin", then="fail") def test_10_update_plugin_fail3(self): diff --git a/tests/plugins/c1/c1_2.c b/tests/plugins/c1/c1_2.c index c6ba1687..13314c12 100644 --- a/tests/plugins/c1/c1_2.c +++ b/tests/plugins/c1/c1_2.c @@ -63,7 +63,7 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = { }; const neu_plugin_module_t neu_plugin_module = { - .version = NEU_VERSION(2, 12, 99), + .version = NEU_VERSION(2, 14, 99), .schema = "c1", .module_name = "c1", .module_descr = "c1 v2", diff --git a/version b/version index 4879166f..af819700 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.12.0-alpha \ No newline at end of file +2.14.0-alpha \ No newline at end of file