#include "ic-resource-interfaces.h"
static int icl_ioty_alive = 1;
+extern GHashTable *resource_hash_table;
void icl_ioty_ocprocess_stop()
{
resource = req_container->resource;
request = req_container->request;
+ gchar *key = NULL;
+ key = g_strdup_printf("%p", resource);
+ if (NULL == g_hash_table_lookup(resource_hash_table, key)) {
+ DBG("Request callback will be not called because there is no resource[%p] in resource_hash_table.", resource);
+ goto OUT;
+ }
+
DBG("resource:[%p], resource->cb:[%p] on [%s]", resource, resource->cb, resource->uri_path);
resource->cb(resource, request, resource->user_data);
DBG("callback done");
+OUT:
+ g_free(key);
icl_destroy_request_container(req_container);
return G_SOURCE_REMOVE;
static OCPersistentStorage icl_ioty_ps;
static GList *icl_generated_pin_cb_list;
+GHashTable *resource_hash_table;
void icl_ioty_deinit(pthread_t thread)
{
FN_CALL;
*resource_handle = resource;
DBG("resource:[%p]", resource);
+ if (NULL == resource_hash_table) {
+ DBG("resource_hash_table will be created");
+ resource_hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ }
+ g_hash_table_add(resource_hash_table, g_strdup_printf("%p", resource));
+
return IOTCON_ERROR_NONE;
}
}
OUT:
+ DBG("resource:[%p]", resource);
+ if (NULL != resource_hash_table) {
+ gchar *key = NULL;
+ key = g_strdup_printf("%p", resource);
+ g_hash_table_remove(resource_hash_table, key);
+ g_free(key);
+
+ if (0 == g_hash_table_size(resource_hash_table)) {
+ DBG("resource_hash_table will be destoryed");
+ g_hash_table_destroy(resource_hash_table);
+ resource_hash_table = NULL;
+ }
+ }
+
free(resource->uri_path);
free(resource);
return ret;