Browse Source

[lwp] 修复错误码误用 (#7906)

zhkag 1 year ago
parent
commit
d5c9dc09a0
1 changed files with 10 additions and 5 deletions
  1. 10 5
      components/lwp/lwp_pmutex.c

+ 10 - 5
components/lwp/lwp_pmutex.c

@@ -189,7 +189,7 @@ static int _pthread_mutex_init(void *umutex)
     if (lock_ret != RT_EOK)
     {
         rt_set_errno(EAGAIN);
-        return -EINTR;
+        return -EAGAIN;
     }
 
     lwp = lwp_self();
@@ -262,7 +262,7 @@ static int _pthread_mutex_lock_timeout(void *umutex, struct timespec *timeout)
     lock_ret = rt_mutex_take_interruptible(&_pmutex_lock, RT_WAITING_FOREVER);
     if (lock_ret != RT_EOK)
     {
-        rt_set_errno(EAGAIN);
+        rt_set_errno(EINTR);
         return -EINTR;
     }
 
@@ -323,6 +323,11 @@ static int _pthread_mutex_lock_timeout(void *umutex, struct timespec *timeout)
                 return -ETIMEDOUT;
             }
         }
+        else if (lock_ret == -RT_EINTR)
+        {
+            rt_set_errno(EINTR);
+            return -EINTR;
+        }
         else
         {
             rt_set_errno(EAGAIN);
@@ -343,7 +348,7 @@ static int _pthread_mutex_unlock(void *umutex)
     if (lock_ret != RT_EOK)
     {
         rt_set_errno(EAGAIN);
-        return -EINTR;
+        return -EAGAIN;
     }
 
     lwp = lwp_self();
@@ -385,7 +390,7 @@ static int _pthread_mutex_unlock(void *umutex)
     if (lock_ret != RT_EOK)
     {
         rt_set_errno(EPERM);
-        return -EAGAIN;
+        return -EPERM;
     }
     return 0;
 }
@@ -400,7 +405,7 @@ static int _pthread_mutex_destroy(void *umutex)
     if (lock_ret != RT_EOK)
     {
         rt_set_errno(EAGAIN);
-        return -EINTR;
+        return -EAGAIN;
     }
 
     lwp = lwp_self();