mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +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:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* graphics/vnc/server/vnc_fbdev.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -482,7 +482,7 @@ static int vnc_start_server(int display)
|
||||
|
||||
static inline int vnc_wait_start(int display)
|
||||
{
|
||||
int errcode;
|
||||
int ret = OK;
|
||||
|
||||
/* Check if there has been a session allocated yet. This is one of the
|
||||
* first things that the VNC server will do with the kernel thread is
|
||||
@@ -502,22 +502,20 @@ static inline int vnc_wait_start(int display)
|
||||
* conditions here, but I think none that are fatal.
|
||||
*/
|
||||
|
||||
while (sem_wait(&g_fbstartup[display].fbinit) < 0)
|
||||
do
|
||||
{
|
||||
errcode = get_errno();
|
||||
ret = nxsem_wait(&g_fbstartup[display].fbinit);
|
||||
|
||||
/* sem_wait() should fail only if it is interrupt by a signal. */
|
||||
/* The only case that an error should occur here is if the wait
|
||||
* was awakened by a signal.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(errcode == EINTR);
|
||||
if (errcode != EINTR)
|
||||
{
|
||||
DEBUGASSERT(errcode > 0);
|
||||
return -errcode;
|
||||
}
|
||||
DEBUGASSERT(ret == OK || ret == -EINTR);
|
||||
}
|
||||
while (ret == -EINTR);
|
||||
}
|
||||
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -563,19 +561,20 @@ static inline int vnc_wait_connect(int display)
|
||||
* conditions here, but I think none that are fatal.
|
||||
*/
|
||||
|
||||
while (sem_wait(&g_fbstartup[display].fbconnect) < 0)
|
||||
do
|
||||
{
|
||||
errcode = get_errno();
|
||||
ret = nxsem_wait(&g_fbstartup[display].fbconnect);
|
||||
|
||||
/* sem_wait() should fail only if it is interrupt by a signal. */
|
||||
/* The only case that an error should occur here is if the wait
|
||||
* was awakened by a signal.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(errcode == EINTR);
|
||||
if (errcode != EINTR)
|
||||
if (ret < 0 && ret != -EINTR)
|
||||
{
|
||||
DEBUGASSERT(errcode > 0);
|
||||
return -errcode;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
while (ret == -EINTR);
|
||||
|
||||
/* We were awakened. A result of -EBUSY means that the negotiation
|
||||
* is not complete. Why would we be awakened in that case? Some
|
||||
|
||||
Reference in New Issue
Block a user