return MA_ERROR_NONE;
}
#endif
-static int _wait_cb_ret(unsigned int msec)
+static int _wait_cb_ret(int msec)
{
OCStackResult ret = OC_STACK_OK;
- unsigned int i, times = msec /100;
+
#ifndef THREAD_COND_WAIT_USED
struct timespec request, remaining;
- request.tv_sec = 0;
- request.tv_nsec = 1000000;
+ request.tv_sec = msec / 1000;
+ request.tv_nsec = (msec % 1000) * 1000000;
#endif
ma_check_null_ret_error("g_client", g_client, OC_STACK_INVALID_PARAM);
pthread_join(proc_a.thread, (void*) &result_a);
#else
- for (i = 0; !g_client->g_doneCB && times > i; ++i) {
-
- ret = nanosleep(&request, &remaining);
- if (-1 == ret && EINTR == errno) {
- MA_LOGE( "Onanosleep error = %d", errno);
- break;
- }
+ for (int i=0; !g_client->g_doneCB && msec > i; i+=10) {
+ /*
+ * Basically, nanosleep is more thread-safe function,
+ * But, in our case, nanosleep cause crash frequently
+ */
+ usleep(10000);
g_mutex_lock(&iotivity_mutex);
ret = OCProcess();