diff options
author | Genta IHA <genta@teeda.jp> | 2018-01-15 18:17:20 +0900 |
---|---|---|
committer | Genta IHA <genta@teeda.jp> | 2018-01-16 11:37:16 +0900 |
commit | 0c5b32919e64e2fbdfd26e900f06eb29f47fc295 (patch) | |
tree | 32081624d49b13c3874bbc045d07344ca29ccd8f | |
parent | 247e04c8a59b6e3b32d88fe6dac7bbb4948845a4 (diff) | |
download | vyatta-cfg-0c5b32919e64e2fbdfd26e900f06eb29f47fc295.tar.gz vyatta-cfg-0c5b32919e64e2fbdfd26e900f06eb29f47fc295.zip |
vyatta-cfg: Fix memory leak in Cstore perl binding
The Cstore perl binding (XS) has memory leak bug.
This commit will fix this issue.
All XS should implement "DESTROY" function to free memory,
but this binding haven't this function. It leads memory
leak each time when you call "new Cstore();" in perl code.
Additionally, VyOS Helium standard Perl module
"Vyatta::Config" have a Cstore instance variable, and each
time calling "new Vyatta::Config();" in Perl causes memory
leak due to this issue. Especially, the long-live process
using Vyatta::Config (e.g. vyos-intfwatched) lead to serious
memory exhaustion problem due to this issue.
This patch implements the "DESTROY" function in XS for
Cstore library, and fix this memory leak issue.
-rw-r--r-- | perl_dmod/Cstore/Cstore.xs | 4 | ||||
-rw-r--r-- | perl_dmod/Cstore/typemap | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/perl_dmod/Cstore/Cstore.xs b/perl_dmod/Cstore/Cstore.xs index 3c9a9ad..3626303 100644 --- a/perl_dmod/Cstore/Cstore.xs +++ b/perl_dmod/Cstore/Cstore.xs @@ -45,6 +45,10 @@ OUTPUT: RETVAL +void +Cstore::DESTROY() + + bool Cstore::cfgPathExists(CPATH *pref, bool active_cfg) PREINIT: diff --git a/perl_dmod/Cstore/typemap b/perl_dmod/Cstore/typemap index 8d6d178..7714cd1 100644 --- a/perl_dmod/Cstore/typemap +++ b/perl_dmod/Cstore/typemap @@ -12,7 +12,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -Cstore * O_CPPOBJ +Cstore * O_OBJECT STRVEC * T_STRVEC_REF CPATH * T_CPATH_REF STRSTRMAP * T_STRSTRMAP_REF @@ -20,7 +20,7 @@ STRSTRMAP * T_STRSTRMAP_REF ############################################################ OUTPUT -O_CPPOBJ +O_OBJECT sv_setref_pv($arg, CLASS, (void *) $var); T_STRVEC_REF @@ -44,7 +44,7 @@ T_STRSTRMAP_REF ############################################################ INPUT -O_CPPOBJ +O_OBJECT if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) { $var = ($type) SvIV((SV *) SvRV($arg)); } else { |