- iTimeout += now.tv_usec / 1000;
- abstime.tv_sec = now.tv_sec + (time_t)(iTimeout / 1000);
- abstime.tv_nsec = (long)((iTimeout % (unsigned long)1000) * (unsigned long)1000000);
- bReturn = (pthread_cond_timedwait(&m_cond, &mutex->m_mutex, &abstime) == 0);
+ if (iTimeout > 0)
+ {
+ struct timespec abstime;
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ iTimeout += now.tv_usec / 1000;
+ abstime.tv_sec = now.tv_sec + (time_t)(iTimeout / 1000);
+ abstime.tv_nsec = (int32_t)((iTimeout % (uint32_t)1000) * (uint32_t)1000000);
+ bReturn = (pthread_cond_timedwait(&m_cond, &mutex->m_mutex, &abstime) == 0);
+ }
+ else
+ {
+ bReturn = (pthread_cond_wait(&m_cond, &mutex->m_mutex) == 0);
+ }