fix(mqtt): handle driver delete

This commit is contained in:
eeff
2023-08-31 14:37:23 +08:00
parent 3dca78e780
commit efc7ece5d8
4 changed files with 21 additions and 0 deletions
+7
View File
@@ -707,3 +707,10 @@ int handle_update_driver(neu_plugin_t *plugin, neu_req_update_node_t *req)
req->new_name);
return 0;
}
int handle_del_driver(neu_plugin_t *plugin, neu_reqresp_node_deleted_t *req)
{
route_tbl_del_driver(&plugin->route_tbl, req->node);
plog_notice(plugin, "delete route driver:%s", req->node);
return 0;
}
+1
View File
@@ -49,6 +49,7 @@ int handle_unsubscribe_group(neu_plugin_t * plugin,
neu_req_unsubscribe_t *unsub_info);
int handle_update_driver(neu_plugin_t *plugin, neu_req_update_node_t *req);
int handle_del_driver(neu_plugin_t *plugin, neu_reqresp_node_deleted_t *req);
#ifdef __cplusplus
}
+1
View File
@@ -377,6 +377,7 @@ static int mqtt_plugin_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
error = handle_update_driver(plugin, data);
break;
case NEU_REQRESP_NODE_DELETED:
error = handle_del_driver(plugin, data);
break;
case NEU_REQ_UPDATE_LICENSE:
break;
+12
View File
@@ -140,6 +140,18 @@ static inline void route_tbl_update_driver(route_entry_t **tbl,
}
}
static inline void route_tbl_del_driver(route_entry_t **tbl, const char *driver)
{
route_entry_t *e = NULL, *tmp = NULL;
HASH_ITER(hh, *tbl, e, tmp)
{
if (0 == strcmp(e->key.driver, driver)) {
HASH_DEL(*tbl, e);
route_entry_free(e);
}
}
}
static inline void route_tbl_del(route_entry_t **tbl, const char *driver,
const char *group)
{