Merge "Merge tag 'AU_LINUX_ANDROID_KK.04.04.04.010.094' into HEAD"

This commit is contained in:
Linux Build Service Account 2014-08-14 14:25:10 -07:00 committed by Gerrit - the friendly Code Review server
commit b236da9f2f
3 changed files with 27 additions and 8 deletions

View file

@ -316,8 +316,9 @@ enum loc_api_adapter_err {
LOC_API_ADAPTER_ERR_TIMEOUT = 8, LOC_API_ADAPTER_ERR_TIMEOUT = 8,
LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9, LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
LOC_API_ADAPTER_ERR_ENGINE_DOWN = 100, /* equating engine down to phone offline, as they are the same errror */
LOC_API_ADAPTER_ERR_FAILURE, LOC_API_ADAPTER_ERR_ENGINE_DOWN = LOC_API_ADAPTER_ERR_PHONE_OFFLINE,
LOC_API_ADAPTER_ERR_FAILURE = 101,
LOC_API_ADAPTER_ERR_UNKNOWN LOC_API_ADAPTER_ERR_UNKNOWN
}; };

View file

@ -1718,7 +1718,9 @@ static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data)
ret_val = loc_eng_data.adapter->startFix(); ret_val = loc_eng_data.adapter->startFix();
if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS || if (ret_val == LOC_API_ADAPTER_ERR_SUCCESS ||
ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN) ret_val == LOC_API_ADAPTER_ERR_ENGINE_DOWN ||
ret_val == LOC_API_ADAPTER_ERR_PHONE_OFFLINE ||
ret_val == LOC_API_ADAPTER_ERR_GENERAL_FAILURE)
{ {
loc_eng_data.adapter->setInSession(TRUE); loc_eng_data.adapter->setInSession(TRUE);
loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN); loc_inform_gps_status(loc_eng_data, GPS_STATUS_SESSION_BEGIN);

View file

@ -101,12 +101,28 @@ static void *timer_thread(void *thread_data)
break; break;
} }
pthread_mutex_destroy(&t->timer_mutex);
pthread_cond_destroy(&t->timer_cond);
if(ETIMEDOUT == ret) if(ETIMEDOUT == ret)
t->callback_func(t->user_data, ret); t->callback_func(t->user_data, ret);
// A (should be rare) race condition is that, when the loc_time_stop is called
// and acquired mutex, we reach here. pthread_mutex_destroy will fail with
// error code EBUSY. We give it 6 tries in 5 seconds. Should be eanough time
// for loc_timer_stop to complete. With the 7th try, we also perform unlock
// prior to destroy.
{
int i;
for (i = 0; EBUSY == pthread_mutex_destroy(&t->timer_mutex) && i <= 5; i++) {
if (i < 5) {
sleep(1);
} else {
// nah, forget it, something is seriously wrong. Mutex has been
// held too long. Unlock the mutext here.
pthread_mutex_unlock(&t->timer_mutex);
}
}
}
pthread_cond_destroy(&t->timer_cond);
free(t); free(t);
LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__); LOC_LOGD("%s:%d]: Exit\n", __func__, __LINE__);
return NULL; return NULL;
@ -175,8 +191,8 @@ _err:
void loc_timer_stop(void* handle) { void loc_timer_stop(void* handle) {
timer_data* t = (timer_data*)handle; timer_data* t = (timer_data*)handle;
if (NULL != t && (READY == t->state || WAITING == t->state)) { if (NULL != t && (READY == t->state || WAITING == t->state) &&
pthread_mutex_lock(&(t->timer_mutex)); pthread_mutex_lock(&(t->timer_mutex)) == 0) {
if (READY == t->state || WAITING == t->state) { if (READY == t->state || WAITING == t->state) {
pthread_cond_signal(&t->timer_cond); pthread_cond_signal(&t->timer_cond);
t->state = ABORT; t->state = ABORT;