Fix net_lock returning ERROR when instead of real error code on failure.

This commit is contained in:
Jussi Kivilinna 2017-09-01 07:18:16 -06:00 committed by Gregory Nutt
parent afe137ffbf
commit 5beaad491a
1 changed files with 20 additions and 7 deletions

View File

@ -232,6 +232,16 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime)
ret = sem_wait(sem);
}
/* Check for errors from sem_wait() (should only be EINTR)
* REVISIT: errno really should not be used within the OS
*/
if (ret < 0)
{
ret = -get_errno();
DEBUGASSERT(ret < 0);
}
/* Recover the network lock at the proper count */
_net_takesem();
@ -241,15 +251,18 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime)
else
{
ret = sem_wait(sem);
/* Check for errors from sem_wait() (should only be EINTR)
* REVISIT: errno really should not be used within the OS
*/
if (ret < 0)
{
ret = -get_errno();
DEBUGASSERT(ret < 0);
}
}
/* REVISIT: errno really should not be used within the OS */
if (ret < 0)
{
ret = -get_errno();
DEBUGASSERT(ret < 0);
}
sched_unlock();
leave_critical_section(flags);