mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
@@ -8,7 +8,7 @@ on:
|
||||
- published
|
||||
|
||||
env:
|
||||
VERSION: 2.12.0
|
||||
VERSION: 2.14.0
|
||||
UI_VERSION: 2.6.1
|
||||
BRANCH: main
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#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)
|
||||
|
||||
@@ -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;
|
||||
+19
-20
@@ -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);
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user