mirror of
https://github.com/emqx/neuron.git
synced 2026-10-29 15:09:11 +08:00
Merge pull request #598 from fengzeroz/main
fix(driver): update all tag error if tag == NULL
This commit is contained in:
@@ -54,8 +54,6 @@ struct neu_driver_cache {
|
||||
|
||||
static void update_tag_error(neu_driver_cache_t *cache, const char *group,
|
||||
const char *tag, int64_t timestamp, int error);
|
||||
static void update_group_error(neu_driver_cache_t *cache, const char *group,
|
||||
int64_t timestamp, int error);
|
||||
|
||||
inline static tkey_t to_key(const char *group, const char *tag)
|
||||
{
|
||||
@@ -100,11 +98,7 @@ void neu_driver_cache_destroy(neu_driver_cache_t *cache)
|
||||
void neu_driver_cache_error(neu_driver_cache_t *cache, const char *group,
|
||||
const char *tag, int64_t timestamp, int32_t error)
|
||||
{
|
||||
if (tag == NULL) {
|
||||
update_group_error(cache, group, timestamp, error);
|
||||
} else {
|
||||
update_tag_error(cache, group, tag, timestamp, error);
|
||||
}
|
||||
update_tag_error(cache, group, tag, timestamp, error);
|
||||
}
|
||||
|
||||
void neu_driver_cache_update(neu_driver_cache_t *cache, const char *group,
|
||||
@@ -217,20 +211,3 @@ static void update_tag_error(neu_driver_cache_t *cache, const char *group,
|
||||
|
||||
nng_mtx_unlock(cache->mtx);
|
||||
}
|
||||
|
||||
static void update_group_error(neu_driver_cache_t *cache, const char *group,
|
||||
int64_t timestamp, int error)
|
||||
{
|
||||
struct elem *elem = NULL, *tmp = NULL;
|
||||
|
||||
nng_mtx_lock(cache->mtx);
|
||||
HASH_ITER(hh, cache->table, elem, tmp)
|
||||
{
|
||||
if (strcmp(elem->key.group, group) == 0) {
|
||||
elem->timestamp = timestamp;
|
||||
elem->error = error;
|
||||
}
|
||||
}
|
||||
|
||||
nng_mtx_unlock(cache->mtx);
|
||||
}
|
||||
@@ -120,8 +120,23 @@ static void update(neu_adapter_t *adapter, const char *group, const char *tag,
|
||||
}
|
||||
|
||||
if (value.type == NEU_TYPE_ERROR) {
|
||||
neu_driver_cache_error(driver->cache, group, tag,
|
||||
driver->adapter.timestamp, value.value.i32);
|
||||
if (tag != NULL) {
|
||||
neu_driver_cache_error(driver->cache, group, tag,
|
||||
driver->adapter.timestamp, value.value.i32);
|
||||
} else {
|
||||
group_t *g = find_group(driver, group);
|
||||
if (g != NULL) {
|
||||
UT_array *tags = neu_group_get_read_tag(g->group);
|
||||
|
||||
utarray_foreach(tags, neu_datatag_t *, t)
|
||||
{
|
||||
neu_driver_cache_error(driver->cache, group, t->name,
|
||||
driver->adapter.timestamp,
|
||||
value.value.i32);
|
||||
}
|
||||
utarray_free(tags);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
neu_driver_cache_update(driver->cache, group, tag,
|
||||
driver->adapter.timestamp, n_byte,
|
||||
|
||||
Reference in New Issue
Block a user