Backout 3f731241cb. It is a good idea, but has some unpleasant side effect... like SYSLOG and dbg() no longer work

This commit is contained in:
Gregory Nutt 2016-04-18 18:55:36 -06:00
parent 5997373b55
commit 6cfe56202d
7 changed files with 51 additions and 10 deletions

View File

@ -445,6 +445,18 @@ static inline int vnc_wait_server(int display)
result = g_fbstartup[display].result;
if (result != -EBUSY)
{
#ifdef CONFIG_DEBUG
if (result < 0)
{
DEBUGASSERT(g_vnc_sessions[display] == NULL);
gdbg("ERROR: VNC server startup failed: %d\n", result);
}
else
{
DEBUGASSERT(g_vnc_sessions[display] != NULL &&
g_vnc_sessions[display]->state == VNCSERVER_RUNNING);
}
#endif
return result;
}
}

View File

@ -94,6 +94,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
/* Inform the client of the VNC protocol version */
gvdbg("Send protocol version: %s\n", g_vncproto);
len = strlen(g_vncproto);
nsent = psock_send(&session->connect, g_vncproto, len, 0);
if (nsent < 0)
@ -108,6 +110,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
/* Receive the echo of the protocol string */
gvdbg("Receive echo from VNC client\n");
nrecvd = psock_recv(&session->connect, session->inbuf, len, 0);
if (nrecvd < 0)
{
@ -125,6 +129,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
* word:"
*/
gvdbg("Send security type (None)\n");
sectype = (FAR struct rfb_sectype_s *)session->outbuf;
rfb_putbe32(sectype->type, RFB_SECTYPE_NONE);
@ -150,6 +156,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
* In this implementation, the sharing flag is ignored.
*/
gvdbg("Receive ClientInit\n");
nrecvd = psock_recv(&session->connect, session->inbuf,
sizeof(struct rfb_clientinit_s), 0);
if (nrecvd < 0)
@ -162,13 +170,15 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
DEBUGASSERT(nrecvd == sizeof(struct rfb_clientinit_s));
/* Send the ClientInit message
/* Send the ServerInit message
*
* "After receiving the ClientInit message, the server sends a ServerInit
* message. This tells the client the width and height of the servers
* framebuffer, its pixel format and the name associated with the desktop:
*/
gvdbg("Receive ServerInit\n");
serverinit = (FAR struct rfb_serverinit_s *)session->outbuf;
rfb_putbe16(serverinit->width, CONFIG_VNCSERVER_SCREENWIDTH);
@ -204,6 +214,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
* This may override some of our framebuffer settings.
*/
gvdbg("Receive SetPixelFormat\n");
setformat = (FAR struct rfb_setpixelformat_s *)session->inbuf;
nrecvd = psock_recv(&session->connect, setformat,
@ -273,6 +285,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
* we will do only raw format.
*/
gvdbg("Receive encoding types\n");
(void)psock_recv(&session->connect, session->inbuf,
CONFIG_VNCSERVER_INBUFFER_SIZE, 0);

View File

@ -119,6 +119,9 @@ int vnc_receiver(FAR struct vnc_session_s *session)
int errcode;
int ret;
DEBUGASSERT(session);
gvdbg("Receiver running for Display %d\n", session->display);
/* Loop until the client disconnects or an unhandled error occurs */
for (; ; )

View File

@ -57,10 +57,6 @@
#include "vnc_server.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
@ -92,7 +88,7 @@ FAR struct vnc_session_s *g_vnc_sessions[RFB_MAX_DISPLAYS];
****************************************************************************/
static void vnc_reset_session(FAR struct vnc_session_s *session,
FAR uint8_t *fb)
FAR uint8_t *fb, int display)
{
FAR struct vnc_fbupdate_s *curr;
FAR struct vnc_fbupdate_s *next;
@ -137,6 +133,7 @@ static void vnc_reset_session(FAR struct vnc_session_s *session,
sem_reset(&session->freesem, CONFIG_VNCSERVER_NUPDATES);
sem_reset(&session->queuesem, 0);
session->fb = fb;
session->display = display;
session->state = VNCSERVER_INITIALIZED;
}
@ -160,6 +157,8 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port)
struct sockaddr_in addr;
int ret;
gvdbg("Connecting display %d\n", session->display);
/* Create a listening socket */
addr.sin_family = AF_INET;
@ -194,6 +193,8 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port)
/* Connect to the client */
gvdbg("Acception connection for display %d\n", session->display);
ret = psock_accept(&session->listen, NULL, NULL, &session->connect);
if (ret < 0)
{
@ -201,6 +202,7 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port)
goto errout_with_listener;
}
gvdbg("Display %d connected\n", session->display);
session->state = VNCSERVER_CONNECTED;
return OK;
@ -234,6 +236,7 @@ int vnc_server(int argc, FAR char *argv[])
int display;
int ret;
gvdbg("Server Started\n");
DEBUGASSERT(session != NULL);
/* A single argument is expected: A diplay port number in ASCII form */
@ -253,6 +256,8 @@ int vnc_server(int argc, FAR char *argv[])
goto errout_with_post;
}
gvdbg("Display %d\n", display);
/* Allocate the framebuffer memory. We rely on the fact that
* the KMM allocator will align memory to 32-bits or better.
*/
@ -290,7 +295,7 @@ int vnc_server(int argc, FAR char *argv[])
* for the next connection.
*/
vnc_reset_session(session, fb);
vnc_reset_session(session, fb, display);
g_fbstartup[display].result = -EBUSY;
sem_reset(&g_fbstartup[display].fbsem, 0);

View File

@ -207,6 +207,7 @@ struct vnc_session_s
/* Display geometry and color characteristics */
uint8_t display; /* Display number (for debug) */
uint8_t colorfmt; /* Remote color format (See include/nuttx/fb.h) */
uint8_t bpp; /* Remote bits per pixel */
FAR uint8_t *fb; /* Allocated local frame buffer */

View File

@ -544,9 +544,11 @@ static FAR void *vnc_updater(FAR void *arg)
} convert;
bool color32 = false;
DEBUGASSERT(session != NULL);
gvdbg("Updater running for Display %d\n", session->display);
/* Set up some constant pointers and values */
DEBUGASSERT(session != NULL);
update = (FAR struct rfb_framebufferupdate_s *)session->outbuf;
destrect = update->rect;
@ -743,6 +745,8 @@ int vnc_start_updater(FAR struct vnc_session_s *session)
struct sched_param param;
int status;
gvdbg("Starting updater for Display %d\n", session->display);
/* Create thread that is gonna send rectangles to the client */
session->state = VNCSERVER_RUNNING;

View File

@ -117,12 +117,14 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
#endif
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
#if 0 /* No... there are side effects */
/* Associate file descriptors with the new task. Exclude kernel threads;
* kernel threads do not have file or socket descriptors. They must use
* SYSLOG for output and the low-level psock interfaces for network I/O.
*/
if (ttype != TCB_FLAG_TTYPE_KERNEL)
#endif
{
ret = group_setuptaskfiles(tcb);
if (ret < OK)