summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2017-01-20 14:15:31 +0100
committerKaleb KEITHLEY <kkeithle@redhat.com>2017-06-16 09:57:25 +0000
commitcfa46e1774178d0af7cabc010d397d62fc0501a6 (patch)
treea6a410e6ebbf19738fe177b368bf86c5156c8fa5
parent6aaa4cd9a0eb75d791a47d88dd43fbea90285245 (diff)
nfs/nlm: free the nlm_client upon RPC_DISCONNECT
When an NLM client disconnects, it should be removed from the list and free'd. > Cherry picked from commit 6897ba5c51b29c05b270c447adb1a34cb8e61911: > Change-Id: Ib427c896bfcdc547a3aee42a652578ffd076e2ad > BUG: 1381970 > Signed-off-by: Niels de Vos <ndevos@redhat.com> > Reviewed-on: https://review.gluster.org/17189 > Smoke: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Change-Id: Ib427c896bfcdc547a3aee42a652578ffd076e2ad BUG: 1450380 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: https://review.gluster.org/17277 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
-rw-r--r--xlators/nfs/server/src/nlm4.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index 903262eff54..cff9a3f5044 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -45,7 +45,7 @@
/* TODO:
* 1) 2 opens racing .. creating an fd leak.
- * 2) use mempool for nlmclnt - destroy if no fd exists, create during 1st call
+ * 2) use GF_REF_* for nlm_clnt_t
*/
typedef ssize_t (*nlm4_serializer) (struct iovec outmsg, void *args);
@@ -333,6 +333,24 @@ ret:
return rpc_clnt;
}
+static void
+nlm_client_free (nlm_client_t *nlmclnt)
+{
+ list_del (&nlmclnt->fdes);
+ list_del (&nlmclnt->nlm_clients);
+ list_del (&nlmclnt->shares);
+
+ GF_FREE (nlmclnt->caller_name);
+
+ if (nlmclnt->rpc_clnt) {
+ /* cleanup the saved-frames before last unref */
+ rpc_clnt_connection_cleanup (&nlmclnt->rpc_clnt->conn);
+ /* rpc_clnt_connection_cleanup() calls rpc_clnt_unref() */
+ }
+
+ GF_FREE (nlmclnt);
+}
+
int
nlm_set_rpc_clnt (rpc_clnt_t *rpc_clnt, char *caller_name)
{
@@ -375,26 +393,16 @@ int
nlm_unset_rpc_clnt (rpc_clnt_t *rpc)
{
nlm_client_t *nlmclnt = NULL;
- rpc_clnt_t *rpc_clnt = NULL;
LOCK (&nlm_client_list_lk);
list_for_each_entry (nlmclnt, &nlm_client_list, nlm_clients) {
if (rpc == nlmclnt->rpc_clnt) {
- rpc_clnt = nlmclnt->rpc_clnt;
- nlmclnt->rpc_clnt = NULL;
+ nlm_client_free (nlmclnt);
break;
}
}
UNLOCK (&nlm_client_list_lk);
- if (rpc_clnt == NULL) {
- return -1;
- }
- if (rpc_clnt) {
- /* cleanup the saved-frames before last unref */
- rpc_clnt_connection_cleanup (&rpc_clnt->conn);
- rpc_clnt_unref (rpc_clnt);
- }
return 0;
}