fix prevent 482199 ~ 488631
authorMinchul Lee <slotus.lee@samsung.com>
Wed, 18 Nov 2015 04:54:47 +0000 (13:54 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Nov 2015 05:54:46 +0000 (14:54 +0900)
Change-Id: Id919337fcd53641d0b8c376d0d026282bbd5d095
Signed-off-by: Minchul Lee <slotus.lee@samsung.com>
daemon/icd-ioty-ocprocess.c
daemon/icd-ioty.c
lib/icl-lite-resource.c

index 85254e7..5caa70b 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
-#include <unistd.h> /* for usleep() */
+#include <unistd.h>
 #include <glib.h>
 
 #include <ocstack.h>
@@ -329,6 +329,7 @@ OCEntityHandlerResult icd_ioty_ocprocess_req_handler(OCEntityHandlerFlag flag,
        dev_addr = calloc(1, sizeof(OCDevAddr));
        if (NULL == dev_addr) {
                ERR("calloc() Fail(%d)", errno);
+               free(req_ctx->bus_name);
                free(req_ctx);
                return OC_EH_ERROR;
        }
@@ -355,6 +356,7 @@ OCEntityHandlerResult icd_ioty_ocprocess_req_handler(OCEntityHandlerFlag flag,
                        req_ctx->payload = NULL;
                        break;
                default:
+                       free(req_ctx->dev_addr);
                        free(req_ctx->bus_name);
                        free(req_ctx);
                        return OC_EH_ERROR;
@@ -406,6 +408,7 @@ gpointer icd_ioty_ocprocess_thread(gpointer data)
 {
        FN_CALL;
        OCStackResult result;
+       const struct timespec delay = {0, 10 * 1000 * 1000}; /* 10 ms */
 
        icd_ioty_alive = 1;
        while (icd_ioty_alive) {
@@ -417,8 +420,9 @@ gpointer icd_ioty_ocprocess_thread(gpointer data)
                        break;
                }
 
-               /* TODO : SHOULD revise time or usleep */
-               usleep(10);
+               /* TODO : Current '10ms' is not proven sleep time. Revise the time after test.
+                * Or recommend changes to event driven architecture */
+               nanosleep(&delay, NULL);
        }
 
        return NULL;
index b5f9714..b809ec1 100644 (file)
@@ -744,6 +744,7 @@ OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_policy,
        context = calloc(1, sizeof(icd_sig_ctx_s));
        if (NULL == context) {
                ERR("calloc() Fail(%d)", errno);
+               free(uri);
                return NULL;
        }
        context->bus_name = ic_utils_strdup(bus_name);
index a00e08b..ca8355c 100644 (file)
@@ -139,10 +139,11 @@ static void _icl_lite_resource_request_handler(GDBusConnection *connection,
 {
        GVariant *repr_gvar;
        int ret, request_type;
+       int64_t oic_request_h = 0;
+       int64_t oic_resource_h = 0;
        iotcon_representation_h repr;
        iotcon_state_h recv_state = NULL;
        GVariantIter *repr_iter, *state_iter;
-       int64_t oic_request_h, oic_resource_h;
        iotcon_lite_resource_h resource = user_data;
 
        ret = iotcon_representation_create(&repr);