[support#1497929] CLL: Filetr free busy queue overindexing bugfix in DsRestAPI

Change-Id: I1f8ab09744b342c94112faa057453fc24d624484
Signed-off-by: Tamas Levente Kiss <tamas.levente.kiss@ericsson.com>
diff --git a/src/DsRestAPI/EPTF_CLL_DsRestAPI_DSServer_Functions.ttcn b/src/DsRestAPI/EPTF_CLL_DsRestAPI_DSServer_Functions.ttcn
index 9856779..ed6a4e2 100644
--- a/src/DsRestAPI/EPTF_CLL_DsRestAPI_DSServer_Functions.ttcn
+++ b/src/DsRestAPI/EPTF_CLL_DsRestAPI_DSServer_Functions.ttcn
@@ -633,13 +633,13 @@
       pl_parentList[vl_nextParent] := pl_contentToInsert.node.val;
       pl_parentIndexList[vl_nextParent] := 0;
       v_DsRestAPI_DSServer_requestHandlerDB[v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId].outstandingRequests := v_DsRestAPI_DSServer_requestHandlerDB[v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId].outstandingRequests + 1;
-      f_EPTF_DsRestAPI_Filter_evaluateFilter({{pl_transactionid}, pl_filter, refers(f_EPTF_DsRestAPI_DSServer_postFilterEvaluated), v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId}, pl_parentList, pl_parentIndexList);
+      f_EPTF_DsRestAPI_Filter_evaluateFilter({{pl_transactionid, 0, v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId}, pl_filter, refers(f_EPTF_DsRestAPI_DSServer_postFilterEvaluated), v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId, false}, pl_parentList, pl_parentIndexList);
     } else /*if (ischosen(pl_contentToInsert.list))*/ {
       for (var integer i := 0; i < vl_counter; i := i + 1) {
         pl_parentList[vl_nextParent] := pl_contentToInsert.list[i].node.val;
         pl_parentIndexList[vl_nextParent] := i;
         v_DsRestAPI_DSServer_requestHandlerDB[v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId].outstandingRequests := v_DsRestAPI_DSServer_requestHandlerDB[v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId].outstandingRequests + 1;
-        f_EPTF_DsRestAPI_Filter_evaluateFilter({{pl_transactionid, i}, pl_filter, refers(f_EPTF_DsRestAPI_DSServer_postFilterEvaluated), v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId}, pl_parentList, pl_parentIndexList);
+        f_EPTF_DsRestAPI_Filter_evaluateFilter({{pl_transactionid, i, v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId}, pl_filter, refers(f_EPTF_DsRestAPI_DSServer_postFilterEvaluated), v_DsRestAPI_DSServer_responseHandlerDB[pl_transactionid].requestId, false}, pl_parentList, pl_parentIndexList);
       }
     }
   }
@@ -839,7 +839,7 @@
       } else /*if (ischosen(pl_getData.filter.request))*/ {
         v_DsRestAPI_DSServer_requestHandlerDB[v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].requestId].outstandingRequests := v_DsRestAPI_DSServer_requestHandlerDB[v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].requestId].outstandingRequests + 1;
         v_DsRestAPI_DSServer_filterItemsDB[pl_userData[0]] := {preFilterItem := {requestToSend := pl_getData}};
-        f_EPTF_DsRestAPI_Filter_evaluateFilter({pl_userData, pl_getData.filter, refers(f_EPTF_DsRestAPI_DSServer_preFilterEvaluated), v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].requestId}, v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].parentList, v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].parentIndexList);
+        f_EPTF_DsRestAPI_Filter_evaluateFilter({{pl_userData[0], 0, v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].requestId}, pl_getData.filter, refers(f_EPTF_DsRestAPI_DSServer_preFilterEvaluated), v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].requestId, false}, v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].parentList, v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].parentIndexList);
         return;
       }
       v_DsRestAPI_DSServer_responseHandlerDB[pl_userData[0]].checkPostFilter := false;
@@ -1134,6 +1134,7 @@
           };
           v_DsRestAPI_DSServer_requestHandlerDB[vl_id].requests := {};
           v_DsRestAPI_DSServer_requestHandlerDB[vl_id].outstandingRequests := -v_DsRestAPI_DSServer_requestHandlerDB[vl_id].outstandingRequests;
+          setTimedOutRequest(vl_id);
         }
       };
 
diff --git a/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Definitions.ttcn b/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Definitions.ttcn
index b105a51..4aea43d 100644
--- a/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Definitions.ttcn
+++ b/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Definitions.ttcn
@@ -174,7 +174,8 @@
     EPTF_IntegerList userData,
     EPTF_DsRestAPI_Filter filter,
     fcb_EPTF_DsRestAPI_FilterEvaluatedCallback filterEvaluatedCallback,
-    integer storageId
+    integer storageId,
+    boolean requestTimedOut
   }
   
   ///////////////////////////////////////////////////////////////////////////////
diff --git a/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Functions.ttcn b/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Functions.ttcn
index 2a8cd12..5e2e67c 100644
--- a/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Functions.ttcn
+++ b/src/DsRestAPI/EPTF_CLL_DsRestAPI_Filter_Functions.ttcn
@@ -117,6 +117,10 @@
   }
   
   private function f_EPTF_DsRestAPI_Filter_filterResponseArrived(in integer pl_errorCode, in EPTF_Var_DirectContent pl_dataValue, in EPTF_IntegerList pl_userData) runs on EPTF_DsRestAPI_Filter_CT {
+    if (v_DsRestAPI_Filter_filtersToBeEvaluatedDB[v_DsRestAPI_Filter_outstandingFiltersDB[pl_userData[0]].filterId].requestTimedOut == true) { 
+      v_DsRestAPI_Filter_outstandingFiltersDB[pl_userData[0]].storageKey := ""
+    }
+
     var EPTF_IntegerList vl_filterPath := v_DsRestAPI_Filter_outstandingFiltersDB[pl_userData[0]].filterPath;
     var charstring vl_replacement := f_EPTF_Var_directContent2str(pl_dataValue);
     if (pl_errorCode != 0) {
@@ -161,10 +165,13 @@
   }
   
   private function f_EPTF_DsRestAPI_Filter_sendFilterRequest(in integer pl_filterId, in EPTF_IntegerList pl_filterPath, in EPTF_DsRestAPI_Filter pl_filter) runs on EPTF_DsRestAPI_Filter_CT {
-    
     var integer vl_filterRequestId := f_EPTF_FBQ_getOrCreateFreeSlot(v_DsRestAPI_Filter_outstandingFiltersQueue);
     f_EPTF_FBQ_moveFromFreeHeadToBusyTail(v_DsRestAPI_Filter_outstandingFiltersQueue);
     v_DsRestAPI_Filter_outstandingFiltersDB[vl_filterRequestId] := {pl_filterId, pl_filterPath, ""};
+
+    if (v_DsRestAPI_Filter_filtersToBeEvaluatedDB[pl_filterId].requestTimedOut) {
+        f_EPTF_DsRestAPI_Filter_filterResponseArrived(0, {boolVal:= false}, {vl_filterRequestId});
+    }
     
     var EPTF_DataSource_Params vl_params := {};
     if (ispresent(pl_filter.request.params)) {
@@ -243,6 +250,15 @@
       }
     }
   }
+
+  friend function setTimedOutRequest(integer pl_requestID) runs on EPTF_DsRestAPI_Filter_CT {
+    var integer vl_size := sizeof(v_DsRestAPI_Filter_filtersToBeEvaluatedDB);
+      for (var integer i := 0; i < vl_size; i := i + 1) {
+          if (isbound(v_DsRestAPI_Filter_filtersToBeEvaluatedDB[i]) and v_DsRestAPI_Filter_filtersToBeEvaluatedDB[i].userData[2] == pl_requestID) {
+              v_DsRestAPI_Filter_filtersToBeEvaluatedDB[i].requestTimedOut := true;
+          }
+      }
+  }
   
   friend function f_EPTF_DsRestAPI_Filter_isPreFilterAllowed(in EPTF_DsRestAPI_Filter pl_filter, in integer pl_index) return boolean {
     var charstring vl_parentN := "%Parent" & int2str(pl_index) & "%";