static gboolean __zblib_service_unload_plugin(ZigBeePlugin *plugin)
{
const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin);
- char *plugin_name = zblib_plugin_get_plugin_name(plugin);
+ char *plugin_name = NULL;
zblib_check_null_ret_error("descriptor", descriptor, FALSE);
zblib_check_null_ret_error("descriptor->unload", descriptor->unload, FALSE);
+ plugin_name = zblib_plugin_get_plugin_name(plugin);
+
descriptor->unload(plugin);
Z_LOGI("plugin(%s) unloaded!", plugin_name);
+ g_free(plugin_name);
+
return TRUE;
}
+static void __zblib_service_remove_request_table_iter(gpointer key,
+ gpointer value, gpointer user_data)
+{
+ ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
+ gint request_id = (gint)key;
+
+ NOT_USED(value);
+
+ zblib_check_null_ret("service_interface", service_interface);
+
+ Z_LOGD("Removing request id [%d]", request_id);
+ zblib_request_free(service_interface, request_id);
+}
+
ZigBeeService *zblib_service_new()
{
ZigBeeService *service;
{
zblib_check_null_ret("service", service);
+ if (service->request_table) {
+ GSList *interface_objs = NULL;
+ ZigBeeServiceInterface *service_interface = NULL;
+
+ interface_objs = service->interface_objs;
+ if (NULL == interface_objs) {
+ Z_LOGE("interface_objs is NULL");
+ } else {
+ while (interface_objs) {
+ service_interface = (ZigBeeServiceInterface *)interface_objs->data;
+
+ /* Remove left request */
+ g_hash_table_foreach(service->request_table,
+ __zblib_service_remove_request_table_iter,
+ service_interface);
+
+ /* Move to next service interface */
+ interface_objs = g_slist_next(interface_objs);
+ }
+ g_hash_table_remove_all(service->request_table);
+ g_hash_table_destroy(service->request_table);
+ service->request_table = NULL;
+ }
+ }
+
/* Free plug-ins */
if (service->plugins) {
g_slist_free(service->plugins);
/* Specific vendor plug-in would be removed */
service->plugins = g_slist_remove(service->plugins, plugin);
+ /* Deinitialize plugin */
+ zblib_plugin_free(plugin);
+
return TRUE;
}
service_interface = tmp_service_interface;
break;
}
+ g_free(object_name);
list = g_slist_next(list);
}