From: saerome.kim Date: Tue, 9 Jan 2018 10:56:18 +0000 (+0900) Subject: Fix problem that undeleted MO at the sub-device X-Git-Tag: submit/tizen/20190131.065036~269 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bf3cfa9f96ad60e48132c6885dd2cea7e5975af;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git Fix problem that undeleted MO at the sub-device - This issue due to the IoTivitiy policy. In IoTivity source (IsRequestFromResourceOwner() at policyengine.c) return false if requester's DELETE method is not match rowner's uuid Signed-off-by: saerome.kim --- diff --git a/src/d2d-subowner/d2ds-subowner.c b/src/d2d-subowner/d2ds-subowner.c index 2178d05..082c73c 100644 --- a/src/d2d-subowner/d2ds-subowner.c +++ b/src/d2d-subowner/d2ds-subowner.c @@ -60,9 +60,9 @@ /*This value is used only for sample (not OCF spec) */ #define ACL_RESRC_ARRAY_SIZE 3 -#define DISCOVERY_TIMEOUT 3 /* 3 sec */ -#define CALLBACK_TIMEOUT_S 10 /* 10 sec */ -#define CALLBACK_TIMEOUT_MS 10 * 50 /* 5sec = 100ms * 50 */ +#define DISCOVERY_TIMEOUT 3 /**< 3 sec */ +#define CALLBACK_TIMEOUT_S 10 * 1000 /**< 10 sec = 100ms * 1000 */ +#define CALLBACK_TIMEOUT_MS 10 * 500 /**< 5sec = 100ms * 500 */ /* '_' for separaing from the same constant variable in srmresourcestrings.c */ static const char* SVR_DB_FILE_NAME = "oic_svr_db_d2ds.dat"; @@ -376,10 +376,13 @@ static FILE* _fopen_prvn_mng(const char* path, const char* mode) return fopen(data_dir, mode); } -static int _wait_cb_ret(int milli_seconds) +static int _wait_cb_ret(int msec) { OCStackResult ret = OC_STACK_OK; - for (int i=0; !g_client->g_doneCB && milli_seconds > i; ++i) { + + d2ds_check_null_ret("g_client", g_client); + + for (int i=0; !g_client->g_doneCB && msec > i; ++i) { usleep(1000); ret = OCProcess(); if (OC_STACK_OK != ret) { @@ -396,6 +399,8 @@ static int _wait_cb_ret(int milli_seconds) static void _input_pin_cb(char* pin, size_t len) { + d2ds_check_null_ret("g_client", g_client); + if (!pin || OXM_RANDOM_PIN_MAX_SIZE>=len) { D2DS_LOGE( "inputPinCB invalid parameters"); return; @@ -409,6 +414,8 @@ static void _remove_mot_client() { GMutex motdev_mutex; + d2ds_check_null_ret("g_client", g_client); + g_mutex_init(&motdev_mutex); g_mutex_lock(&motdev_mutex); if (g_client->g_motdev_list) { @@ -422,6 +429,8 @@ static void _remove_owned_client() { GMutex owned_dev_mutex; + d2ds_check_null_ret("g_client", g_client); + /* delete un/owned device lists before updating them */ g_mutex_init(&owned_dev_mutex); g_mutex_lock(&owned_dev_mutex); @@ -708,6 +717,7 @@ static void __notify_found_devs(void *data) static gpointer _disc_mot_env_devs_func(gpointer data) { d2ds_req_cb_s *con = (d2ds_req_cb_s *)data; + d2ds_check_null_ret("con", con); /* delete un/owned device lists before updating them */ _remove_mot_client(); @@ -860,7 +870,7 @@ static gpointer _mot_func(gpointer data) goto MOT_ENDED; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_MS); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); if(ret) { D2DS_LOGE( "OCDoMultipleOwnershipTransfer callback error = %d (%s)", ret, _error_to_string(ret)); goto MOT_ENDED; @@ -947,7 +957,7 @@ static gpointer _remove_mo_func(gpointer data) } uuid_target = _convert_uuid(con->uuid_target_str); - src_dev = _get_dev_by_uuid(g_client->g_motdev_list, uuid_target); + src_dev = _get_dev_by_uuid(g_client->g_mowned_list, uuid_target); if (!src_dev) { D2DS_LOGE("We can't find in MOT dev list"); goto MOT_ENDED; @@ -967,7 +977,7 @@ static gpointer _remove_mo_func(gpointer data) goto MOT_ENDED; } - ret = _wait_cb_ret(CALLBACK_TIMEOUT_MS); + ret = _wait_cb_ret(CALLBACK_TIMEOUT_S); if(ret) { D2DS_LOGE( "OCRemoveSubOwner callback error = %d (%s)", ret, _error_to_string(ret)); goto MOT_ENDED;