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 <string> #include <list> +#include <time.h> struct SearchAttribute @@ -88,6 +89,8 @@ public: void setIsAccessor() {mIsAccessor = true;} bool isSync() {return mIsSync;} bool isAccessor() {return mIsAccessor;} + time_t getLastSearchTime() { return mLastSearch; } + void updateSearchTime() { mLastSearch = time(NULL); } void* syncOsi; void* attrNameList; void* classInfo; @@ -98,6 +101,7 @@ private: AttributeList mRtsToFetch; bool mIsSync; bool mIsAccessor; + time_t mLastSearch; }; #endif diff --git a/osaf/services/saf/immsv/immnd/immnd_cb.h b/osaf/services/saf/immsv/immnd/immnd_cb.h --- a/osaf/services/saf/immsv/immnd/immnd_cb.h +++ b/osaf/services/saf/immsv/immnd/immnd_cb.h @@ -68,6 +68,10 @@ typedef struct immnd_immom_client_node { The tmp client is then removed, anticipating a resurrect request by the IMMA. */ + time_t mLastSearch; /* Time of the latest used search handle + It is used to reduce number of iterations + of inactive search handles. + */ } IMMND_IMM_CLIENT_NODE; /****************************************************************************** ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel