diff --git a/plugins/mqtt/mqtt_handle.c b/plugins/mqtt/mqtt_handle.c index b1138f6f..8131e53e 100644 --- a/plugins/mqtt/mqtt_handle.c +++ b/plugins/mqtt/mqtt_handle.c @@ -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; +} diff --git a/plugins/mqtt/mqtt_handle.h b/plugins/mqtt/mqtt_handle.h index 55823578..b689a49c 100644 --- a/plugins/mqtt/mqtt_handle.h +++ b/plugins/mqtt/mqtt_handle.h @@ -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 } diff --git a/plugins/mqtt/mqtt_plugin.c b/plugins/mqtt/mqtt_plugin.c index 08a7da6e..7c083123 100644 --- a/plugins/mqtt/mqtt_plugin.c +++ b/plugins/mqtt/mqtt_plugin.c @@ -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; diff --git a/plugins/mqtt/mqtt_plugin.h b/plugins/mqtt/mqtt_plugin.h index c8db3c93..d0b74ff1 100644 --- a/plugins/mqtt/mqtt_plugin.h +++ b/plugins/mqtt/mqtt_plugin.h @@ -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) {