diff --git a/plugins/modbus/modbus_tcp.c b/plugins/modbus/modbus_tcp.c index 30d4a2da6..0e767c904 100644 --- a/plugins/modbus/modbus_tcp.c +++ b/plugins/modbus/modbus_tcp.c @@ -104,6 +104,10 @@ static void start_periodic_read(neu_plugin_t * plugin, neu_datatag_id_t *id = (neu_datatag_id_t *) iterator_get(&iter); neu_datatag_t * tag = neu_datatag_tbl_get(plugin->tag_table, *id); + if (tag == NULL) { + // The tag had been deleted by other node + continue; + } if ((tag->attribute & NEU_ATTRIBUTE_READ) == NEU_ATTRIBUTE_READ) { switch (tag->type) { case NEU_DTYPE_UINT16: @@ -199,6 +203,11 @@ setup_read_resp_data_value(neu_datatag_table_t * tag_table, int result = 0; neu_int_val_t int_val = { 0 }; + if (tag == NULL) { + // The tag had been deleted by other node + continue; + } + if ((tag->attribute & NEU_ATTRIBUTE_READ) == NEU_ATTRIBUTE_READ) { switch (tag->type) { case NEU_DTYPE_UINT32: @@ -343,6 +352,16 @@ static neu_data_val_t *setup_write_resp_data_value(neu_data_val_t *write_val, neu_datatag_t * tag = neu_datatag_tbl_get(plugin->tag_table, int_val->key); + if (tag == NULL) { + // The tag had been deleted by other node + error = NEU_ERR_TAG_NOT_EXIST; + neu_dvalue_set_errorcode(val_error, error); + + neu_int_val_init(&iv, int_val->key, val_error); + neu_fixed_array_set(array_resp, i, (void *) &iv); + continue; + } + switch (val_type) { case NEU_DTYPE_INT64: { int64_t i64 = 0; diff --git a/src/base/neu_plugin_common.c b/src/base/neu_plugin_common.c index 80a9e8805..965946178 100644 --- a/src/base/neu_plugin_common.c +++ b/src/base/neu_plugin_common.c @@ -453,6 +453,10 @@ int neu_plugin_tag_count_by_attribute(neu_taggrp_config_t *grp_config, { neu_datatag_id_t *id = (neu_datatag_id_t *) iterator_get(&iter_id); neu_datatag_t * tag = neu_datatag_tbl_get(tag_table, *id); + if (tag == NULL) { + // The tag had been deleted by other node + continue; + } if ((tag->attribute & attribute) == attribute) { count += 1; }