PengZheng commented on code in PR #583:
URL: https://github.com/apache/celix/pull/583#discussion_r1246227393


##########
libs/utils/src/celix_threads.c:
##########
@@ -182,21 +175,39 @@ celix_status_t 
celixThreadCondition_timedwaitRelative(celix_thread_cond_t *cond,
 }
 #else
 celix_status_t celixThreadCondition_timedwaitRelative(celix_thread_cond_t 
*cond, celix_thread_mutex_t *mutex, long seconds, long nanoseconds) {
-    struct timespec time;
-    seconds = seconds >= 0 ? seconds : 0;
-    time = celix_gettime(CLOCK_MONOTONIC);
-    time.tv_sec += seconds;
-    if(nanoseconds > 0) {
-        time.tv_nsec += nanoseconds;
-        while (time.tv_nsec > CELIX_NS_IN_SEC) {
-            time.tv_sec++;
-            time.tv_nsec -= CELIX_NS_IN_SEC;
-        }
-    }
+    double delay = (double)seconds + ((double)nanoseconds / 1000000000);
+    struct timespec time = celixThreadCondition_getDelayedTime(delay);
     return pthread_cond_timedwait(cond, mutex, &time);
 }
 #endif
 
+struct timespec celixThreadCondition_getTime() {
+    return celixThreadCondition_getDelayedTime(0);
+}
+
+struct timespec celixThreadCondition_getDelayedTime(double delayInSeconds) {
+#if __APPLE__
+    struct timeval tv;
+    struct timespec now;
+    gettimeofday(&tv, NULL);

Review Comment:
   A quick fix has been sent: 
https://github.com/apache/celix/pull/583/commits/1df9b8165a01ca5c0158cf70f40f35111898657f
   
   PS: `brew update` kept failing (but not always) on our CI. Without mac at 
hand, I shall stop here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to