[Bugfix][T106BUG-525]Fix datacall timeout because of system time synchronization
Only Configure: No
Affected branch: master
Affected module: data
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: Ia488e7643755c18f7c98f527315334769730f228
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c
index 7f7a2f7..57e0c93 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/atchannel.c
@@ -105,15 +105,12 @@
#ifndef USE_NP
static void setTimespecRelative(struct timespec *p_ts, long long msec)
{
- struct timeval tv;
+ struct timespec ts;
- gettimeofday(&tv, (struct timezone *) NULL);
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ p_ts->tv_sec = ts.tv_sec + (msec / 1000);
+ p_ts->tv_nsec = ts.tv_nsec + (msec % 1000) * 1000L * 1000L;
- /* what's really funny about this is that I know
- pthread_cond_timedwait just turns around and makes this
- a relative time again */
- p_ts->tv_sec = tv.tv_sec + (msec / 1000);
- p_ts->tv_nsec = (tv.tv_usec + (msec % 1000) * 1000L) * 1000L;
}
#endif /*USE_NP*/
@@ -1200,7 +1197,7 @@
int i;
struct atchn_info *channel = NULL;
struct atchn_context *ctx = &atchnctx;
- pthread_attr_t attr;
+ pthread_condattr_t attr;
memset(ctx, 0, sizeof(struct atchn_context));
@@ -1224,8 +1221,10 @@
return -1;
}
- pthread_mutex_init(&channel->s_atchnmutex, NULL);
- pthread_cond_init(&channel->s_atchncond, NULL);
+ pthread_condattr_init(&attr);
+ pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+ pthread_cond_init(&channel->s_atchncond, &attr);
+ pthread_condattr_destroy(&attr);
ctx->atchninfo[i] = channel;
}