mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
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:
@@ -445,6 +445,18 @@ static inline int vnc_wait_server(int display)
|
|||||||
result = g_fbstartup[display].result;
|
result = g_fbstartup[display].result;
|
||||||
if (result != -EBUSY)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||||||
|
|
||||||
/* Inform the client of the VNC protocol version */
|
/* Inform the client of the VNC protocol version */
|
||||||
|
|
||||||
|
gvdbg("Send protocol version: %s\n", g_vncproto);
|
||||||
|
|
||||||
len = strlen(g_vncproto);
|
len = strlen(g_vncproto);
|
||||||
nsent = psock_send(&session->connect, g_vncproto, len, 0);
|
nsent = psock_send(&session->connect, g_vncproto, len, 0);
|
||||||
if (nsent < 0)
|
if (nsent < 0)
|
||||||
@@ -108,6 +110,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||||||
|
|
||||||
/* Receive the echo of the protocol string */
|
/* Receive the echo of the protocol string */
|
||||||
|
|
||||||
|
gvdbg("Receive echo from VNC client\n");
|
||||||
|
|
||||||
nrecvd = psock_recv(&session->connect, session->inbuf, len, 0);
|
nrecvd = psock_recv(&session->connect, session->inbuf, len, 0);
|
||||||
if (nrecvd < 0)
|
if (nrecvd < 0)
|
||||||
{
|
{
|
||||||
@@ -125,6 +129,8 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||||||
* word:"
|
* word:"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
gvdbg("Send security type (None)\n");
|
||||||
|
|
||||||
sectype = (FAR struct rfb_sectype_s *)session->outbuf;
|
sectype = (FAR struct rfb_sectype_s *)session->outbuf;
|
||||||
rfb_putbe32(sectype->type, RFB_SECTYPE_NONE);
|
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.
|
* In this implementation, the sharing flag is ignored.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
gvdbg("Receive ClientInit\n");
|
||||||
|
|
||||||
nrecvd = psock_recv(&session->connect, session->inbuf,
|
nrecvd = psock_recv(&session->connect, session->inbuf,
|
||||||
sizeof(struct rfb_clientinit_s), 0);
|
sizeof(struct rfb_clientinit_s), 0);
|
||||||
if (nrecvd < 0)
|
if (nrecvd < 0)
|
||||||
@@ -162,13 +170,15 @@ int vnc_negotiate(FAR struct vnc_session_s *session)
|
|||||||
|
|
||||||
DEBUGASSERT(nrecvd == sizeof(struct rfb_clientinit_s));
|
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
|
* "After receiving the ClientInit message, the server sends a ServerInit
|
||||||
* message. This tells the client the width and height of the server’s
|
* message. This tells the client the width and height of the server’s
|
||||||
* framebuffer, its pixel format and the name associated with the desktop:
|
* framebuffer, its pixel format and the name associated with the desktop:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
gvdbg("Receive ServerInit\n");
|
||||||
|
|
||||||
serverinit = (FAR struct rfb_serverinit_s *)session->outbuf;
|
serverinit = (FAR struct rfb_serverinit_s *)session->outbuf;
|
||||||
|
|
||||||
rfb_putbe16(serverinit->width, CONFIG_VNCSERVER_SCREENWIDTH);
|
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.
|
* This may override some of our framebuffer settings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
gvdbg("Receive SetPixelFormat\n");
|
||||||
|
|
||||||
setformat = (FAR struct rfb_setpixelformat_s *)session->inbuf;
|
setformat = (FAR struct rfb_setpixelformat_s *)session->inbuf;
|
||||||
|
|
||||||
nrecvd = psock_recv(&session->connect, setformat,
|
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.
|
* we will do only raw format.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
gvdbg("Receive encoding types\n");
|
||||||
|
|
||||||
(void)psock_recv(&session->connect, session->inbuf,
|
(void)psock_recv(&session->connect, session->inbuf,
|
||||||
CONFIG_VNCSERVER_INBUFFER_SIZE, 0);
|
CONFIG_VNCSERVER_INBUFFER_SIZE, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ int vnc_receiver(FAR struct vnc_session_s *session)
|
|||||||
int errcode;
|
int errcode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
DEBUGASSERT(session);
|
||||||
|
gvdbg("Receiver running for Display %d\n", session->display);
|
||||||
|
|
||||||
/* Loop until the client disconnects or an unhandled error occurs */
|
/* Loop until the client disconnects or an unhandled error occurs */
|
||||||
|
|
||||||
for (; ; )
|
for (; ; )
|
||||||
|
|||||||
@@ -57,10 +57,6 @@
|
|||||||
|
|
||||||
#include "vnc_server.h"
|
#include "vnc_server.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* 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,
|
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 *curr;
|
||||||
FAR struct vnc_fbupdate_s *next;
|
FAR struct vnc_fbupdate_s *next;
|
||||||
@@ -136,8 +132,9 @@ static void vnc_reset_session(FAR struct vnc_session_s *session,
|
|||||||
|
|
||||||
sem_reset(&session->freesem, CONFIG_VNCSERVER_NUPDATES);
|
sem_reset(&session->freesem, CONFIG_VNCSERVER_NUPDATES);
|
||||||
sem_reset(&session->queuesem, 0);
|
sem_reset(&session->queuesem, 0);
|
||||||
session->fb = fb;
|
session->fb = fb;
|
||||||
session->state = VNCSERVER_INITIALIZED;
|
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;
|
struct sockaddr_in addr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
gvdbg("Connecting display %d\n", session->display);
|
||||||
|
|
||||||
/* Create a listening socket */
|
/* Create a listening socket */
|
||||||
|
|
||||||
addr.sin_family = AF_INET;
|
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 */
|
/* Connect to the client */
|
||||||
|
|
||||||
|
gvdbg("Acception connection for display %d\n", session->display);
|
||||||
|
|
||||||
ret = psock_accept(&session->listen, NULL, NULL, &session->connect);
|
ret = psock_accept(&session->listen, NULL, NULL, &session->connect);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@@ -201,6 +202,7 @@ static int vnc_connect(FAR struct vnc_session_s *session, int port)
|
|||||||
goto errout_with_listener;
|
goto errout_with_listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gvdbg("Display %d connected\n", session->display);
|
||||||
session->state = VNCSERVER_CONNECTED;
|
session->state = VNCSERVER_CONNECTED;
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
@@ -234,6 +236,7 @@ int vnc_server(int argc, FAR char *argv[])
|
|||||||
int display;
|
int display;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
gvdbg("Server Started\n");
|
||||||
DEBUGASSERT(session != NULL);
|
DEBUGASSERT(session != NULL);
|
||||||
|
|
||||||
/* A single argument is expected: A diplay port number in ASCII form */
|
/* 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;
|
goto errout_with_post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gvdbg("Display %d\n", display);
|
||||||
|
|
||||||
/* Allocate the framebuffer memory. We rely on the fact that
|
/* Allocate the framebuffer memory. We rely on the fact that
|
||||||
* the KMM allocator will align memory to 32-bits or better.
|
* 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.
|
* for the next connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
vnc_reset_session(session, fb);
|
vnc_reset_session(session, fb, display);
|
||||||
g_fbstartup[display].result = -EBUSY;
|
g_fbstartup[display].result = -EBUSY;
|
||||||
sem_reset(&g_fbstartup[display].fbsem, 0);
|
sem_reset(&g_fbstartup[display].fbsem, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ struct vnc_session_s
|
|||||||
|
|
||||||
/* Display geometry and color characteristics */
|
/* 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 colorfmt; /* Remote color format (See include/nuttx/fb.h) */
|
||||||
uint8_t bpp; /* Remote bits per pixel */
|
uint8_t bpp; /* Remote bits per pixel */
|
||||||
FAR uint8_t *fb; /* Allocated local frame buffer */
|
FAR uint8_t *fb; /* Allocated local frame buffer */
|
||||||
|
|||||||
@@ -544,9 +544,11 @@ static FAR void *vnc_updater(FAR void *arg)
|
|||||||
} convert;
|
} convert;
|
||||||
bool color32 = false;
|
bool color32 = false;
|
||||||
|
|
||||||
|
DEBUGASSERT(session != NULL);
|
||||||
|
gvdbg("Updater running for Display %d\n", session->display);
|
||||||
|
|
||||||
/* Set up some constant pointers and values */
|
/* Set up some constant pointers and values */
|
||||||
|
|
||||||
DEBUGASSERT(session != NULL);
|
|
||||||
update = (FAR struct rfb_framebufferupdate_s *)session->outbuf;
|
update = (FAR struct rfb_framebufferupdate_s *)session->outbuf;
|
||||||
destrect = update->rect;
|
destrect = update->rect;
|
||||||
|
|
||||||
@@ -743,6 +745,8 @@ int vnc_start_updater(FAR struct vnc_session_s *session)
|
|||||||
struct sched_param param;
|
struct sched_param param;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
gvdbg("Starting updater for Display %d\n", session->display);
|
||||||
|
|
||||||
/* Create thread that is gonna send rectangles to the client */
|
/* Create thread that is gonna send rectangles to the client */
|
||||||
|
|
||||||
session->state = VNCSERVER_RUNNING;
|
session->state = VNCSERVER_RUNNING;
|
||||||
|
|||||||
@@ -117,12 +117,14 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
|
#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;
|
/* Associate file descriptors with the new task. Exclude kernel threads;
|
||||||
* kernel threads do not have file or socket descriptors. They must use
|
* 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.
|
* SYSLOG for output and the low-level psock interfaces for network I/O.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (ttype != TCB_FLAG_TTYPE_KERNEL)
|
if (ttype != TCB_FLAG_TTYPE_KERNEL)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ret = group_setuptaskfiles(tcb);
|
ret = group_setuptaskfiles(tcb);
|
||||||
if (ret < OK)
|
if (ret < OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user