Commit a9abab6a authored by jehan's avatar jehan
Browse files

use CLOCK_BOOTTIME for Android

parent 2ada9646
......@@ -480,15 +480,30 @@ char * belle_sip_strdup(const char *s){
}
#ifndef WIN32
uint64_t belle_sip_time_ms(void){
static int find_best_clock_id () {
struct timespec ts;
static int clock_id=CLOCK_MONOTONIC;
if (clock_gettime(clock_id,&ts)==-1){
belle_sip_error("clock_gettime() error for clock_id=%i: %s",clock_id,strerror(errno));
if (clock_id==CLOCK_MONOTONIC){
static int clock_id=-1;
#ifndef ANDROID
#define DEFAULT_CLOCK_MODE CLOCK_MONOTONIC
#else
#define DEFAULT_CLOCK_MODE CLOCK_BOOTTIME
#endif
if (clock_id==-1) {
if (clock_gettime(DEFAULT_CLOCK_MODE,&ts)!=1){
clock_id=CLOCK_MONOTONIC;
} else if (clock_gettime(CLOCK_REALTIME,&ts)!=1){
clock_id=CLOCK_REALTIME;
return belle_sip_time_ms();
} else {
belle_sip_fatal("Cannot find suitable clock mode");
}
}
return clock_id;
}
uint64_t belle_sip_time_ms(void){
struct timespec ts;
if (clock_gettime(find_best_clock_id(),&ts)==-1){
belle_sip_error("clock_gettime() error for clock_id=%i: %s",find_best_clock_id(),strerror(errno));
return 0;
}
return (ts.tv_sec*1000LL) + (ts.tv_nsec/1000000LL);
......
......@@ -77,7 +77,7 @@ static void schedule_timer(belle_sip_refresher_t* refresher) {
belle_sip_main_loop_remove_source(belle_sip_stack_get_main_loop(refresher->transaction->base.provider->stack),refresher->timer);
belle_sip_object_unref(refresher->timer);
}
refresher->timer=belle_sip_timeout_source_new(timer_cb,refresher,refresher->expires*1000);
refresher->timer=belle_sip_timeout_source_new(timer_cb,refresher,refresher->expires*900);
belle_sip_object_set_name((belle_sip_object_t*)refresher->timer,"Refresher timeout");
belle_sip_main_loop_add_source(belle_sip_stack_get_main_loop(refresher->transaction->base.provider->stack),refresher->timer);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment