From 14c6f3ee95e53a0dea872eadf7ed6330b3d1c71b Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 12 Dec 2018 04:02:29 +0100 Subject: [PATCH] vty: show subscriber: put() before printing the use count Do not show the VTY command's own use count during 'show subscriber '. When using 'show subscriber msisdn 2023', I was surprised to see a use count of 2 and suspected a use count leak. With 'show subscriber cache' however, the use count is 1. So I realized it is the vty command's own use count that makes it two, besides the lu_complete=true one. Change-Id: Id02b57b7ed299b010b9f8b9e809548eb1e6aa699 --- src/libmsc/msc_vty.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c index 87adc82de..4e71e2628 100644 --- a/src/libmsc/msc_vty.c +++ b/src/libmsc/msc_vty.c @@ -832,10 +832,13 @@ DEFUN(show_subscr, return CMD_WARNING; } - subscr_dump_full_vty(vty, vsub); - + /* In the vty output to the user, exclude this local use count added by vlr_subscr_get() in get_vsub_by_argv(). + * This works, because: for get_vsub_by_argv() to succeed, there *must* have been at least one use count before + * this, and since this is not multi-threaded, this vlr_subscr_put() cannot possibly reach a count of 0. */ vlr_subscr_put(vsub); + subscr_dump_full_vty(vty, vsub); + return CMD_SUCCESS; }