From c33bde1f825a9a299d13f940adac3992fd445aa1 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 31 Oct 2017 18:46:49 -0600 Subject: [PATCH] Fixes a memory leak that is caused because the client message queue is not unlinked after the client disconnects from the NX server. --- libnx/nxmu/nx_connect.c | 4 ++-- libnx/nxmu/nx_disconnect.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libnx/nxmu/nx_connect.c b/libnx/nxmu/nx_connect.c index 00b93934e3..e69580bce8 100644 --- a/libnx/nxmu/nx_connect.c +++ b/libnx/nxmu/nx_connect.c @@ -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. * diff --git a/libnx/nxmu/nx_disconnect.c b/libnx/nxmu/nx_disconnect.c index d8cd4517e2..6b1877efc3 100644 --- a/libnx/nxmu/nx_disconnect.c +++ b/libnx/nxmu/nx_disconnect.c @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -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); + } }