Fixes a memory leak that is caused because the client message queue is not unlinked after the client disconnects from the NX server.

This commit is contained in:
Masayuki Ishikawa 2017-10-31 18:46:49 -06:00 committed by Gregory Nutt
parent e348ea70ff
commit c33bde1f82
2 changed files with 10 additions and 2 deletions

View File

@ -60,8 +60,8 @@
****************************************************************************/
/* Each client is assigned a unique ID using the g_nxcid counter. That
* counter increments as each new counter is created and is* protected for
* thread safefy with g_nxlibsem. Note that these are the only global values
* counter increments as each new counter is created and is protected for
* thread safety with g_nxlibsem. Note that these are the only global values
* in the NX implementation. This is because the client ID must be unique
* even across all server instances.
*

View File

@ -39,6 +39,7 @@
#include <nuttx/config.h>
#include <stdio.h>
#include <mqueue.h>
#include <errno.h>
#include <debug.h>
@ -70,6 +71,7 @@ void nx_disconnect(NXHANDLE handle)
{
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
struct nxsvrmsg_s outmsg;
char climqname[NX_CLIENT_MXNAMELEN];
int ret;
/* Inform the server that this client no longer exists */
@ -84,4 +86,10 @@ void nx_disconnect(NXHANDLE handle)
{
gerr("ERROR: nxmu_sendserver() returned %d\n", ret);
}
else
{
snprintf(climqname, sizeof(climqname),
NX_CLIENT_MQNAMEFMT, conn->cid);
(void)mq_unlink(climqname);
}
}