Check return from nxsem_wait_initialize()

Resolution of Issue 619 will require multiple steps, this part of the first step in that resolution:  Every call to nxsem_wait_uninterruptible() must handle the return value from nxsem_wait_uninterruptible properly.  This commit is only for those files under graphics/, mm/, net/, sched/, wireless/bluetooth.

Still to do:  Files under fs/, drivers/, and arch.  The last is 116 files and will take some effort.
This commit is contained in:
Gregory Nutt
2020-03-29 11:57:53 -06:00
committed by Abdelatif Guettouche
parent 0558aa0a78
commit 97339e47f1
17 changed files with 544 additions and 459 deletions
+44 -41
View File
@@ -1,35 +1,20 @@
/****************************************************************************
* graphics/vnc/server/vnc_fbdev.c
*
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
@@ -174,7 +159,8 @@ static int up_getvideoinfo(FAR struct fb_vtable_s *vtable,
DEBUGASSERT(fbinfo != NULL && vinfo != NULL);
if (fbinfo != NULL && vinfo != NULL)
{
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
DEBUGASSERT(fbinfo->display >= 0 &&
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
if (session == NULL || session->state != VNCSERVER_RUNNING)
@@ -215,7 +201,8 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
DEBUGASSERT(fbinfo != NULL && pinfo != NULL && planeno == 0);
if (fbinfo != NULL && pinfo != NULL && planeno == 0)
{
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
DEBUGASSERT(fbinfo->display >= 0 &&
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
if (session == NULL || session->state != VNCSERVER_RUNNING)
@@ -262,7 +249,8 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable,
if (fbinfo != NULL && cmap != NULL)
{
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
DEBUGASSERT(fbinfo->display >= 0 &&
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
if (session == NULL || session->state != VNCSERVER_RUNNING)
@@ -287,7 +275,8 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable,
****************************************************************************/
#ifdef CONFIG_FB_CMAP
static int up_putcmap(FAR struct fb_vtable_s *vtable, FAR const struct fb_cmap_s *cmap)
static int up_putcmap(FAR struct fb_vtable_s *vtable,
FAR const struct fb_cmap_s *cmap)
{
FAR struct vnc_fbinfo_s *fbinfo = (FAR struct vnc_fbinfo_s *)vtable;
FAR struct vnc_session_s *session;
@@ -299,7 +288,8 @@ static int up_putcmap(FAR struct fb_vtable_s *vtable, FAR const struct fb_cmap_s
if (fbinfo != NULL && cmap != NULL)
{
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
DEBUGASSERT(fbinfo->display >= 0 &&
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
if (session == NULL || session->state != VNCSERVER_RUNNING)
@@ -337,7 +327,8 @@ static int up_getcursor(FAR struct fb_vtable_s *vtable,
if (fbinfo != NULL && attrib != NULL)
{
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
DEBUGASSERT(fbinfo->display >= 0 &&
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
if (session == NULL || session->state != VNCSERVER_RUNNING)
@@ -374,7 +365,8 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
if (fbinfo != NULL && settings != NULL)
{
DEBUGASSERT(fbinfo->display >= 0 && fbinfo->display < RFB_MAX_DISPLAYS);
DEBUGASSERT(fbinfo->display >= 0 &&
fbinfo->display < RFB_MAX_DISPLAYS);
session = g_vnc_sessions[fbinfo->display];
if (session == NULL || session->state != VNCSERVER_RUNNING)
@@ -395,12 +387,14 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable,
#warning Missing logic
}
#endif
#ifdef CONFIG_FB_HWCURSORIMAGE
if ((settings->flags & FB_CUR_SETIMAGE) != 0)
{
#warning Missing logic
}
#endif
return OK;
}
@@ -485,6 +479,8 @@ static int vnc_start_server(int display)
static inline int vnc_wait_start(int display)
{
int ret;
/* 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
* started. But we might be here before the thread has gotten that far.
@@ -494,8 +490,8 @@ static inline int vnc_wait_start(int display)
* has been allocated and fully initialized.
*/
while (g_vnc_sessions[display] == NULL ||
g_vnc_sessions[display]->state == VNCSERVER_UNINITIALIZED)
while (g_vnc_sessions[display] == NULL ||
g_vnc_sessions[display]->state == VNCSERVER_UNINITIALIZED)
{
/* The server is not yet running. Wait for the server to post the FB
* semaphore. In certain error situations, the server may post the
@@ -503,7 +499,11 @@ static inline int vnc_wait_start(int display)
* conditions here, but I think none that are fatal.
*/
nxsem_wait_uninterruptible(&g_fbstartup[display].fbinit);
ret = nxsem_wait_uninterruptible(&g_fbstartup[display].fbinit);
if (ret < 0)
{
return ret;
}
}
return OK;
@@ -542,8 +542,8 @@ static inline int vnc_wait_connect(int display)
* messages and to perform remote framebuffer updates.
*/
while (g_vnc_sessions[display] == NULL ||
g_vnc_sessions[display]->state != VNCSERVER_RUNNING)
while (g_vnc_sessions[display] == NULL ||
g_vnc_sessions[display]->state != VNCSERVER_RUNNING)
{
/* The server is not yet running. Wait for the server to post the FB
* semaphore. In certain error situations, the server may post the
@@ -574,9 +574,11 @@ static inline int vnc_wait_connect(int display)
else
{
DEBUGASSERT(g_vnc_sessions[display] != NULL &&
g_vnc_sessions[display]->state == VNCSERVER_RUNNING);
g_vnc_sessions[display]->state ==
VNCSERVER_RUNNING);
}
#endif
return ret;
}
}
@@ -726,7 +728,8 @@ int vnc_fbinitialize(int display, vnc_kbdout_t kbdout,
*
* Description:
* Return a a reference to the framebuffer object for the specified video
* plane of the specified plane. Many OSDs support multiple planes of video.
* plane of the specified plane. Many OSDs support multiple planes of
* video.
*
* Input Parameters:
* display - In the case of hardware with multiple displays, this
+23 -29
View File
@@ -1,35 +1,20 @@
/****************************************************************************
* graphics/vnc/vnc_updater.c
*
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
@@ -126,8 +111,16 @@ static void vnc_sem_debug(FAR struct vnc_session_s *session,
int queuecount;
int freewaiting;
int queuewaiting;
int ret;
nxsem_wait_uninterruptible(&g_errsem);
ret = nxsem_wait_uninterruptible(&g_errsem);
if (ret < 0)
{
/* Should happen only on task cancellation */
DEBUGASSERT(ret == -ECANCELED);
return;
}
/* Count structures in the list */
@@ -445,7 +438,8 @@ int vnc_start_updater(FAR struct vnc_session_s *session)
session->state = VNCSERVER_RUNNING;
DEBUGVERIFY(pthread_attr_init(&attr));
DEBUGVERIFY(pthread_attr_setstacksize(&attr, CONFIG_VNCSERVER_UPDATER_STACKSIZE));
DEBUGVERIFY(pthread_attr_setstacksize(&attr,
CONFIG_VNCSERVER_UPDATER_STACKSIZE));
param.sched_priority = CONFIG_VNCSERVER_UPDATER_PRIO;
DEBUGVERIFY(pthread_attr_setschedparam(&attr, &param));