src/mds/apitest/mdstipc.h      |    3 +-
 src/mds/apitest/mdstipc_api.c  |  288 ++++++++++++++++++++--------------------
 src/mds/apitest/mdstipc_conf.c |   42 ++---
 3 files changed, 163 insertions(+), 170 deletions(-)


mdstest leak in many cases because of:
- incorrect use of input param
- wrong test sequence (cacel subscription after uninstall)
- malloc then terminate thread (cannot reach free)
- missing free on receiving message (used global pointer)
- encode wrong message length

action: fix above cases

diff --git a/src/mds/apitest/mdstipc.h b/src/mds/apitest/mdstipc.h
--- a/src/mds/apitest/mdstipc.h
+++ b/src/mds/apitest/mdstipc.h
@@ -1,6 +1,7 @@
 /*          OpenSAF
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright Ericsson AB 2017 - All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -206,7 +207,7 @@ uint32_t destroy_pwe_on_vdest(MDS_HDL);
 
 /**************     USER DEFINED WRAPPERS FOR MDS SERVICE APIs **************/
 
-uint32_t tet_create_task(NCS_OS_CB ,NCSCONTEXT );
+uint32_t tet_create_task(NCS_OS_CB ,NCSCONTEXT *);
 uint32_t tet_release_task(void *task_handle);
 int is_adest_sel_obj_found(int );
 int is_sel_obj_found(int);
diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
--- a/src/mds/apitest/mdstipc_api.c
+++ b/src/mds/apitest/mdstipc_api.c
@@ -395,7 +395,7 @@ void  tet_svc_install_tp_10()
   printf("\nTest case 10:Installing the External MIN service EXTMIN in a 
seperate thread and Uninstalling it here\n");
   //Install thread
   rc = tet_create_task((NCS_OS_CB)tet_vdest_install_thread,
-                       gl_tet_vdest[0].svc[0].task.t_handle);
+                       &gl_tet_vdest[0].svc[0].task.t_handle);
   if (rc !=  NCSCC_RC_SUCCESS) {
     printf("\nFail to Install thread\n");
     FAIL = 1;
@@ -403,9 +403,8 @@ void  tet_svc_install_tp_10()
 
   //Now Release the Install Thread
   rc = tet_release_task(gl_tet_vdest[0].svc[0].task.t_handle);
-  if (rc !=  NCSCC_RC_SUCCESS) {
-    printf("\nFail to release thread\n");
-    FAIL = 1;
+  if (rc ==  NCSCC_RC_SUCCESS) {
+    printf("\nTask released\n");
   }
 
   //Counter shall be != 0
@@ -843,7 +842,7 @@ void  tet_svc_install_tp_17()
 void tet_vdest_uninstall_thread()
 {
   // Inside Thread
-  printf("tet_vdest_uninstall_thread\n");
+  printf("\ntet_vdest_uninstall_thread\n");
   test_validate(mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl,500), 
                NCSCC_RC_SUCCESS);
 }
@@ -1009,7 +1008,7 @@ void tet_svc_unstall_tp_5()
   //Uninstalling the above service in a seperate thread
   //Uninstall thread
   rc = tet_create_task((NCS_OS_CB)tet_vdest_uninstall_thread,
-                       gl_tet_vdest[0].svc[0].task.t_handle);
+                       &gl_tet_vdest[0].svc[0].task.t_handle);
   if (rc !=  NCSCC_RC_SUCCESS) {
     printf("\nFail to create the uninstall thread\n");
     FAIL = 1;
@@ -1018,8 +1017,8 @@ void tet_svc_unstall_tp_5()
 
   //Now Release the Uninstall Thread
   rc = tet_release_task(gl_tet_vdest[0].svc[0].task.t_handle);
-  if (rc !=  NCSCC_RC_SUCCESS) {
-    printf("\nFail to release the uninstall thread\n");
+  if (rc ==  NCSCC_RC_SUCCESS) {
+    printf("\nTask released\n");
     FAIL = 1;
   }
 
@@ -1833,16 +1832,6 @@ void tet_svc_subscr_VDEST_10()
     FAIL = 1;
   }
 
-  printf("\tUninstalling 600 and 700\n");
-  for(id=600;id<=700;id=id+100)
-  {
-    if(  
mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl,id)!=NCSCC_RC_SUCCESS)
-    {
-      printf("\nFail to uninstall service %d\n", id);
-      FAIL = 1;
-    }
-  }
-
   //Cancelling the subscription
   if(mds_service_cancel_subscription(gl_tet_adest.mds_pwe1_hdl,500,2,
                                      svcids)!=NCSCC_RC_SUCCESS)
@@ -1850,6 +1839,17 @@ void tet_svc_subscr_VDEST_10()
     printf("\nFail cancel subscription 500\n");
     FAIL = 1;
   }
+
+  printf("\tUninstalling 600 and 700\n");
+  for(id=600;id<=700;id=id+100)
+  {
+    if(  
mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl,id)!=NCSCC_RC_SUCCESS)
+    {
+      printf("\nFail to uninstall service %d\n", id);
+      FAIL = 1;
+    }
+  }
+
   if(  mds_service_uninstall(gl_tet_adest.mds_pwe1_hdl,500)!=NCSCC_RC_SUCCESS)
   {
     printf("\nFail to uninstall service 500\n");
@@ -2123,17 +2123,6 @@ void tet_svc_subscr_VDEST_12()
     FAIL=1;
   }
 
-  printf("\nAction: Uninstalling 600 \n");
-  for(i=0; i<=1;i++)
-  {
-    if(  
mds_service_uninstall(gl_tet_vdest[i].mds_pwe1_hdl,600)!=NCSCC_RC_SUCCESS)
-
-    {
-      printf("\nFail\n");
-      FAIL=1;
-    }
-  } 
-
   printf("\nAction: Cancelling the subscription\n");
   if(mds_service_cancel_subscription(gl_tet_adest.mds_pwe1_hdl,500,1,
                                      svc_id_sixhd)!=NCSCC_RC_SUCCESS)
@@ -2141,6 +2130,17 @@ void tet_svc_subscr_VDEST_12()
     printf("\nFail\n");
     FAIL=1;
   }
+
+  printf("\nAction: Uninstalling 600 \n");
+  for(i=0; i<=1;i++)
+  {
+    if(  
mds_service_uninstall(gl_tet_vdest[i].mds_pwe1_hdl,600)!=NCSCC_RC_SUCCESS)
+
+    {
+      printf("\nFail\n");
+      FAIL=1;
+    }
+  }
   if(  mds_service_uninstall(gl_tet_adest.mds_pwe1_hdl,500)!=NCSCC_RC_SUCCESS)
   {
     printf("\nFail\n");
@@ -2537,7 +2537,7 @@ void tet_svc_subscr_ADEST_8()
     }
     printf("\nAction: Cancel in a seperate thread\n");
     if(tet_create_task((NCS_OS_CB)tet_adest_cancel_thread,
-                       gl_tet_adest.svc[0].task.t_handle)
+                       &gl_tet_adest.svc[0].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -2650,7 +2650,7 @@ void tet_svc_subscr_ADEST_10()
     printf("\nAction: Retrieve in a seperate thread\n");
     /*Retrieve thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_retrieve_thread,
-                       gl_tet_adest.svc[0].task.t_handle)
+                       &gl_tet_adest.svc[0].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -5069,11 +5069,6 @@ void tet_adest_rcvr_svc_thread()
 {
   MDS_SVC_ID svc_id;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));   
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
   
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_adest_sel_obj_found(0)) )
@@ -5088,6 +5083,11 @@ void tet_adest_rcvr_svc_thread()
     /*after that send a response to the sender, if it expects*/ 
     if(gl_rcvdmsginfo.rsp_reqd)
     {
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       if(mds_send_response(gl_tet_adest.mds_pwe1_hdl,
                            NCSMDS_SVC_ID_EXTERNAL_MIN,
                            mesg)!=NCSCC_RC_SUCCESS)
@@ -5097,21 +5097,15 @@ void tet_adest_rcvr_svc_thread()
       else
         printf("Response Success\n");
       gl_rcvdmsginfo.rsp_reqd=0;
-    }
-  }
-
-  free(mesg);
+      free(mesg);
+    }
+  }
 }
 
 void tet_vdest_rcvr_resp_thread()
 {
   MDS_SVC_ID svc_id;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);    
   
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_vdest_sel_obj_found(1,1)) )
@@ -5124,6 +5118,11 @@ void tet_vdest_rcvr_resp_thread()
     /*after that send a response to the sender, if it expects*/ 
     if(gl_rcvdmsginfo.rsp_reqd)
     {
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       if(mds_send_response(gl_tet_vdest[1].mds_pwe1_hdl,
                            NCSMDS_SVC_ID_EXTERNAL_MIN,
                            mesg)!=NCSCC_RC_SUCCESS)
@@ -5132,11 +5131,9 @@ void tet_vdest_rcvr_resp_thread()
       }
       else
         printf("Response Success\n");
-
-    }
-  }
-
-  free(mesg);
+        free(mesg);
+    }
+  }
 }
 
 void tet_send_response_tp_1()
@@ -5179,7 +5176,7 @@ void tet_send_response_tp_1()
     printf("\nTest Case 1: Svc INTMIN on PWE=2 of ADEST sends a LOW  Priority 
message to Svc NCSMDS_SVC_ID_EXTERNAL_MIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created");fflush(stdout);
@@ -5203,7 +5200,7 @@ void tet_send_response_tp_1()
     {
       printf("\tTASK is released\n");
     }
-    fflush(stdout);                
+    fflush(stdout);
     if(mds_service_cancel_subscription(gl_tet_adest.pwe[0].mds_pwe_hdl,
                                        NCSMDS_SVC_ID_INTERNAL_MIN,1,
                                        svcids)!=NCSCC_RC_SUCCESS)
@@ -5264,7 +5261,7 @@ void tet_send_response_tp_2()
     printf("\nTest Case 2: Svc INTMIN on PWE=2 of ADEST sends a MEDIUM 
Priority message to Svc EXTMIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -5349,7 +5346,7 @@ void tet_send_response_tp_3()
     printf("\nTest Case 3: Svc INTMIN on Active VEST=200 sends a HIGH Priority 
message to Svc EXTERNAL_MIN on ADEST and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_svc_thread,
-                       gl_tet_adest.svc[0].task.t_handle)
+                       &gl_tet_adest.svc[0].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -5432,7 +5429,7 @@ void tet_send_response_tp_4()
     printf("\nTest Case 4: Svc EXTMIN of ADEST sends a VERYHIGH Priority 
message to Svc EXTMIN on Active Vdest=200 and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_resp_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -5517,7 +5514,7 @@ void tet_send_response_tp_5()
     printf("\nTest Case 5: While Await ActiveTimer ON:SvcEXTMIN of ADEST sends 
a message to Svc EXTMIN on Active Vdest=200 and Times out\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_resp_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -5614,7 +5611,7 @@ void tet_send_response_tp_6()
     printf("\nTest Case 6: Svc EXTMIN of ADEST sends a VERYHIGH Priority 
message to Svc EXTMIN on QUIESCED Vdest=200 and Times out\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_resp_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -5695,7 +5692,7 @@ void tet_send_response_tp_7()
     printf("\nTest Case 7: Implicit Subscription:Svc INTMIN on PWE=2 of ADEST 
sends a LOW Priority message to Svc EXTMIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -5738,7 +5735,7 @@ void tet_send_response_tp_7()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -5952,7 +5949,7 @@ void tet_send_response_tp_11()
     mesg->send_len=2*MSG_SIZE+2;
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -6018,7 +6015,7 @@ TODO: Check this testcase, it was outcom
     {
       /*Receiver thread*/
       if(tet_create_task((NCS_OS_CB)tet_adest_rcvr_thread,
-                         gl_tet_adest.svc[2].task.t_handle)
+                         &gl_tet_adest.svc[2].task.t_handle)
          ==NCSCC_RC_SUCCESS )
       {
         printf("\tTask has been Created\n");fflush(stdout);
@@ -6058,11 +6055,6 @@ void tet_vdest_rcvr_thread()
 {
   MDS_SVC_ID svc_id;
   char tmp[]=" Yes Sender! I am in. Message Delivered?";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);    
 
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_vdest_sel_obj_found(1,1)) )
@@ -6076,6 +6068,11 @@ void tet_vdest_rcvr_thread()
     /*after that send a response to the sender, if it expects*/ 
     if(gl_rcvdmsginfo.rsp_reqd)
     {
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       if(mds_sendrsp_getack(gl_tet_vdest[1].mds_pwe1_hdl,
                             NCSMDS_SVC_ID_EXTERNAL_MIN,0,
                             mesg)!=NCSCC_RC_SUCCESS)
@@ -6085,6 +6082,7 @@ void tet_vdest_rcvr_thread()
       else
         printf("Response Ack Success\n");
       gl_rcvdmsginfo.rsp_reqd=0;
+      free(mesg);
       /*if(mds_send_redrsp_getack(gl_tet_vdest[1].mds_pwe1_hdl,
         2000,300)!=NCSCC_RC_SUCCESS)
         {      printf("Response Fail\n");FAIL=1;    }
@@ -6093,18 +6091,11 @@ void tet_vdest_rcvr_thread()
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 
 void tet_Dadest_all_rcvr_thread()
 {
   MDS_SVC_ID svc_id;
-  char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
 
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_adest_sel_obj_found(1)) )
@@ -6135,7 +6126,6 @@ void tet_Dadest_all_rcvr_thread()
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 
 /*Adest sending direct response to vdest*/
@@ -6184,11 +6174,6 @@ void tet_adest_all_chgrole_rcvr_thread()
 {
   MDS_SVC_ID svc_id;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
 
   printf("\nInside CHG ROLE ADEST Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_adest_sel_obj_found(1)) )
@@ -6210,11 +6195,17 @@ void tet_adest_all_chgrole_rcvr_thread()
         {
           printf("\nFail\n");
         }
+        TET_MDS_MSG *mesg;
+        mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+        memset(mesg, 0, sizeof(TET_MDS_MSG));
+        memcpy(mesg->send_data,tmp,sizeof(tmp));
+        mesg->send_len=sizeof(tmp);
         if(mds_send_response(gl_tet_adest.mds_pwe1_hdl,
                              
NCSMDS_SVC_ID_EXTERNAL_MIN,mesg)!=NCSCC_RC_SUCCESS)
         {
           printf("\nFail\n");
         }
+        free(mesg);
 
                
         sleep(10);
@@ -6228,17 +6219,11 @@ void tet_adest_all_chgrole_rcvr_thread()
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 void tet_vdest_all_rcvr_thread()
 {
   MDS_SVC_ID svc_id;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
 
   printf("\nInside VDEST  Receiver Thread\n");fflush(stdout);
   sleep(10);
@@ -6260,27 +6245,27 @@ void tet_vdest_all_rcvr_thread()
     /*after that send a response to the sender, if it expects*/
     if(gl_rcvdmsginfo.rsp_reqd)
     {
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       if(mds_send_response(gl_tet_vdest[1].mds_pwe1_hdl,
                            NCSMDS_SVC_ID_EXTERNAL_MIN,mesg)!=NCSCC_RC_SUCCESS)
       {
         printf("\nFail\n");
       }
       gl_rcvdmsginfo.rsp_reqd=0;
+      free(mesg);
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 void tet_adest_all_rcvrack_thread()
 {
   MDS_SVC_ID svc_id;
   uint32_t rs;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
 
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_adest_sel_obj_found(1)) )
@@ -6300,15 +6285,20 @@ void tet_adest_all_rcvrack_thread()
         printf("\nFail\n");
       }
 
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       rs=mds_sendrsp_getack(gl_tet_adest.mds_pwe1_hdl, 
NCSMDS_SVC_ID_EXTERNAL_MIN,
                             0,mesg);
                
       printf("\nResponse code is %d",rs);
       gl_rcvdmsginfo.rsp_reqd=0;
+      free(mesg);
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 
 void tet_adest_all_rcvrack_chgrole_thread()
@@ -6316,11 +6306,6 @@ void tet_adest_all_rcvrack_chgrole_threa
   MDS_SVC_ID svc_id;
   uint32_t rs;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
 
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_adest_sel_obj_found(1)) )
@@ -6340,13 +6325,19 @@ void tet_adest_all_rcvrack_chgrole_threa
         printf("\nFail\n");
       }
       if(tet_create_task((NCS_OS_CB)tet_adest_all_chgrole_rcvr_thread,
-                         gl_tet_adest.svc[1].task.t_handle)
+                         &gl_tet_adest.svc[1].task.t_handle)
          == NCSCC_RC_SUCCESS )
       {
         printf("\tTask has been Created\n");fflush(stdout); 
       }
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       rs=mds_sendrsp_getack(gl_tet_adest.mds_pwe1_hdl, 
NCSMDS_SVC_ID_EXTERNAL_MIN,
                             0,mesg);
+      free(mesg);
       if(tet_release_task(gl_tet_adest.svc[1].task.t_handle)
          ==NCSCC_RC_SUCCESS)
         printf("\tTASK is released\n");
@@ -6357,7 +6348,6 @@ void tet_adest_all_rcvrack_chgrole_threa
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 
 void tet_Dadest_all_rcvrack_chgrole_thread()
@@ -6383,7 +6373,7 @@ void tet_Dadest_all_rcvrack_chgrole_thre
         printf("\nFail\n");
       }
       if(tet_create_task((NCS_OS_CB)tet_adest_all_chgrole_rcvr_thread,
-                         gl_tet_adest.svc[1].task.t_handle)== NCSCC_RC_SUCCESS 
)
+                         &gl_tet_adest.svc[1].task.t_handle)== 
NCSCC_RC_SUCCESS )
       {
         printf("\tTask has been Created\n");fflush(stdout);
       }
@@ -6425,11 +6415,6 @@ void tet_adest_all_rcvr_thread()
 {
   MDS_SVC_ID svc_id;
   char tmp[]=" Hi Sender! My Name is RECEIVER ";
-  TET_MDS_MSG *mesg;
-  mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
-  memset(mesg, 0, sizeof(TET_MDS_MSG));
-  memcpy(mesg->send_data,tmp,sizeof(tmp));
-  mesg->send_len=sizeof(tmp);
 
   printf("\nInside Receiver Thread\n");fflush(stdout);
   if( (svc_id=is_adest_sel_obj_found(1)) )
@@ -6448,16 +6433,21 @@ void tet_adest_all_rcvr_thread()
       {
         printf("\nFail\n");
       }
+      TET_MDS_MSG *mesg;
+      mesg = (TET_MDS_MSG*)malloc(sizeof(TET_MDS_MSG));
+      memset(mesg, 0, sizeof(TET_MDS_MSG));
+      memcpy(mesg->send_data,tmp,sizeof(tmp));
+      mesg->send_len=sizeof(tmp);
       if(mds_send_response(gl_tet_adest.mds_pwe1_hdl,
                            NCSMDS_SVC_ID_EXTERNAL_MIN,mesg)!=NCSCC_RC_SUCCESS)
       {
         printf("\nFail\n");
       }
       gl_rcvdmsginfo.rsp_reqd=0;
+      free(mesg);
     }
   }
   fflush(stdout);
-  free(mesg);
 }
 
 void tet_send_all_tp_1()
@@ -6563,7 +6553,7 @@ void tet_send_all_tp_1()
   }
 
   if(tet_create_task((NCS_OS_CB)tet_adest_all_rcvr_thread,
-                     gl_tet_adest.svc[1].task.t_handle)
+                     &gl_tet_adest.svc[1].task.t_handle)
      == NCSCC_RC_SUCCESS )
   {
     printf("\nTask has been Created\n");fflush(stdout);
@@ -6606,7 +6596,7 @@ void tet_send_all_tp_1()
   }
 
   if(tet_create_task((NCS_OS_CB)tet_adest_all_rcvrack_thread,
-                     gl_tet_adest.svc[1].task.t_handle)
+                     &gl_tet_adest.svc[1].task.t_handle)
      == NCSCC_RC_SUCCESS )
   {
     printf("\tTask has been Created\n");fflush(stdout);
@@ -6742,7 +6732,7 @@ void tet_send_all_tp_2()
   /*Create thread to change role*/
 
   if(tet_create_task((NCS_OS_CB)tet_change_role_thread,
-                     gl_tet_adest.svc[1].task.t_handle)
+                     &gl_tet_adest.svc[1].task.t_handle)
      == NCSCC_RC_SUCCESS )
   {
     printf("\nTask has been Created\n");fflush(stdout);
@@ -6787,7 +6777,7 @@ void tet_send_all_tp_2()
   else
     printf("\nSuccess\n");
   if(tet_create_task((NCS_OS_CB)tet_vdest_all_rcvr_thread,
-                     gl_tet_vdest[1].svc[1].task.t_handle)
+                     &gl_tet_vdest[1].svc[1].task.t_handle)
      == NCSCC_RC_SUCCESS )
   {
     printf("\nTask has been Created\n");fflush(stdout);
@@ -6812,7 +6802,7 @@ void tet_send_all_tp_2()
     printf("\nTASK is released\n");
   /*RSP*/
   if(tet_create_task((NCS_OS_CB)tet_adest_all_chgrole_rcvr_thread,
-                     gl_tet_adest.svc[1].task.t_handle)
+                     &gl_tet_adest.svc[1].task.t_handle)
      == NCSCC_RC_SUCCESS )
   {
     printf("\nTask has been Created\n");fflush(stdout);
@@ -6842,7 +6832,7 @@ void tet_send_all_tp_2()
   /*SNDRACK*/
 
   if(tet_create_task((NCS_OS_CB)tet_adest_all_rcvrack_chgrole_thread,
-                     gl_tet_adest.svc[1].task.t_handle)
+                     &gl_tet_adest.svc[1].task.t_handle)
      == NCSCC_RC_SUCCESS )
   {
     printf("\nTask has been Created\n");fflush(stdout);
@@ -6930,7 +6920,7 @@ void tet_send_response_ack_tp_1()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7009,7 +6999,7 @@ void tet_send_response_ack_tp_2()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7087,7 +7077,7 @@ void tet_send_response_ack_tp_3()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7165,7 +7155,7 @@ void tet_send_response_ack_tp_4()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7244,7 +7234,7 @@ void tet_send_response_ack_tp_5()
     printf("\nTest Case 5: While Await Active Timer ON:SvcEXTMIN of ADEST 
sends a message to Svc EXTMIN on Active Vdest=200 and Times out\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7336,7 +7326,7 @@ void tet_send_response_ack_tp_6()
     printf("\nTest Case 6: SvcEXTMIN of ADEST sends message to SvcEXTMIN on 
QUIESCED Vdest=200 and Times out\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7411,7 +7401,7 @@ void tet_send_response_ack_tp_7()
     printf("\nTest Case 7: Implicit Subscription: Svc EXTL_MIN on ADEST sends 
a LOWPriority message to Svc EXTMIN on VDEST=200 and expects Response\n");
     /*Receiver thread*/
     if (tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                        gl_tet_vdest[1].svc[1].task.t_handle) == 
NCSCC_RC_SUCCESS ) {
+                        &gl_tet_vdest[1].svc[1].task.t_handle) == 
NCSCC_RC_SUCCESS ) {
       printf("\tTask has been Created\n");fflush(stdout);
     }
     /*Sender */ 
@@ -7447,7 +7437,7 @@ void tet_send_response_ack_tp_7()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -7509,7 +7499,7 @@ void tet_send_response_ack_tp_8()
     mesg->send_len=2*MSG_SIZE+2;
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_vdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS ) {
       printf("\nTask has been Created\n");fflush(stdout);
     }
@@ -8806,6 +8796,8 @@ void tet_direct_just_send_tp_11()
     { printf("\nFail\n");FAIL=1;    }
     else
       printf("\nSuccess\n");
+    m_MDS_FREE_DIRECT_BUFF(direct_buff);
+    direct_buff=NULL;
 
     printf("\nCancel subscription\n");
     if(mds_service_cancel_subscription(gl_tet_adest.mds_pwe1_hdl,
@@ -9186,7 +9178,7 @@ void tet_direct_send_all_tp_1()
     /*SNDRSP*/
     printf("\nDirect send with rsp\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9212,7 +9204,7 @@ void tet_direct_send_all_tp_1()
     /*SNDRACK*/
     printf("\n Direct send with response ack\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_rack_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle) == 
NCSCC_RC_SUCCESS )
+                       &gl_tet_vdest[1].svc[1].task.t_handle) == 
NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
     }
@@ -9314,7 +9306,7 @@ void tet_direct_send_all_tp_2()
     /*SNDRSP*/
     printf("\nDirect send with rsp\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9340,7 +9332,7 @@ void tet_direct_send_all_tp_2()
     /*SNDRACK*/
     printf("\n Direct send with response ack\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_rack_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9444,7 +9436,7 @@ void tet_direct_send_all_tp_3()
     /*SNDRSP*/
     printf("\nDirect send with rsp\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9470,7 +9462,7 @@ void tet_direct_send_all_tp_3()
     /*SNDRACK*/
     printf("\n Direct send with response ack\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_rack_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9574,7 +9566,7 @@ void tet_direct_send_all_tp_4()
     /*SNDRSP*/
     printf("\nDirect send with rsp\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9600,7 +9592,7 @@ void tet_direct_send_all_tp_4()
     /*SNDRACK*/
     printf("\n Direct send with response ack\n");
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_rack_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9733,7 +9725,7 @@ void tet_direct_send_all_tp_5()
     /*Create thread to change role*/
 
     if(tet_create_task((NCS_OS_CB)tet_change_role_thread,
-                       gl_tet_adest.svc[1].task.t_handle)
+                       &gl_tet_adest.svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9779,7 +9771,7 @@ void tet_direct_send_all_tp_5()
       printf("\nSuccess\n");
 
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_chg_role_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9808,7 +9800,7 @@ void tet_direct_send_all_tp_5()
 
     /*RSP*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_all_chgrole_rcvr_thread,
-                       gl_tet_adest.svc[1].task.t_handle)
+                       &gl_tet_adest.svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -9859,7 +9851,7 @@ void tet_direct_send_all_tp_5()
     /*SNDRACK*/
 
     if(tet_create_task((NCS_OS_CB)tet_Dadest_all_rcvrack_chgrole_thread,
-                       gl_tet_adest.svc[1].task.t_handle)
+                       &gl_tet_adest.svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -10051,7 +10043,7 @@ void tet_direct_send_all_tp_6()
     }
 
     if(tet_create_task((NCS_OS_CB)tet_Dadest_all_rcvr_thread,
-                       gl_tet_adest.svc[1].task.t_handle)
+                       &gl_tet_adest.svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -10095,7 +10087,7 @@ void tet_direct_send_all_tp_6()
     }
 
     if(tet_create_task((NCS_OS_CB)tet_adest_all_rcvrack_thread,
-                       gl_tet_adest.svc[1].task.t_handle)
+                       &gl_tet_adest.svc[1].task.t_handle)
        == NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -10942,6 +10934,8 @@ void tet_direct_send_ack_tp_11()
     { printf("\nFail\n");FAIL=1;    }
     else
       printf("\nSuccess\n");
+    m_MDS_FREE_DIRECT_BUFF(direct_buff);
+    direct_buff=NULL;
 
     if(mds_service_cancel_subscription(gl_tet_adest.mds_pwe1_hdl,
                                        NCSMDS_SVC_ID_EXTERNAL_MIN,1,
@@ -11402,7 +11396,7 @@ void tet_direct_send_response_tp_1()
     printf("\nTest Case 1: Svc INTMIN on PWE=2 of ADEST sends a LOW Priority 
message to Svc EXTMIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -11485,7 +11479,7 @@ void tet_direct_send_response_tp_2()
     printf("\nTest Case 2: Svc INTMIN on PWE=2 of ADEST sends a MEDIUM 
Priority message to Svc EXTMIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -11558,7 +11552,7 @@ void tet_direct_send_response_tp_3()
     printf("\nTest Case 3: Svc INTMIN on PWE=2 of ADEST sends a HIGH Priority 
message to Svc EXTMIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -11630,7 +11624,7 @@ void tet_direct_send_response_tp_4()
     printf("\nTest Case 4: Svc INTMIN on PWE=2 of ADEST sends a VERYHIGH 
Priority message to Svc EXTMIN and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -11711,7 +11705,7 @@ void tet_direct_send_response_tp_5()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -11752,7 +11746,7 @@ void tet_direct_send_response_tp_5()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dadest_rcvr_thread,
-                       gl_tet_adest.svc[2].task.t_handle)
+                       &gl_tet_adest.svc[2].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -11832,7 +11826,7 @@ void tet_direct_send_response_ack_tp_1()
     printf("\nTest Case 1: Svc EXTMIN on ADEST sends a LOW priority message to 
Svc EXTMIN on VDEST=200 and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
@@ -11912,7 +11906,7 @@ void tet_direct_send_response_ack_tp_2()
     printf("\nTest Case 2: Svc EXTMIN on ADEST sends a MEDIUM priority message 
to Svc EXTMIN on VDEST=200 and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");
@@ -11994,7 +11988,7 @@ void tet_direct_send_response_ack_tp_3()
    
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -12073,7 +12067,7 @@ void tet_direct_send_response_ack_tp_4()
     printf("\nTest Case 4: Svc EXTMIN on ADEST sends a VERYHIGH priority  
message to Svc EXTMIN on VDEST=200 and expects a Response\n");
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -12158,7 +12152,7 @@ void tet_direct_send_response_ack_tp_5()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\tTask has been Created\n");fflush(stdout);
@@ -12198,7 +12192,7 @@ void tet_direct_send_response_ack_tp_5()
     }
     /*Receiver thread*/
     if(tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_thread,
-                       gl_tet_vdest[1].svc[1].task.t_handle)
+                       &gl_tet_vdest[1].svc[1].task.t_handle)
        ==NCSCC_RC_SUCCESS )
     {
       printf("\nTask has been Created\n");fflush(stdout);
diff --git a/src/mds/apitest/mdstipc_conf.c b/src/mds/apitest/mdstipc_conf.c
--- a/src/mds/apitest/mdstipc_conf.c
+++ b/src/mds/apitest/mdstipc_conf.c
@@ -968,7 +968,7 @@ uint32_t mds_send_get_ack(MDS_HDL mds_hd
       return NCSCC_RC_SUCCESS;
     }
   else
-    {  
+    {
       if(rs==NCSCC_RC_REQ_TIMOUT)
         {
           printf("\nMDS SEND ACK has TIMED OUT\n");
@@ -1022,6 +1022,7 @@ uint32_t mds_send_get_response(MDS_HDL m
           rsp=svc_to_mds_info.info.svc_send.info.sndrsp.o_rsp;
           printf("The response got from the receiver is : \n message length \
 = %d \n message = %s",rsp->recvd_len,rsp->recvd_data);
+          free(rsp);
         }
       return NCSCC_RC_SUCCESS;
     }
@@ -1341,26 +1342,13 @@ uint32_t mds_direct_send_message(MDS_HDL
     }
   else
     {
-      if(rs==NCSCC_RC_REQ_TIMOUT)
+      if(message)
         {
-          printf("\nRequest to ncsmds_api: MDS DIRECT SEND has TIMED OUT\n");
           /*Free the above allocated Direct Buff*/
           m_MDS_FREE_DIRECT_BUFF(direct_buff);
           direct_buff=NULL;
-          return NCSCC_RC_REQ_TIMOUT;      
         }
-      else if(rs==MDS_RC_MSG_NO_BUFFERING)
-        {
-          printf("\nRequest to ncsmds_api: MDS DIRECT SEND has failed as no 
active instance\n");
-          /*Free the above allocated Direct Buff*/
-          return MDS_RC_MSG_NO_BUFFERING;
-        }
-
-      else
-        {
-          printf("\nRequest to ncsmds_api: MDS DIRECT SEND has FAILED\n");
-          return NCSCC_RC_FAILURE;
-        }
+      return rs;
     }
 }
 
@@ -1574,7 +1562,7 @@ int is_adest_sel_obj_found(int si)
   return 0;
 }
 uint32_t tet_create_task(NCS_OS_CB task_startup,
-                      NCSCONTEXT t_handle)
+                      NCSCONTEXT* p_t_handle)
 {
   char taskname[]="MDS_Tipc test";
   int policy = SCHED_OTHER; /*root defaults */
@@ -1586,7 +1574,7 @@ uint32_t tet_create_task(NCS_OS_CB task_
                          prio_val,
                          policy,
                          NCS_STACKSIZE_MEDIUM,
-                         &t_handle) == NCSCC_RC_SUCCESS)
+                         p_t_handle) == NCSCC_RC_SUCCESS)
 
     return NCSCC_RC_SUCCESS;
   else
@@ -1819,6 +1807,9 @@ uint32_t tet_mds_cb_enc(NCSMDS_CALLBACK_
   p8 = ncs_enc_reserve_space(mds_to_svc_info->info.enc.io_uba, 2);
   ncs_encode_16bit(&p8, msg->send_len);
   ncs_enc_claim_space(mds_to_svc_info->info.enc.io_uba, 2);
+  p8 = ncs_enc_reserve_space(mds_to_svc_info->info.enc.io_uba, 2);
+  ncs_encode_16bit(&p8, msg->send_len >> 16);
+  ncs_enc_claim_space(mds_to_svc_info->info.enc.io_uba, 2);
   
   /* ENCODE data */
   ncs_encode_n_octets_in_uba(mds_to_svc_info->info.enc.io_uba, 
@@ -1855,11 +1846,15 @@ uint32_t tet_mds_cb_dec(NCSMDS_CALLBACK_
                              (uint8_t*)&msg->recvd_len, 2);
   msg->recvd_len = ncs_decode_16bit(&p8);
   ncs_dec_skip_space(mds_to_svc_info->info.dec.io_uba, 2);
+  p8 = ncs_dec_flatten_space(mds_to_svc_info->info.dec.io_uba, 
+                             (uint8_t*)&msg->recvd_len, 2);
+  msg->recvd_len += ncs_decode_16bit(&p8) << 16;
+  ncs_dec_skip_space(mds_to_svc_info->info.dec.io_uba, 2);
   
   /*Decode data*/
   /*msg->recvd_data = (char *) malloc(msg->recvd_len+1);*/
   memset(msg->recvd_data, 0, msg->recvd_len+1);
-  ncs_decode_n_octets_from_uba(mds_to_svc_info->info.dec.io_uba, 
+  ncs_decode_n_octets_from_uba(mds_to_svc_info->info.dec.io_uba,
                                (uint8_t*)msg->recvd_data, msg->recvd_len);
   msg->recvd_data[msg->recvd_len] = 0; /* NULL termination for string */
   if(mds_to_svc_info->info.dec.i_is_resp)
@@ -1885,7 +1880,7 @@ uint32_t tet_mds_cb_enc_flat (NCSMDS_CAL
   ncs_enc_claim_space(mds_to_svc_info->info.enc_flat.io_uba, 2);
   
   /* ENCODE data */
-  ncs_encode_n_octets_in_uba(mds_to_svc_info->info.enc_flat.io_uba, 
+  ncs_encode_n_octets_in_uba(mds_to_svc_info->info.enc_flat.io_uba,
                              (uint8_t*)msg->send_data, msg->send_len);
   /*
     printf("Successfully flat encoded message for Receiver svc = %d\n\n",
@@ -1936,7 +1931,7 @@ uint32_t tet_mds_cb_dec_flat (NCSMDS_CAL
 uint32_t tet_mds_cb_rcv(NCSMDS_CALLBACK_INFO *mds_to_svc_info)
 {
   /*as usal this is preceded by one of cb_cpy or cb_dec or cb_dec_flat*/
-  TET_MDS_MSG *msg;
+  TET_MDS_MSG *msg = 0;
   
   msg=mds_to_svc_info->info.receive.i_msg;
   
@@ -1962,7 +1957,10 @@ uint32_t tet_mds_cb_rcv(NCSMDS_CALLBACK_
   
   /*Now storing the message context on a global structure*/
   gl_rcvdmsginfo.yr_svc_hdl=mds_to_svc_info->i_yr_svc_hdl; /*the decider*/
-  
+  if (gl_rcvdmsginfo.msg!=0)
+    {
+      free(gl_rcvdmsginfo.msg);
+    }
   gl_rcvdmsginfo.msg=mds_to_svc_info->info.receive.i_msg;
   gl_rcvdmsginfo.rsp_reqd=mds_to_svc_info->info.receive.i_rsp_reqd;
   if(gl_rcvdmsginfo.rsp_reqd)


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to