Browse Source

fix pthread_mutex_trylock suspended by locked mutex

liyansheng 2 years ago
parent
commit
81ac3f70b9
1 changed files with 3 additions and 4 deletions
  1. 3 4
      components/libc/time/clock_time.c

+ 3 - 4
components/libc/time/clock_time.c

@@ -41,14 +41,13 @@ INIT_COMPONENT_EXPORT(clock_time_system_init);
 
 int clock_time_to_tick(const struct timespec *time)
 {
-    int tick;
+    int tick = 0;
     long nsecond, second;
     struct timespec tp;
 
     RT_ASSERT(time != RT_NULL);
 
-    tick = RT_WAITING_FOREVER;
-    if (time != RT_NULL)
+    if (time->tv_sec != 0 && time->tv_nsec != 0)
     {
         /* get current tp */
         clock_gettime(CLOCK_REALTIME, &tp);
@@ -546,4 +545,4 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
 
     return RT_EOK;
 }
-RTM_EXPORT(timer_settime);
+RTM_EXPORT(timer_settime);