#define DISCOVERY_TIMEOUT 6 /**< 6 sec */
#define CALLBACK_TIMEOUT_5S 5 * 1000 /**< 5sec = 5 * 1000 * 1ms */
-#define TIME_UNIT 100 /**< Sleep time unit */
+#define CALLBACK_MARGIN 10 * 1000 /**< 10sec */
+#define TIME_UNIT 10 /**< Sleep time unit */
/* '_' for separaing from the same constant variable in srmresourcestrings.c */
static const char* SVR_DB_FILE_NAME = "oic_svr_db_ma.dat";
TIMES += 1;
while (!g_client->g_doneCB && proc->data <= TIMES) {
- /* Increase 100 msec */
+ /* Increase wait time per unit time (= 10 msec) */
time_to_wait.tv_sec = time(NULL);
time_to_wait.tv_nsec = TIME_UNIT * 1000000;
return MA_ERROR_NONE;
}
-#endif
+#endif /* THREAD_COND_WAIT_USED */
static FILE* _fopen_prvn_mng(const char* path, const char* mode)
{
strcpy(proc.name, "A\0");
proc.data = 0;
- proc.waits = msec + CALLBACK_TIMEOUT_5S;
+ proc.waits = msec + CALLBACK_MARGIN;
if (0 != _init_proc(&proc, _exec_and_wait)) {
MA_LOGE("Fail to init proc [%s]", proc.name);
}
pthread_join(proc.thread, &result);
#else
- for (int i = 0; !g_client->g_doneCB && (msec + CALLBACK_TIMEOUT_5S) >= i; i += 10) {
- /*
- * Basically, nanosleep is more thread-safe function,
- * But, in our case, nanosleep cause crash frequently
- */
+ for (int i = 0; !g_client->g_doneCB && (msec + CALLBACK_MARGIN) >= i; i += TIME_UNIT) {
+
result = nanosleep(&tim, &tim2);
if (0 > result)
MA_LOGE("nanosleep failed=%d", errno);