[devel] [PATCH 1 of 1] IMM: release inactive search handles [#47]
osaf/services/saf/immsv/immnd/ImmModel.cc| 49 +++- osaf/services/saf/immsv/immnd/ImmSearchOp.cc | 1 + osaf/services/saf/immsv/immnd/ImmSearchOp.hh | 4 ++ 3 files changed, 53 insertions(+), 1 deletions(-) diff --git a/osaf/services/saf/immsv/immnd/ImmModel.cc b/osaf/services/saf/immsv/immnd/ImmModel.cc --- a/osaf/services/saf/immsv/immnd/ImmModel.cc +++ b/osaf/services/saf/immsv/immnd/ImmModel.cc @@ -33,6 +33,7 @@ #define PRT_LOW_THRESHOLD 1 /* See ImmModel::immNotPbeWritable */ #define PRT_HIGH_THRESHOLD 4 /* See ImmModel::immNotPbeWritable */ #define CCB_CRIT_THRESHOLD 8 /* See ImmModel::immNotPbeWritable */ +#define SEARCH_TIMEOUT_SEC 600 /* Search timeout */ struct ContinuationInfo2 @@ -968,6 +969,46 @@ immModel_cleanTheBasement(IMMND_CB *cb, osafassert(ix==(*pbePrtoReqArrSize)); } +time_t now = time(NULL); +ImmSearchOp *op; +IMMND_OM_SEARCH_NODE *searchOp; +IMMND_OM_SEARCH_NODE **prevSearchOp; +IMMND_IMM_CLIENT_NODE *cl_node = +(IMMND_IMM_CLIENT_NODE *)ncs_patricia_tree_getnext(&cb->client_info_db, NULL); +int clearCounter = 0; +while(cl_node) { +if(!cl_node->mIsSync) { +clearCounter = 0; +searchOp = cl_node->searchOpList; +prevSearchOp = &cl_node->searchOpList; +while(searchOp) { +assert(searchOp->searchOp); +op = (ImmSearchOp *)searchOp->searchOp; +if(!op->isSync() && now - op->getLastSearchTime() > SEARCH_TIMEOUT_SEC) { +TRACE_2("Clear search result. Timeout %dsec. Search id: %d, OM handle: %llx", +SEARCH_TIMEOUT_SEC, searchOp->searchId, cl_node->imm_app_hdl); +*prevSearchOp = searchOp->next; +immModel_deleteSearchOp(op); +free(searchOp); +searchOp = *prevSearchOp; +clearCounter++; +} else { +prevSearchOp = &searchOp->next; +searchOp = searchOp->next; +} +} + +if(clearCounter) { +LOG_NO("Clear %d search result(s) for OM handle %llx. Search timeout %dsec", +clearCounter, cl_node->imm_app_hdl, SEARCH_TIMEOUT_SEC); +} +} + +cl_node = (IMMND_IMM_CLIENT_NODE *)ncs_patricia_tree_getnext( +&cb->client_info_db, +cl_node->patnode.key_info); +} + return stuck; } @@ -9284,6 +9325,9 @@ ImmModel::searchInitialize(ImmsvOmSearch std::string refObjectName; SaUint32T childCount=0; +/* Reset search time */ +op.updateSearchTime(); + if(scope == SA_IMM_ONE) { if(noDanglingSearch) { LOG_NO("ERR_INVALID_PARAM: SA_IMM_SEARCH_NO_DANGLING_DEPENDENTS " @@ -9293,7 +9337,7 @@ ImmModel::searchInitialize(ImmsvOmSearch return this->accessorGet(req, op); } - + size_t sz = strnlen((char *) req->rootName.buf, (size_t)req->rootName.size); std::string rootName((const char*)req->rootName.buf, sz); @@ -9723,6 +9767,9 @@ SaAisErrorT ImmModel::nextSyncResult(Imm ImmAttrValueMap::iterator j; IMMSV_OM_RSP_SEARCH_NEXT* p = NULL; +/* Reset search time */ +op.updateSearchTime(); + if((*osip) == classInfo->mExtent.end()) { delete osip; op.syncOsi = NULL; diff --git a/osaf/services/saf/immsv/immnd/ImmSearchOp.cc b/osaf/services/saf/immsv/immnd/ImmSearchOp.cc --- a/osaf/services/saf/immsv/immnd/ImmSearchOp.cc +++ b/osaf/services/saf/immsv/immnd/ImmSearchOp.cc @@ -27,6 +27,7 @@ ImmSearchOp::ImmSearchOp() syncOsi=NULL; attrNameList=NULL; classInfo=NULL; +lastSearch = 0; } ImmSearchOp::~ImmSearchOp() diff --git a/osaf/services/saf/immsv/immnd/ImmSearchOp.hh b/osaf/services/saf/immsv/immnd/ImmSearchOp.hh --- a/osaf/services/saf/immsv/immnd/ImmSearchOp.hh +++ b/osaf/services/saf/immsv/immnd/ImmSearchOp.hh @@ -22,6 +22,7 @@ #include "ImmAttrValue.hh" #include #include +#include struct SearchAttribute @@ -88,6 +89,8 @@ public: void setIsAccessor() {mIsAccessor = true;} bool isSync() {return mIsSync;} bool isAccessor() {return mIsAccessor;} +time_tgetLastSearchTime() { return lastSearch; } +void updateSearchTime() { lastSearch = time(NULL); } void* syncOsi; void* attrNameList; void* classInfo; @@ -98,6 +101,7 @@ private: AttributeList mRtsToFetch; bool mIsSync; bool mIsAccessor; +time_t lastSearch; }; #endif -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 1 of 1] IMM: release inactive search handles [#47]
osaf/services/saf/immsv/immnd/ImmModel.cc| 59 +++- osaf/services/saf/immsv/immnd/ImmSearchOp.cc | 1 + osaf/services/saf/immsv/immnd/ImmSearchOp.hh | 4 + osaf/services/saf/immsv/immnd/immnd_cb.h | 4 + 4 files changed, 67 insertions(+), 1 deletions(-) diff --git a/osaf/services/saf/immsv/immnd/ImmModel.cc b/osaf/services/saf/immsv/immnd/ImmModel.cc --- a/osaf/services/saf/immsv/immnd/ImmModel.cc +++ b/osaf/services/saf/immsv/immnd/ImmModel.cc @@ -33,6 +33,7 @@ #define PRT_LOW_THRESHOLD 1 /* See ImmModel::immNotPbeWritable */ #define PRT_HIGH_THRESHOLD 4 /* See ImmModel::immNotPbeWritable */ #define CCB_CRIT_THRESHOLD 8 /* See ImmModel::immNotPbeWritable */ +#define SEARCH_TIMEOUT_SEC 600 /* Search timeout */ struct ContinuationInfo2 @@ -968,6 +969,56 @@ immModel_cleanTheBasement(IMMND_CB *cb, osafassert(ix==(*pbePrtoReqArrSize)); } +time_t now = time(NULL); +time_t nextSearch = 0; +time_t opSearchTime; +ImmSearchOp *op; +IMMND_OM_SEARCH_NODE *searchOp; +IMMND_OM_SEARCH_NODE **prevSearchOp; +IMMND_IMM_CLIENT_NODE *cl_node = +(IMMND_IMM_CLIENT_NODE *)ncs_patricia_tree_getnext(&cb->client_info_db, NULL); +int clearCounter = 0; +while(cl_node) { +if(!cl_node->mIsSync && cl_node->searchOpList +&& (now - cl_node->mLastSearch > SEARCH_TIMEOUT_SEC)) { +nextSearch = now; +clearCounter = 0; +searchOp = cl_node->searchOpList; +prevSearchOp = &cl_node->searchOpList; +while(searchOp) { +osafassert(searchOp->searchOp); +op = (ImmSearchOp *)searchOp->searchOp; +opSearchTime = op->getLastSearchTime(); +if(!op->isSync() && now - opSearchTime > SEARCH_TIMEOUT_SEC) { +TRACE_2("Clear search result. Timeout %dsec. Search id: %d, OM handle: %llx", +SEARCH_TIMEOUT_SEC, searchOp->searchId, cl_node->imm_app_hdl); +*prevSearchOp = searchOp->next; +immModel_deleteSearchOp(op); +free(searchOp); +searchOp = *prevSearchOp; +clearCounter++; +} else { +if(opSearchTime < nextSearch) { + nextSearch = opSearchTime; +} +prevSearchOp = &searchOp->next; +searchOp = searchOp->next; +} +} + +cl_node->mLastSearch = nextSearch; + +if(clearCounter) { +LOG_NO("Clear %d search result(s) for OM handle %llx. Search timeout %dsec", +clearCounter, cl_node->imm_app_hdl, SEARCH_TIMEOUT_SEC); +} +} + +cl_node = (IMMND_IMM_CLIENT_NODE *)ncs_patricia_tree_getnext( +&cb->client_info_db, +cl_node->patnode.key_info); +} + return stuck; } @@ -1281,6 +1332,9 @@ immModel_nextResult(IMMND_CB *cb, void* } err = ImmModel::instance(&cb->immModel)->nextSyncResult(rsp, *op); } else { +/* Reset search time */ +op->updateSearchTime(); + err = op->nextResult(rsp, implConn, implNodeId, (rtAttrsToFetch)?(&rtAttrs):NULL, (SaUint64T*) implDest); @@ -9284,6 +9338,9 @@ ImmModel::searchInitialize(ImmsvOmSearch std::string refObjectName; SaUint32T childCount=0; +/* Reset search time */ +op.updateSearchTime(); + if(scope == SA_IMM_ONE) { if(noDanglingSearch) { LOG_NO("ERR_INVALID_PARAM: SA_IMM_SEARCH_NO_DANGLING_DEPENDENTS " @@ -9293,7 +9350,7 @@ ImmModel::searchInitialize(ImmsvOmSearch return this->accessorGet(req, op); } - + size_t sz = strnlen((char *) req->rootName.buf, (size_t)req->rootName.size); std::string rootName((const char*)req->rootName.buf, sz); diff --git a/osaf/services/saf/immsv/immnd/ImmSearchOp.cc b/osaf/services/saf/immsv/immnd/ImmSearchOp.cc --- a/osaf/services/saf/immsv/immnd/ImmSearchOp.cc +++ b/osaf/services/saf/immsv/immnd/ImmSearchOp.cc @@ -27,6 +27,7 @@ ImmSearchOp::ImmSearchOp() syncOsi=NULL; attrNameList=NULL; classInfo=NULL; +mLastSearch = 0; } ImmSearchOp::~ImmSearchOp() diff --git a/osaf/services/saf/immsv/immnd/ImmSearchOp.hh b/osaf/services/saf/immsv/immnd/ImmSearchOp.hh --- a/osaf/services/saf/immsv/immnd/ImmSearchOp.hh +++ b/osaf/services/saf/immsv/immnd/ImmSearchOp.hh @@ -22,6 +22,7 @@ #include "ImmAttrValue.hh" #include #include +#include struct SearchAttribute @@ -88,6 +89,8 @@ public: void setIsAccessor() {mIsAccessor = true;} bool isSync() {return mIsSync;} bool isAccessor() {return mIsAccessor;} +time_tgetLastSearchTime() { return mLastSearch; } +void updateSearchTime() { mLastSearch = time
Re: [devel] [PATCH 1 of 1] IMM: release inactive search handles [#47]
Hi Zoran, One comment I have is that op.updateSearchTime() is done in ImmModel::searchInitialize() and in ImmModel::nextSyncResult(). But I think it needs to be done also in ImmSearchOp::nextResult(). nextSyncResult is only relevant for sync iterations. But you want to refresh That timer also for regular iterartions. Other than that it is ACK from me. /AndersBj -Original Message- From: Zoran Milinkovic [mailto:zoran.milinko...@ericsson.com] Sent: den 28 mars 2014 15:02 To: reddy.neelaka...@oracle.com Cc: opensaf-devel@lists.sourceforge.net Subject: [devel] [PATCH 1 of 1] IMM: release inactive search handles [#47] osaf/services/saf/immsv/immnd/ImmModel.cc| 49 +++- osaf/services/saf/immsv/immnd/ImmSearchOp.cc | 1 + osaf/services/saf/immsv/immnd/ImmSearchOp.hh | 4 ++ 3 files changed, 53 insertions(+), 1 deletions(-) diff --git a/osaf/services/saf/immsv/immnd/ImmModel.cc b/osaf/services/saf/immsv/immnd/ImmModel.cc --- a/osaf/services/saf/immsv/immnd/ImmModel.cc +++ b/osaf/services/saf/immsv/immnd/ImmModel.cc @@ -33,6 +33,7 @@ #define PRT_LOW_THRESHOLD 1 /* See ImmModel::immNotPbeWritable */ #define PRT_HIGH_THRESHOLD 4 /* See ImmModel::immNotPbeWritable */ #define CCB_CRIT_THRESHOLD 8 /* See ImmModel::immNotPbeWritable */ +#define SEARCH_TIMEOUT_SEC 600 /* Search timeout */ struct ContinuationInfo2 @@ -968,6 +969,46 @@ immModel_cleanTheBasement(IMMND_CB *cb, osafassert(ix==(*pbePrtoReqArrSize)); } +time_t now = time(NULL); +ImmSearchOp *op; +IMMND_OM_SEARCH_NODE *searchOp; +IMMND_OM_SEARCH_NODE **prevSearchOp; +IMMND_IMM_CLIENT_NODE *cl_node = +(IMMND_IMM_CLIENT_NODE *)ncs_patricia_tree_getnext(&cb->client_info_db, NULL); +int clearCounter = 0; +while(cl_node) { +if(!cl_node->mIsSync) { +clearCounter = 0; +searchOp = cl_node->searchOpList; +prevSearchOp = &cl_node->searchOpList; +while(searchOp) { +assert(searchOp->searchOp); +op = (ImmSearchOp *)searchOp->searchOp; +if(!op->isSync() && now - op->getLastSearchTime() > SEARCH_TIMEOUT_SEC) { +TRACE_2("Clear search result. Timeout %dsec. Search id: %d, OM handle: %llx", +SEARCH_TIMEOUT_SEC, searchOp->searchId, cl_node->imm_app_hdl); +*prevSearchOp = searchOp->next; +immModel_deleteSearchOp(op); +free(searchOp); +searchOp = *prevSearchOp; +clearCounter++; +} else { +prevSearchOp = &searchOp->next; +searchOp = searchOp->next; +} +} + +if(clearCounter) { +LOG_NO("Clear %d search result(s) for OM handle %llx. Search timeout %dsec", +clearCounter, cl_node->imm_app_hdl, SEARCH_TIMEOUT_SEC); +} +} + +cl_node = (IMMND_IMM_CLIENT_NODE *)ncs_patricia_tree_getnext( +&cb->client_info_db, +cl_node->patnode.key_info); +} + return stuck; } @@ -9284,6 +9325,9 @@ ImmModel::searchInitialize(ImmsvOmSearch std::string refObjectName; SaUint32T childCount=0; +/* Reset search time */ +op.updateSearchTime(); + if(scope == SA_IMM_ONE) { if(noDanglingSearch) { LOG_NO("ERR_INVALID_PARAM: SA_IMM_SEARCH_NO_DANGLING_DEPENDENTS " @@ -9293,7 +9337,7 @@ ImmModel::searchInitialize(ImmsvOmSearch return this->accessorGet(req, op); } - + size_t sz = strnlen((char *) req->rootName.buf, (size_t)req->rootName.size); std::string rootName((const char*)req->rootName.buf, sz); @@ -9723,6 +9767,9 @@ SaAisErrorT ImmModel::nextSyncResult(Imm ImmAttrValueMap::iterator j; IMMSV_OM_RSP_SEARCH_NEXT* p = NULL; +/* Reset search time */ +op.updateSearchTime(); + if((*osip) == classInfo->mExtent.end()) { delete osip; op.syncOsi = NULL; diff --git a/osaf/services/saf/immsv/immnd/ImmSearchOp.cc b/osaf/services/saf/immsv/immnd/ImmSearchOp.cc --- a/osaf/services/saf/immsv/immnd/ImmSearchOp.cc +++ b/osaf/services/saf/immsv/immnd/ImmSearchOp.cc @@ -27,6 +27,7 @@ ImmSearchOp::ImmSearchOp() syncOsi=NULL; attrNameList=NULL; classInfo=NULL; +lastSearch = 0; } ImmSearchOp::~ImmSearchOp() diff --git a/osaf/services/saf/immsv/immnd/ImmSearchOp.hh b/osaf/services/saf/immsv/immnd/ImmSearchOp.hh --- a/osaf/services/saf/immsv/immnd/ImmSearchOp.hh +++ b/osaf/services/saf/immsv/immnd/ImmSearchOp.hh @@ -22,6 +22,7 @@ #include "ImmAttrValue.hh" #include #include +#include struct SearchAttribute @@ -88,6 +89,8 @@ public: void setIsAccessor() {mI