mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
Squashed commit of the following:
This commit backs out most of commit b4747286b1. That change was added because sem_wait() would sometimes cause cancellation points inappropriated. But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.
In the OS, all calls to sem_wait() changed to nxsem_wait(). nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.
In all OS functions (not libraries), change sem_wait() to nxsem_wait(). This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.
sched/semaphore: Add the function nxsem_wait(). This is a new internal OS interface. It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
This commit is contained in:
@@ -177,31 +177,8 @@ static sem_t g_ipv6_cachelock;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
|
||||
static int net_lock_ipv4_cache(void)
|
||||
{
|
||||
int ret = sem_wait(&g_ipv4_cachelock);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -get_errno();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
|
||||
static int net_lock_ipv6_cache(void)
|
||||
{
|
||||
int ret = sem_wait(&g_ipv6_cachelock);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -get_errno();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#define net_lock_ipv4_cache() mxsem_wait(&g_ipv4_cachelock);
|
||||
#define net_lock_ipv6_cache() mxsem_wait(&g_ipv6_cachelock);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_unlock_ipv4_cache and net_unlock_ipv6_cache
|
||||
|
||||
@@ -674,12 +674,10 @@ int net_lockroute_ipv4(void)
|
||||
{
|
||||
/* No.. wait to get the lock */
|
||||
|
||||
ret = sem_wait(&g_ipv4_exclsem);
|
||||
ret = nxsem_wait(&g_ipv4_exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
nerr("ERROR: sem_wait() failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
nerr("ERROR: nxsem_wait() failed: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -715,12 +713,10 @@ int net_lockroute_ipv6(void)
|
||||
{
|
||||
/* No.. wait to get the lock */
|
||||
|
||||
ret = sem_wait(&g_ipv6_exclsem);
|
||||
ret = nxsem_wait(&g_ipv6_exclsem);
|
||||
if (ret < 0)
|
||||
{
|
||||
int errcode = get_errno();
|
||||
nerr("ERROR: sem_wait() failed: %d\n", errcode);
|
||||
ret = -errcode;
|
||||
nerr("ERROR: nxsem_wait() failed: %d\n", errcode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user