From ca8be5eb1d8cf230ed9dd5fcddd14c54f1d0d0b2 Mon Sep 17 00:00:00 2001 From: liuh-80 Date: Thu, 21 Jul 2022 05:09:25 +0000 Subject: [PATCH 1/2] Fix epool leak issue --- pyext/swsscommon.i | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pyext/swsscommon.i b/pyext/swsscommon.i index 49af0a656..82526a9c8 100644 --- a/pyext/swsscommon.i +++ b/pyext/swsscommon.i @@ -158,6 +158,14 @@ T castSelectableObj(swss::Selectable *temp) %template(hgetall) hgetall>; } +%extend swss::PubSub { +%pythoncode { + def __del__(self): + self.__swig_destroy__(self.this) + del self.this +} +} + %ignore swss::TableEntryPoppable::pops(std::deque &, const std::string &); %apply std::vector& OUTPUT {std::vector &keys}; %apply std::vector& OUTPUT {std::vector &ops}; @@ -210,3 +218,7 @@ T castSelectableObj(swss::Selectable *temp) %include "dbinterface.h" %include "logger.h" %include "status_code_util.h" + +// Handle object ownership issue with %newobject https://www.swig.org/Doc4.0/SWIGDocumentation.html#Customization_ownership +%newobject DBConnector::pubsub(); +%newobject DBConnector::newConnector(unsigned int timeout); \ No newline at end of file From d722e8e31ef630e44484b92d8abc1df9adb211cf Mon Sep 17 00:00:00 2001 From: liuh-80 Date: Thu, 21 Jul 2022 06:48:09 +0000 Subject: [PATCH 2/2] Fix code issue --- pyext/swsscommon.i | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pyext/swsscommon.i b/pyext/swsscommon.i index 82526a9c8..cbbf8a4e2 100644 --- a/pyext/swsscommon.i +++ b/pyext/swsscommon.i @@ -142,6 +142,12 @@ T castSelectableObj(swss::Selectable *temp) %template(CastSelectableToRedisSelectObj) castSelectableObj; %template(CastSelectableToSubscriberTableObj) castSelectableObj; +// Handle object ownership issue with %newobject: +// https://www.swig.org/Doc4.0/SWIGDocumentation.html#Customization_ownership +// %newobject must declared before %include header files +%newobject swss::DBConnector::pubsub; +%newobject swss::DBConnector::newConnector; + %include "schema.h" %include "dbconnector.h" %include "sonicv2connector.h" @@ -158,14 +164,6 @@ T castSelectableObj(swss::Selectable *temp) %template(hgetall) hgetall>; } -%extend swss::PubSub { -%pythoncode { - def __del__(self): - self.__swig_destroy__(self.this) - del self.this -} -} - %ignore swss::TableEntryPoppable::pops(std::deque &, const std::string &); %apply std::vector& OUTPUT {std::vector &keys}; %apply std::vector& OUTPUT {std::vector &ops}; @@ -218,7 +216,3 @@ T castSelectableObj(swss::Selectable *temp) %include "dbinterface.h" %include "logger.h" %include "status_code_util.h" - -// Handle object ownership issue with %newobject https://www.swig.org/Doc4.0/SWIGDocumentation.html#Customization_ownership -%newobject DBConnector::pubsub(); -%newobject DBConnector::newConnector(unsigned int timeout); \ No newline at end of file