gpointer value, gpointer user_data)
{
ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
- gint request_id = (gint)key;
+ gint request_id = GPOINTER_TO_INT(key);
NOT_USED(value);
zblib_request_free(service_interface, request_id);
}
+static void __zblib_service_remove_async_list(GSList *list_async)
+{
+ GSList *iter = NULL;
+ if (0 < g_slist_length(list_async)) {
+ iter = g_slist_nth(list_async, 0);
+ while (iter) {
+ if (iter) {
+ struct _zblib_async_init_info *async_plugin =
+ (struct _zblib_async_init_info *)(list_async->data);
+ list_async = g_slist_remove(list_async, async_plugin);
+ }
+ iter = g_slist_nth(list_async, 0);
+ }
+ }
+}
+
ZigBeeService *zblib_service_new()
{
ZigBeeService *service;
/* Create new plug-in */
plugin = zblib_plugin_new(service, filename, descriptor, handle);
if (G_UNLIKELY(NULL == plugin)) {
+ dlclose(handle);
g_free(filename);
continue;
}
/* If there is no initializer, it should have asynchronous one */
const ZblibPluginDescriptor_t *descriptor =
zblib_plugin_get_descriptor(plugin);
- if (NULL != descriptor->init_async) {
+ if (NULL != descriptor && NULL != descriptor->init_async) {
/* Register async initializer */
struct _zblib_async_init_info *info =
g_try_new0(struct _zblib_async_init_info, 1);
list_async = g_slist_append(list_async, info);
} else {
+ __zblib_service_remove_async_list(list_async);
Z_LOGE("Fatal : Failed to initialize plugin");
return FALSE;
}
gboolean zblib_service_unload_plugins(ZigBeeService *service)
{
- GSList *list;
+ GSList *list = NULL;
+ GSList *list_async = NULL;
zblib_check_null_ret_error("service", service, FALSE);
+ /* Unload everyy async_plugin */
+ list_async = __zblib_service_ref_async_initializer(service);
+ __zblib_service_remove_async_list(list_async);
+
list = zblib_service_ref_plugins(service);
while (list != NULL) {
ZigBeePlugin *plugin = list->data;