ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r690127 [10/11] - in /webservices/sandesha/trunk/c: ./ build/win32/ config/ ides/vc8/sandesha2/sandesha2/ include/ include/sandesha2/ samples/ samples/RMSampleService/ samples/rm_echo_1_0/ samples/rm_echo_1_0_large_sequence/ samples/rm_echo...
Date Fri, 29 Aug 2008 06:56:38 GMT
Modified: webservices/sandesha/trunk/c/src/util/terminate_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/terminate_mgr.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/util/terminate_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/util/terminate_mgr.c Thu Aug 28 23:56:29 2008
@@ -29,6 +29,7 @@
 #include <sandesha2_sender_mgr.h>
 #include <sandesha2_sender_worker.h>
 #include <sandesha2_sender_bean.h>
+#include <sandesha2_msg_init.h>
 #include <axutil_string.h>
 #include <axutil_uuid_gen.h>
 #include <axis2_addr.h>
@@ -36,7 +37,12 @@
 #include <axutil_array_list.h>
 #include <axis2_engine.h>
 #include <sandesha2_msg_creator.h>
+#include <sandesha2_ack_mgr.h>
+#include <sandesha2_msg_retrans_adjuster.h>
 #include <axis2_transport_out_desc.h>
+#include <axiom_soap_const.h>
+#include <axis2_http_transport_utils.h>
+#include <axis2_core_utils.h>
 
 axutil_hash_t *sandesha2_terminate_mgr_rcv_side_clean_map = NULL;
 
@@ -44,7 +50,7 @@
 sandesha2_terminate_mgr_clean_sending_side_data(
     const axutil_env_t *env,
     axis2_conf_ctx_t *conf_ctx,
-    axis2_char_t *seq_id,
+    axis2_char_t *internal_sequence_id,
     axis2_bool_t svr_side,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
@@ -73,6 +79,12 @@
     const axutil_env_t *env,
     axis2_char_t *name);
 
+static axis2_status_t AXIS2_CALL
+sandesha2_terminate_mgr_process_terminate_msg_response(
+    const axutil_env_t *env, 
+    axis2_msg_ctx_t *msg_ctx,
+    sandesha2_storage_mgr_t *storage_mgr);
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg(
     const axutil_env_t *env,
@@ -235,41 +247,59 @@
     AXIS2_PARAM_CHECK(env->error, next_msg_mgr, AXIS2_FAILURE);
     
     find_bean = sandesha2_next_msg_bean_create(env);
-    sandesha2_next_msg_bean_set_seq_id(find_bean, env, seq_id);
+    if(find_bean)
+    {
+        sandesha2_next_msg_bean_set_seq_id(find_bean, env, seq_id);
     
-    found_list = sandesha2_next_msg_mgr_find(next_msg_mgr, env, find_bean);
+        found_list = sandesha2_next_msg_mgr_find(next_msg_mgr, env, find_bean);
+        sandesha2_next_msg_bean_free(find_bean, env);
+    }
+
     if(found_list)
-        size = axutil_array_list_size(found_list, env);
-    for(i = 0; i < size; i++)
     {
-        sandesha2_next_msg_bean_t *bean = axutil_array_list_get(found_list, 
-            env, i);
-        if(bean)
+        size = axutil_array_list_size(found_list, env);
+
+        for(i = 0; i < size; i++)
         {
-            axis2_char_t *key = NULL;
-            axis2_char_t *seq_id = NULL;
-            key = sandesha2_next_msg_bean_get_ref_msg_key(bean, env);
-            if(key)
+            sandesha2_next_msg_bean_t *bean = axutil_array_list_get(found_list, env, i);
+            if(bean)
             {
-                sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, 
-                    conf_ctx, -1);
+                axis2_char_t *key = NULL;
+                axis2_char_t *temp_seq_id = NULL;
+
+                key = sandesha2_next_msg_bean_get_ref_msg_key(bean, env);
+                if(key)
+                {
+                    sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, conf_ctx, -1);
+                }
+
+                temp_seq_id = sandesha2_next_msg_bean_get_seq_id(bean, env);
+                if(temp_seq_id)
+                {
+                    sandesha2_next_msg_mgr_remove(next_msg_mgr, env, temp_seq_id);
+                }
+
+                sandesha2_next_msg_bean_free(bean, env);
             }
-            seq_id = sandesha2_next_msg_bean_get_seq_id(bean, env);
-            if(seq_id)
-                sandesha2_next_msg_mgr_remove(next_msg_mgr, env, seq_id);
         }
+
+        axutil_array_list_free(found_list, env);
     }
+
     highest_in_msg_key = sandesha2_utils_get_seq_property(env, seq_id,
         SANDESHA2_SEQ_PROP_HIGHEST_IN_MSG_KEY, seq_prop_mgr);
     if(highest_in_msg_key)
     {
-        sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-            highest_in_msg_key, conf_ctx, -1);
+        sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, highest_in_msg_key, conf_ctx, -1);
         if(highest_in_msg_key)
+        {
             AXIS2_FREE(env->allocator, highest_in_msg_key);
+        }
     }
-    sandesha2_terminate_mgr_remove_recv_side_properties(env, conf_ctx, seq_id,
-        storage_mgr, seq_prop_mgr);
+
+    sandesha2_terminate_mgr_remove_recv_side_properties(env, conf_ctx, seq_id, storage_mgr, 
+            seq_prop_mgr);
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
         "[sandesha2]Exit:sandesha2_terminate_mgr_complete_termination_of_recv_side");
     return AXIS2_SUCCESS;
@@ -296,6 +326,7 @@
     
     all_seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
         SANDESHA2_SEQ_PROP_ALL_SEQS, SANDESHA2_SEQ_PROP_INCOMING_SEQ_LIST);
+
     if(all_seq_bean)
     {
         axutil_array_list_t *all_seq_list = NULL;
@@ -305,31 +336,64 @@
             sandesha2_seq_property_bean_get_value(all_seq_bean, env));
         if(all_seq_list)
         {
-            int i = 0;
-            for(i = 0; i < axutil_array_list_size(all_seq_list, env); i++)
+            int i = 0, j = 0, size = 0;
+
+            size = axutil_array_list_size(all_seq_list, env);
+
+            for(i = 0; i < size; i++)
             {
                 axis2_char_t *value = axutil_array_list_get(all_seq_list, env, i);
-                if(0 == axutil_strcmp(value, seq_id))
+                
+                if(value)
                 {
-                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-                        "[sandesha2]Removing seq id:%s from the all incoming "\
-                        "sequence list", value);
-                    axutil_array_list_remove(all_seq_list, env, i);
-                    break;
+                    if(!axutil_strcmp(value, seq_id))
+                    {
+                        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                            "[sandesha2] Removing seq id:%s from the all incoming sequence list", 
+                            value);
+
+                        axutil_array_list_remove(all_seq_list, env, i);
+                        AXIS2_FREE(env->allocator, value);
+                        break;
+                    }
+
+                    AXIS2_FREE(env->allocator, value);
                 }
             }
+
+            for(j = i++; j < size; j++)
+            {
+                axis2_char_t *value = axutil_array_list_get(all_seq_list, env, i);
+                if(value)
+                {
+                    AXIS2_FREE(env->allocator, value);
+                }
+            }
+
             all_seq_str = sandesha2_utils_array_list_to_string(env, all_seq_list,
                 SANDESHA2_ARRAY_LIST_STRING);
+
             sandesha2_seq_property_bean_set_value(all_seq_bean, env, all_seq_str);
             if(all_seq_str)
+            {
                 AXIS2_FREE(env->allocator, all_seq_str);
+            }
+
             sandesha2_seq_property_mgr_update(seq_prop_mgr, env, all_seq_bean);
+            axutil_array_list_free(all_seq_list, env);
         }
+
+        sandesha2_seq_property_bean_free(all_seq_bean, env);
     }
+
     find_seq_prop_bean = sandesha2_seq_property_bean_create(env);
-    sandesha2_seq_property_bean_set_seq_id(find_seq_prop_bean, env, seq_id);
-    found_list = sandesha2_seq_property_mgr_find(seq_prop_mgr, env, 
-        find_seq_prop_bean);
+    if(find_seq_prop_bean)
+    {
+        sandesha2_seq_property_bean_set_seq_id(find_seq_prop_bean, env, seq_id);
+        found_list = sandesha2_seq_property_mgr_find(seq_prop_mgr, env, find_seq_prop_bean);
+        sandesha2_seq_property_bean_free(find_seq_prop_bean, env);
+    }
+
     if(found_list)
     {
         int i = 0, size = 0;
@@ -345,29 +409,35 @@
                 sandesha2_seq_property_bean_get_name(seq_prop_bean, env)))
             {
                 axis2_char_t *highest_in_msg_key_str = NULL;
-                axis2_char_t *seq_id = sandesha2_seq_property_bean_get_seq_id(
-                    seq_prop_bean, env);
-                axis2_char_t *name = sandesha2_seq_property_bean_get_name(
-                    seq_prop_bean, env);
+                axis2_char_t *temp_seq_id = sandesha2_seq_property_bean_get_seq_id(seq_prop_bean, env);
+                axis2_char_t *name = sandesha2_seq_property_bean_get_name(seq_prop_bean, env);
+
                 if(!axutil_strcmp(name, SANDESHA2_SEQ_PROP_HIGHEST_IN_MSG_NUMBER))
                 {
                     highest_in_msg_key_str = 
                         sandesha2_seq_property_bean_get_value(seq_prop_bean, env);
-                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] "\
-                        "Removing the message context for the highest in "\
-                        "message number");
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                        "[sandesha2] Removing the message context for the highest in message number");
                     sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
                         highest_in_msg_key_str, conf_ctx, -1);
                 }
-                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Removing "\
-                    "the sequence property named %s in the sequence %s", name, 
-                    seq_id);
-                sandesha2_seq_property_mgr_remove(seq_prop_mgr, env, seq_id, name);
+
+                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                        "[sandesha2] Removing the sequence property named %s in the sequence %s", 
+                        name, temp_seq_id);
+
+                sandesha2_seq_property_mgr_remove(seq_prop_mgr, env, temp_seq_id, name);
             }
+            
+            sandesha2_seq_property_bean_free(seq_prop_bean, env);
         }
+
+        axutil_array_list_free(found_list, env);
     }
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_terminate_mgr_remove_recv_side_properties");
+            "[sandesha2]Exit:sandesha2_terminate_mgr_remove_recv_side_properties");
+
     return AXIS2_SUCCESS;
 }
                         
@@ -375,7 +445,7 @@
 sandesha2_terminate_mgr_terminate_sending_side(
     const axutil_env_t *env,
     axis2_conf_ctx_t *conf_ctx,
-    axis2_char_t *seq_id,
+    axis2_char_t *internal_sequence_id,
     axis2_bool_t svr_side,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
@@ -386,17 +456,22 @@
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
         "[sandesha2]Entry:sandesha2_terminate_mgr_terminate_sending_side");
     AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, create_seq_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, sender_mgr, AXIS2_FAILURE);
     
     seq_term_bean = sandesha2_seq_property_bean_create_with_data(env, 
-        seq_id, SANDESHA2_SEQ_PROP_SEQ_TERMINATED, AXIS2_VALUE_TRUE);
-    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, seq_term_bean);
+        internal_sequence_id, SANDESHA2_SEQ_PROP_SEQ_TERMINATED, AXIS2_VALUE_TRUE);
+
+    if(seq_term_bean)
+    {
+        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, seq_term_bean);
+        sandesha2_seq_property_bean_free(seq_term_bean, env);
+    }
     
-    sandesha2_terminate_mgr_clean_sending_side_data(env, conf_ctx, seq_id, 
+    sandesha2_terminate_mgr_clean_sending_side_data(env, conf_ctx, internal_sequence_id, 
         svr_side, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
         "[sandesha2]Exit:sandesha2_terminate_mgr_terminate_sending_side");
@@ -406,7 +481,7 @@
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 sandesha2_terminate_mgr_do_updates_if_needed(
     const axutil_env_t *env,
-    axis2_char_t *seq_id,
+    axis2_char_t *rms_sequence_id,
     sandesha2_seq_property_bean_t *prop_bean,
     sandesha2_seq_property_mgr_t *seq_prop_mgr)
 {
@@ -414,37 +489,50 @@
     axis2_char_t *name = NULL;
     
     AXIS2_PARAM_CHECK(env->error, prop_bean, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, rms_sequence_id, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
     
     name = sandesha2_seq_property_bean_get_name(prop_bean, env);
     if(NULL == name)
+    {
         return AXIS2_FAILURE;
+    }
     
-    if(0 == axutil_strcmp(name, SANDESHA2_SEQ_PROP_CLIENT_COMPLETED_MESSAGES))
+    if(!axutil_strcmp(name, SANDESHA2_SEQ_PROP_CLIENT_COMPLETED_MESSAGES))
+    {
         add_entry_with_seq_id = AXIS2_TRUE;
-    if(0 == axutil_strcmp(name, SANDESHA2_SEQ_PROP_SEQ_TERMINATED))
+    }
+    if(!axutil_strcmp(name, SANDESHA2_SEQ_PROP_SEQ_TERMINATED))
+    {
         add_entry_with_seq_id = AXIS2_TRUE;
-    if(0 == axutil_strcmp(name, SANDESHA2_SEQ_PROP_SEQ_CLOSED))
+    }
+    if(!axutil_strcmp(name, SANDESHA2_SEQ_PROP_SEQ_CLOSED))
+    {
         add_entry_with_seq_id = AXIS2_TRUE;
-    if(0 == axutil_strcmp(name, SANDESHA2_SEQ_PROP_SEQ_TIMED_OUT))
+    }
+    if(!axutil_strcmp(name, SANDESHA2_SEQ_PROP_SEQ_TIMED_OUT))
+    {
         add_entry_with_seq_id = AXIS2_TRUE;
+    }
         
-    if(AXIS2_TRUE == add_entry_with_seq_id && seq_id)
+    if(add_entry_with_seq_id && rms_sequence_id)
     {
         sandesha2_seq_property_bean_t *new_bean = NULL;
+
         new_bean = sandesha2_seq_property_bean_create(env);
-        sandesha2_seq_property_bean_set_seq_id(new_bean, env, seq_id);
+        sandesha2_seq_property_bean_set_seq_id(new_bean, env, rms_sequence_id);
         sandesha2_seq_property_bean_set_name(new_bean, env, name);
         sandesha2_seq_property_bean_set_value(new_bean, env, 
                         sandesha2_seq_property_bean_get_value(prop_bean, env));
         sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, new_bean);
         sandesha2_seq_property_mgr_remove(seq_prop_mgr, env, 
-                    sandesha2_seq_property_bean_get_seq_id(prop_bean, env),
-                    name);
+                    sandesha2_seq_property_bean_get_seq_id(prop_bean, env), name);
         if(new_bean)
+        {
             sandesha2_seq_property_bean_free(new_bean, env);
+        }
     }
+
     return AXIS2_SUCCESS;
 }
 
@@ -457,17 +545,35 @@
     axis2_bool_t deletable = AXIS2_TRUE;
         
     if(0 == axutil_strcasecmp(name, SANDESHA2_SEQ_PROP_TERMINATE_ADDED))
+    {
         deletable = AXIS2_FALSE;
+    }
+
     if(0 == axutil_strcasecmp(name, SANDESHA2_SEQ_PROP_NO_OF_OUTGOING_MSGS_ACKED))
+    {
         deletable = AXIS2_FALSE;
-    if(0 == axutil_strcasecmp(name, SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID))
+    }
+
+    if(0 == axutil_strcasecmp(name, SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID))
+    {
         deletable = AXIS2_FALSE;
+    }
+
     if(0 == axutil_strcasecmp(name, SANDESHA2_SEQ_PROP_SEQ_TERMINATED))
+    {
         deletable = AXIS2_FALSE;
+    }
+
     if(0 == axutil_strcasecmp(name, SANDESHA2_SEQ_PROP_SEQ_CLOSED))
+    {
         deletable = AXIS2_FALSE;
+    }
+
     if(0 == axutil_strcasecmp(name, SANDESHA2_SEQ_PROP_SEQ_TIMED_OUT))
+    {
         deletable = AXIS2_FALSE;
+    }
+
     return deletable;
 }
 
@@ -475,7 +581,7 @@
 sandesha2_terminate_mgr_time_out_sending_side_seq(
     const axutil_env_t *env,
     axis2_conf_ctx_t *conf_ctx,
-    axis2_char_t *seq_id,
+    axis2_char_t *internal_sequence_id,
     axis2_bool_t svr_side,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
@@ -485,76 +591,84 @@
     sandesha2_seq_property_bean_t *seq_term_bean = NULL;
     
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Entry:sandesha2_terminate_mgr_time_out_sending_side_seq");
+        "[sandesha2] Entry:sandesha2_terminate_mgr_time_out_sending_side_seq");
+
     AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, create_seq_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, sender_mgr, AXIS2_FAILURE);
     
-    seq_term_bean = sandesha2_seq_property_bean_create_with_data(env, seq_id,
+    seq_term_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id,
         SANDESHA2_SEQ_PROP_SEQ_TIMED_OUT, AXIS2_VALUE_TRUE);
     
-    sandesha2_terminate_mgr_clean_sending_side_data(env, conf_ctx, seq_id,
-        svr_side, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
+    sandesha2_terminate_mgr_clean_sending_side_data(env, conf_ctx, internal_sequence_id, svr_side, 
+            storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
+
     sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, seq_term_bean);
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_terminate_mgr_time_out_sending_side_seq");
+        "[sandesha2] Exit:sandesha2_terminate_mgr_time_out_sending_side_seq");
+
     return AXIS2_SUCCESS;
 }
 
+/* Clean all sending side data stored in the database. This includes all sequence properties,
+ * all create sequence beans and all sender beans set using internal sequence id.
+ */
 static axis2_status_t
 sandesha2_terminate_mgr_clean_sending_side_data(
     const axutil_env_t *env,
     axis2_conf_ctx_t *conf_ctx,
-    axis2_char_t *seq_id,
+    axis2_char_t *internal_sequence_id,
     axis2_bool_t svr_side,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
     sandesha2_create_seq_mgr_t *create_seq_mgr,
     sandesha2_sender_mgr_t *sender_mgr)
 {
-    axis2_char_t *out_seq_id = NULL;
-    axis2_char_t *internal_seq_id = NULL;
+    axis2_char_t *rms_sequence_id = NULL;
     axutil_array_list_t *found_list = NULL;
     sandesha2_create_seq_bean_t *find_create_seq_bean = NULL;
     sandesha2_seq_property_bean_t *find_seq_prop_bean = NULL;
     
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Entry:sandesha2_terminate_mgr_clean_sending_side_data");
+        "[sandesha2] Entry:sandesha2_terminate_mgr_clean_sending_side_data");
+
     AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, create_seq_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, sender_mgr, AXIS2_FAILURE);
      
-    out_seq_id = sandesha2_utils_get_seq_property(env, seq_id, 
-        SANDESHA2_SEQ_PROP_OUT_SEQ_ID, seq_prop_mgr);
-    if(!svr_side)
+    rms_sequence_id = sandesha2_utils_get_seq_property(env, internal_sequence_id, 
+        SANDESHA2_SEQUENCE_PROPERTY_RMS_SEQ_ID, seq_prop_mgr);
+
+    /*if(!svr_side)
     {
         sandesha2_seq_property_bean_t *acks_to_bean = NULL;
         axis2_bool_t stop_listner_for_async = AXIS2_FALSE;
         
         acks_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env,
-            seq_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR);
+            internal_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR);
         if(acks_to_bean)
         {
             axis2_char_t *acks_to = NULL;
+
             acks_to = sandesha2_seq_property_bean_get_value(acks_to_bean, env);
             if(sandesha2_utils_is_anon_uri(env, acks_to))
+            {
                 stop_listner_for_async = AXIS2_TRUE;
+            }
             sandesha2_seq_property_bean_free(acks_to_bean, env);
         }
         
-    }
-    internal_seq_id = sandesha2_utils_get_seq_property(env, seq_id, 
-        SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID, seq_prop_mgr);
-    if(!internal_seq_id)
-        internal_seq_id = axutil_strdup(env, seq_id);
-    found_list = sandesha2_sender_mgr_find_by_internal_seq_id(sender_mgr, env,
-        internal_seq_id);
+    }*/
+
+    /* Remove all sender beans set using internal sequence id and stored in the database. */
+    found_list = sandesha2_sender_mgr_find_by_internal_seq_id(sender_mgr, env, internal_sequence_id);
     if(found_list)
     {
         int i = 0;
@@ -566,26 +680,30 @@
             
             retrans_bean = axutil_array_list_get(found_list, env, i);
             msg_id = sandesha2_sender_bean_get_msg_id(retrans_bean, env);
-            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Removing the"\
-                " sender bean with msg_id %s and internal_seq_id %s", msg_id, 
-                internal_seq_id);
+
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                    "[sandesha2] Removing the sender bean with msg_id %s and internal_sequence_id %s", 
+                    msg_id, internal_sequence_id);
+
             sandesha2_sender_mgr_remove(sender_mgr, env, msg_id);
-            msg_store_key = sandesha2_sender_bean_get_msg_ctx_ref_key(
-                        retrans_bean, env);
-            sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-                msg_store_key, conf_ctx, -1);
+            msg_store_key = sandesha2_sender_bean_get_msg_ctx_ref_key(retrans_bean, env);
+            sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, msg_store_key, conf_ctx, -1);
             if(retrans_bean)
+            {
                 sandesha2_sender_bean_free(retrans_bean, env);
+            }
         }
+
         if(found_list)
+        {
             axutil_array_list_free(found_list, env);
+        }
     }
-    
+   
+    /* Removing the create seqence beans created and stored in the database. */
     find_create_seq_bean = sandesha2_create_seq_bean_create(env);
-    sandesha2_create_seq_bean_set_internal_seq_id(find_create_seq_bean, env,
-        internal_seq_id);
-    found_list = sandesha2_create_seq_mgr_find(create_seq_mgr, env, 
-        find_create_seq_bean);
+    sandesha2_create_seq_bean_set_internal_sequence_id(find_create_seq_bean, env, internal_sequence_id);
+    found_list = sandesha2_create_seq_mgr_find(create_seq_mgr, env, find_create_seq_bean);
     if(found_list)
     {
         int i = 0;
@@ -596,32 +714,44 @@
             sandesha2_create_seq_bean_t *create_seq_bean = NULL;
             
             create_seq_bean = axutil_array_list_get(found_list, env, i);
-            key = sandesha2_create_seq_bean_get_ref_msg_store_key(
-                create_seq_bean, env);
-            if(key) 
-               sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, 
-                   conf_ctx, -1);
-            msg_id = sandesha2_create_seq_bean_get_create_seq_msg_id(
-                create_seq_bean, env);
-            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Removing the"\
-                " create_seq_bean with msg_id %s and internal_seq_id %s",
-                msg_id, internal_seq_id);
+            key = sandesha2_create_seq_bean_get_ref_msg_store_key(create_seq_bean, env);
+            if(key)
+            {
+               sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, conf_ctx, -1);
+            }
+
+            msg_id = sandesha2_create_seq_bean_get_create_seq_msg_id(create_seq_bean, env);
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                    "[sandesha2] Removing the create_seq_bean with msg_id %s and internal_sequence_id %s", 
+                    msg_id, internal_sequence_id);
+
             sandesha2_create_seq_mgr_remove(create_seq_mgr, env, msg_id);
             if(create_seq_bean)
+            {
                 sandesha2_create_seq_bean_free(create_seq_bean, env);
+            }
         }
+        
+        axutil_array_list_free(found_list, env);
     }
+
     if(find_create_seq_bean)
+    {
         sandesha2_create_seq_bean_free(find_create_seq_bean, env);
-    if(found_list)
-        axutil_array_list_free(found_list, env);
+    }
     
+    /* Remove all sequence properties set using internal sequence id and stored in the database.
+     * This includes all properties set in sandesha2_seq_mgr_setup_new_rms_sequence() function.
+     */
     find_seq_prop_bean = sandesha2_seq_property_bean_create(env);
-    sandesha2_seq_property_bean_set_seq_id(find_seq_prop_bean, env, internal_seq_id);
-    if(internal_seq_id)
-        AXIS2_FREE(env->allocator, internal_seq_id);
-    found_list = sandesha2_seq_property_mgr_find(seq_prop_mgr, env, 
-        find_seq_prop_bean);
+    sandesha2_seq_property_bean_set_seq_id(find_seq_prop_bean, env, internal_sequence_id);
+
+    found_list = sandesha2_seq_property_mgr_find(seq_prop_mgr, env, find_seq_prop_bean);
+    if(find_seq_prop_bean)
+    {
+        sandesha2_seq_property_bean_free(find_seq_prop_bean, env);
+    }
+
     if(found_list)
     {
         int i = 0, size = 0;
@@ -631,293 +761,595 @@
             sandesha2_seq_property_bean_t *seq_prop_bean = NULL;
             
             seq_prop_bean = axutil_array_list_get(found_list, env, i);
-            sandesha2_terminate_mgr_do_updates_if_needed(env, out_seq_id,
-                seq_prop_bean, seq_prop_mgr);
+
+            /* I have only vague idea what this do:damitha. */
+            sandesha2_terminate_mgr_do_updates_if_needed(env, rms_sequence_id, seq_prop_bean, 
+                    seq_prop_mgr);
+
+            /* There are terminate/close sequence related properties that we do not remove at this 
+             * stage from database. When we remove them?:damitha*/
             if(sandesha2_terminate_mgr_is_property_deletable(env,
                 sandesha2_seq_property_bean_get_name(seq_prop_bean, env)))
             {
                 axis2_char_t *highest_in_msg_key_str = NULL;
-                axis2_char_t *seq_id = sandesha2_seq_property_bean_get_seq_id(
-                    seq_prop_bean, env);
-                axis2_char_t *name = sandesha2_seq_property_bean_get_name(
-                    seq_prop_bean, env);
+                axis2_char_t *temp_internal_sequence_id = NULL;
+                axis2_char_t *name = NULL;
+
+                temp_internal_sequence_id = sandesha2_seq_property_bean_get_seq_id(seq_prop_bean, env);
+                name = sandesha2_seq_property_bean_get_name(seq_prop_bean, env);
+
                 if(!axutil_strcmp(name, SANDESHA2_SEQ_PROP_HIGHEST_IN_MSG_NUMBER))
                 {
-                    highest_in_msg_key_str = 
-                        sandesha2_seq_property_bean_get_value(seq_prop_bean, env);
-                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] "\
-                        "Removing the message context for the highest in "\
-                        "message number");
-                    sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-                        highest_in_msg_key_str, conf_ctx, -1);
+                    highest_in_msg_key_str = sandesha2_seq_property_bean_get_value(seq_prop_bean, env);
+
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                            "[sandesha2] Removing the message context for the highest in message number");
+
+                    sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, highest_in_msg_key_str, 
+                            conf_ctx, -1);
                 }
-                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Removing "\
-                    "the sequence property named %s in the sequence %s", name, 
-                    seq_id);
-                sandesha2_seq_property_mgr_remove(seq_prop_mgr, env, seq_id, name);
+
+                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                        "[sandesha2] Removing the sequence property named %s in the sequence %s", 
+                        name, temp_internal_sequence_id);
+
+                sandesha2_seq_property_mgr_remove(seq_prop_mgr, env, temp_internal_sequence_id, name);
             }
+
             if(seq_prop_bean)
+            {
                 sandesha2_seq_property_bean_free(seq_prop_bean, env);
+            }
         }
-    }
-    if(found_list)
+        
         axutil_array_list_free(found_list, env);
-    if(out_seq_id)
-        AXIS2_FREE(env->allocator, out_seq_id);
+    }
+
+    if(rms_sequence_id)
+    {
+        AXIS2_FREE(env->allocator, rms_sequence_id);
+    }
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_terminate_mgr_clean_sending_side_data");
+        "[sandesha2] Exit:sandesha2_terminate_mgr_clean_sending_side_data");
+
     return AXIS2_SUCCESS;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-sandesha2_terminate_mgr_add_terminate_seq_msg(
+sandesha2_terminate_mgr_send_terminate_seq_msg(
     const axutil_env_t *env,
-    sandesha2_msg_ctx_t *rm_msg_ctx,
-    axis2_char_t *out_seq_id,
-    axis2_char_t *int_seq_id,
+    sandesha2_msg_ctx_t *ack_rm_msg_ctx,
+    axis2_char_t *rms_sequence_id,
+    axis2_char_t *internal_sequence_id,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
     sandesha2_create_seq_mgr_t *create_seq_mgr,
     sandesha2_sender_mgr_t *sender_mgr)
 {
-    axis2_msg_ctx_t *msg_ctx = NULL;
+    axis2_msg_ctx_t *ack_msg_ctx = NULL;
     axis2_msg_ctx_t *terminate_msg_ctx = NULL;
     axis2_conf_ctx_t *conf_ctx = NULL;
     sandesha2_seq_property_bean_t *terminated = NULL;
-    sandesha2_msg_ctx_t *terminate_rm_msg = NULL;
+    sandesha2_msg_ctx_t *terminate_rm_msg_ctx = NULL;
     axutil_property_t *property = NULL;
     axis2_endpoint_ref_t *to_epr = NULL;
     sandesha2_seq_property_bean_t *to_bean = NULL;
     axis2_char_t *rm_ver = NULL;
     sandesha2_seq_property_bean_t *transport_to_bean = NULL;
     axis2_char_t *key = NULL;
-    sandesha2_sender_bean_t *terminate_bean = NULL;
+    sandesha2_sender_bean_t *terminate_sender_bean = NULL;
     sandesha2_seq_property_bean_t *terminate_added = NULL;
-    axis2_transport_out_desc_t *transport_out = NULL;
-    axis2_msg_ctx_t *msg_ctx1 = NULL;
+    sandesha2_seq_property_bean_t *replay_bean = NULL;
     axis2_engine_t *engine = NULL;
     axis2_char_t *temp_action = NULL;
     axutil_string_t *soap_action = NULL;
     axis2_status_t status = AXIS2_FALSE;
     const axis2_char_t *to_addr = NULL;
     long send_time = -1;
-    sandesha2_terminate_seq_t *terminate_seq = NULL;
-    axis2_char_t *seq_id = NULL;
     int terminate_delay = -1;
     sandesha2_property_bean_t *property_bean = NULL;
+    axis2_endpoint_ref_t *reply_to_epr = NULL;
+    axis2_bool_t is_svr_side = AXIS2_FALSE;
+    axis2_char_t *msg_id = NULL;
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Entry:sandesha2_terminate_mgr_add_terminate_seq_msg");
-    AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, out_seq_id, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK(env->error, int_seq_id, AXIS2_FAILURE);
+        "[sandesha2] Entry:sandesha2_terminate_mgr_send_terminate_seq_msg");
+
+    AXIS2_PARAM_CHECK(env->error, ack_rm_msg_ctx, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, rms_sequence_id, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, create_seq_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, sender_mgr, AXIS2_FAILURE);
     
-    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
-    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+    ack_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ack_rm_msg_ctx, env);
+    conf_ctx = axis2_msg_ctx_get_conf_ctx(ack_msg_ctx, env);
     
-    terminated = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
-        out_seq_id, SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
-    if(terminated && sandesha2_seq_property_bean_get_value(terminated, env) 
-        && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, 
-        sandesha2_seq_property_bean_get_value(terminated, env)))
-    {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate "\
-            "sequence message was added previously");
-        /* If we do not return at this, there will be two terminate messsages
-         * sent to the client
-         */
-        return AXIS2_SUCCESS;
-    }
-    terminate_rm_msg = sandesha2_msg_creator_create_terminate_seq_msg(env,
-        rm_msg_ctx, out_seq_id, int_seq_id, seq_prop_mgr);
-    if(!terminate_rm_msg)
+    terminated = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_sequence_id, 
+            SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
+
+    /*if(terminated)
+    {
+        axis2_char_t *value = sandesha2_seq_property_bean_get_value(terminated, env);
+
+        if(value && !axutil_strcmp(AXIS2_VALUE_TRUE, value))
+        {
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                "[sandesha2] Terminate sequence message was added previously");
+
+            sandesha2_seq_property_bean_free(terminated, env);
+            return AXIS2_SUCCESS;
+        }
+
+        sandesha2_seq_property_bean_free(terminated, env);
+    }*/
+
+    terminate_rm_msg_ctx = sandesha2_msg_creator_create_terminate_seq_msg(env, ack_rm_msg_ctx, 
+            rms_sequence_id, internal_sequence_id, seq_prop_mgr);
+
+    if(!terminate_rm_msg_ctx)
+    {
         return AXIS2_FAILURE;
-    sandesha2_msg_ctx_set_flow(terminate_rm_msg, env, AXIS2_OUT_FLOW);
+    }
+    
+    terminate_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(terminate_rm_msg_ctx, env);
+
+    sandesha2_msg_ctx_set_flow(terminate_rm_msg_ctx, env, AXIS2_OUT_FLOW);
     property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
-    sandesha2_msg_ctx_set_property(terminate_rm_msg, env, 
-        SANDESHA2_APPLICATION_PROCESSING_DONE, property);
+    sandesha2_msg_ctx_set_property(terminate_rm_msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, 
+            property);
     
-    to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, int_seq_id,
-        SANDESHA2_SEQ_PROP_TO_EPR);
+    to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_sequence_id, 
+            SANDESHA2_SEQ_PROP_TO_EPR);
+
     if(to_bean)
     {
-        to_epr = axis2_endpoint_ref_create(env, 
-            sandesha2_seq_property_bean_get_value(to_bean, env));
+        axis2_char_t *temp_addr = NULL;
+
+        temp_addr = sandesha2_seq_property_bean_get_value(to_bean, env);
+        to_epr = axis2_endpoint_ref_create(env, temp_addr);
+        /*if(!sandesha2_utils_is_anon_uri(env, temp_addr))
+        {
+            to_epr = axis2_endpoint_ref_create(env, temp_addr);
+        }*/
         sandesha2_seq_property_bean_free(to_bean, env);
     }
-    /*if(!to_epr)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] To EPR has an "
-            "invalid value");
-        return AXIS2_FAILURE;
-    }*/
+
     if(to_epr)
+    {
         to_addr = axis2_endpoint_ref_get_address(to_epr, env);
-    sandesha2_msg_ctx_set_to(terminate_rm_msg, env, to_epr);
-    rm_ver = sandesha2_utils_get_rm_version(env, int_seq_id, seq_prop_mgr);
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "to_addr:%s", to_addr);
+        sandesha2_msg_ctx_set_to(terminate_rm_msg_ctx, env, to_epr);
+    }
+
+    rm_ver = sandesha2_utils_get_rm_version(env, internal_sequence_id, seq_prop_mgr);
     if(!rm_ver)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find the "
-            "rm version for msg");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find the rm version for msg");
+        if(terminate_rm_msg_ctx)
+        {
+            sandesha2_msg_ctx_free(terminate_rm_msg_ctx, env);
+        }
+
+        if(terminate_msg_ctx)
+        {
+            axis2_endpoint_ref_t *temp_epr = NULL;
+
+            temp_epr = axis2_msg_ctx_get_to(terminate_msg_ctx, env);
+            if(temp_epr)
+            {
+                axis2_endpoint_ref_free(temp_epr, env);
+            }
+
+            /* Reset the message context to avoid double freeing of transport out stream */
+            axis2_core_utils_reset_out_msg_ctx(env, terminate_msg_ctx);
+            axis2_msg_ctx_free(terminate_msg_ctx, env);
+        }
+
         return AXIS2_FAILURE;
     }
-    sandesha2_msg_ctx_set_wsa_action(terminate_rm_msg, env, 
+
+    sandesha2_msg_ctx_set_wsa_action(terminate_rm_msg_ctx, env, 
         sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_ver));
-    temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action
-        (env, rm_ver);
+
+    temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action(env, rm_ver);
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_action:%s", temp_action);
     soap_action = axutil_string_create(env, temp_action);
-    sandesha2_msg_ctx_set_soap_action(terminate_rm_msg, env, soap_action);
-    transport_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env,
-        int_seq_id, SANDESHA2_SEQ_PROP_TRANSPORT_TO);
+    if(soap_action)
+    {
+        sandesha2_msg_ctx_set_soap_action(terminate_rm_msg_ctx, env, soap_action);
+        axutil_string_free(soap_action, env);
+    }
+
+    transport_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_sequence_id, 
+            SANDESHA2_SEQ_PROP_TRANSPORT_TO);
+
     if(transport_to_bean)
     {
-        axis2_char_t *value = sandesha2_seq_property_bean_get_value(
-            transport_to_bean, env);
+        axis2_char_t *value = sandesha2_seq_property_bean_get_value(transport_to_bean, env);
         property = axutil_property_create_with_args(env, 0, 0, 0, value);
-        sandesha2_msg_ctx_set_property(terminate_rm_msg, env,
-            AXIS2_TRANSPORT_URL, property);
+        sandesha2_msg_ctx_set_property(terminate_rm_msg_ctx, env, AXIS2_TRANSPORT_URL, property);
     }
     
-    sandesha2_msg_ctx_add_soap_envelope(terminate_rm_msg, env);
-    /* If server side and single channel duplex mode send the terminate sequence
-     * message.
+    
+    /* If server side and single channel duplex mode send the terminate sequence message.
      */
-    if(axis2_msg_ctx_get_server_side(msg_ctx, env) &&
-       sandesha2_utils_is_single_channel(env, rm_ver, to_addr))
+    if(sandesha2_utils_is_rm_1_0_anonymous_acks_to(env, rm_ver, to_addr))
     {
-        axis2_msg_ctx_t *msg_ctx2 = NULL;
-        axis2_bool_t is_svr_side = AXIS2_FALSE;
-
-        msg_ctx2 = sandesha2_msg_ctx_get_msg_ctx(terminate_rm_msg, env);
-        is_svr_side = axis2_msg_ctx_get_server_side(msg_ctx2, env);
-        axis2_op_ctx_set_response_written(axis2_msg_ctx_get_op_ctx(msg_ctx2, env), env, AXIS2_TRUE);
-        axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
-        axis2_op_ctx_set_response_written(axis2_msg_ctx_get_op_ctx(msg_ctx, env), env, AXIS2_TRUE);
+        sandesha2_msg_ctx_add_soap_envelope(terminate_rm_msg_ctx, env);
+        axis2_op_ctx_set_response_written(axis2_msg_ctx_get_op_ctx(terminate_msg_ctx, env), env, AXIS2_TRUE);
+        axis2_msg_ctx_set_paused(ack_msg_ctx, env, AXIS2_TRUE);
+        axis2_op_ctx_set_response_written(axis2_msg_ctx_get_op_ctx(ack_msg_ctx, env), env, AXIS2_TRUE);
         engine = axis2_engine_create(env, conf_ctx);
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]axis2_engine_send");
-        axis2_engine_send(engine, env, msg_ctx2);
+
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] axis2_engine_send");
+
+        axis2_engine_send(engine, env, terminate_msg_ctx);
         if(engine)
         {
             axis2_engine_free(engine, env);
             engine = NULL;
         }
+
         /* Clean sending side data */
+        /*sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx, internal_sequence_id, 
+                is_svr_side, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);*/
+        terminate_added = sandesha2_seq_property_bean_create(env);
+
+        if(terminate_added)
         {
-            sandesha2_terminate_seq_t *terminate_seq = NULL;
-            axis2_char_t *seq_id = NULL;
-            axis2_char_t *internal_seq_id = NULL;
-            
-            terminate_seq = sandesha2_msg_ctx_get_terminate_seq(terminate_rm_msg, env);
-            seq_id = sandesha2_identifier_get_identifier(
-                sandesha2_terminate_seq_get_identifier(terminate_seq, 
-                env), env);
-            internal_seq_id = sandesha2_utils_get_seq_property(env, seq_id, 
-                SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID, seq_prop_mgr);
-            sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx,
-                internal_seq_id, is_svr_side, storage_mgr, seq_prop_mgr, 
-                create_seq_mgr, sender_mgr);
-            terminate_added = sandesha2_seq_property_bean_create(env);
-            sandesha2_seq_property_bean_set_name(terminate_added, env, 
-                SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
-            sandesha2_seq_property_bean_set_seq_id(terminate_added, env, 
-                out_seq_id);
-            sandesha2_seq_property_bean_set_value(terminate_added, env, 
-                AXIS2_VALUE_TRUE);
-            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, 
-                terminate_added);
-            if(internal_seq_id)
-                AXIS2_FREE(env->allocator, internal_seq_id);
-            if(terminate_added)
-                sandesha2_seq_property_bean_free(terminate_added, env);
+            sandesha2_seq_property_bean_set_name(terminate_added, env, SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
+
+            sandesha2_seq_property_bean_set_seq_id(terminate_added, env, internal_sequence_id);
+            sandesha2_seq_property_bean_set_value(terminate_added, env, AXIS2_VALUE_TRUE);
+            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, terminate_added);
+            sandesha2_seq_property_bean_free(terminate_added, env);
         }
+
         if(rm_ver)
+        {
             AXIS2_FREE(env->allocator, rm_ver);
+        }
+
+        if(terminate_rm_msg_ctx)
+        {
+            sandesha2_msg_ctx_free(terminate_rm_msg_ctx, env);
+        }
+
+        /* We have created this message context using sandesha2_utils_create_new_related_msg_ctx(). It is our
+         * reponsiblity to free it after use.
+         */
+        if(terminate_msg_ctx)
+        {
+            axis2_endpoint_ref_t *temp_epr = NULL;
+
+            temp_epr = axis2_msg_ctx_get_to(terminate_msg_ctx, env);
+            if(temp_epr)
+            {
+                axis2_endpoint_ref_free(temp_epr, env);
+            }
+
+            /* Reset the message context to avoid double freeing of transport out stream */
+            axis2_core_utils_reset_out_msg_ctx(env, terminate_msg_ctx);
+            axis2_msg_ctx_free(terminate_msg_ctx, env);
+        }
+
         return AXIS2_SUCCESS;
     }
+
     if(rm_ver)
+    {
         AXIS2_FREE(env->allocator, rm_ver);
+    }
+
+    sandesha2_msg_ctx_add_soap_envelope(terminate_rm_msg_ctx, env);
+
+    if(!sandesha2_util_is_ack_already_piggybacked(env, terminate_rm_msg_ctx))
+    {
+        sandesha2_ack_mgr_piggyback_acks_if_present(env, rms_sequence_id, terminate_rm_msg_ctx, 
+                storage_mgr, seq_prop_mgr, sender_mgr);
+    }
+
     key = axutil_uuid_gen(env);
-    terminate_bean = sandesha2_sender_bean_create(env);
-    sandesha2_sender_bean_set_msg_ctx_ref_key(terminate_bean, env, key);
-    terminate_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(terminate_rm_msg, env);
-    sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, 
-        terminate_msg_ctx);
-    property_bean = sandesha2_utils_get_property_bean(env, 
-        axis2_conf_ctx_get_conf(conf_ctx, env));
-    terminate_delay = sandesha2_property_bean_get_terminate_delay(property_bean, 
-        env); 
-    send_time = sandesha2_utils_get_current_time_in_millis(env) +
-        terminate_delay;
-    sandesha2_sender_bean_set_time_to_send(terminate_bean, env, send_time);
-    sandesha2_sender_bean_set_msg_id(terminate_bean, env, 
-        sandesha2_msg_ctx_get_msg_id(terminate_rm_msg, env));
-    sandesha2_sender_bean_set_send(terminate_bean, env, AXIS2_TRUE);
-
-    terminate_seq = sandesha2_msg_ctx_get_terminate_seq(terminate_rm_msg, env);
-    seq_id = sandesha2_identifier_get_identifier(
-        sandesha2_terminate_seq_get_identifier(terminate_seq, 
-        env), env);
-    sandesha2_sender_bean_set_seq_id(terminate_bean, env, seq_id);
-    sandesha2_sender_bean_set_internal_seq_id(terminate_bean, env, int_seq_id);
-
-    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_FALSE);
-    sandesha2_msg_ctx_set_property(terminate_rm_msg, env, 
-        SANDESHA2_QUALIFIED_FOR_SENDING, property);
-    sandesha2_sender_bean_set_msg_type(terminate_bean, env, 
-        SANDESHA2_MSG_TYPE_TERMINATE_SEQ);
+    terminate_sender_bean = sandesha2_sender_bean_create(env);
+    sandesha2_sender_bean_set_msg_ctx_ref_key(terminate_sender_bean, env, key);
+    /*sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, terminate_msg_ctx, AXIS2_TRUE);*/
+    property_bean = sandesha2_utils_get_property_bean(env, axis2_conf_ctx_get_conf(conf_ctx, env));
+    terminate_delay = sandesha2_property_bean_get_terminate_delay(property_bean, env); 
+    send_time = sandesha2_utils_get_current_time_in_millis(env) + terminate_delay;
+    sandesha2_sender_bean_set_time_to_send(terminate_sender_bean, env, send_time);
+
+    msg_id = sandesha2_msg_ctx_get_msg_id(terminate_rm_msg_ctx, env);
+    sandesha2_sender_bean_set_msg_id(terminate_sender_bean, env, msg_id);
+
+    sandesha2_sender_bean_set_send(terminate_sender_bean, env, AXIS2_TRUE);
+
+    sandesha2_sender_bean_set_seq_id(terminate_sender_bean, env, rms_sequence_id);
+    sandesha2_sender_bean_set_internal_seq_id(terminate_sender_bean, env, internal_sequence_id);
+
+    sandesha2_sender_bean_set_msg_type(terminate_sender_bean, env, SANDESHA2_MSG_TYPE_TERMINATE_SEQ);
                             
-    sandesha2_sender_bean_set_resend(terminate_bean, env, AXIS2_FALSE);
-    sandesha2_sender_mgr_insert(sender_mgr, env, terminate_bean);
-    if(terminate_bean)
-        sandesha2_sender_bean_free(terminate_bean, env);
-    
-    terminate_added = sandesha2_seq_property_bean_create(env);
-    sandesha2_seq_property_bean_set_name(terminate_added, env, 
-        SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
-    sandesha2_seq_property_bean_set_seq_id(terminate_added, env, out_seq_id);
-    sandesha2_seq_property_bean_set_value(terminate_added, env, 
-        AXIS2_VALUE_TRUE);
-    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, terminate_added);
-    if(terminate_added)
-        sandesha2_seq_property_bean_free(terminate_added, env);
-    msg_ctx1 = sandesha2_msg_ctx_get_msg_ctx(terminate_rm_msg, env);
-    if(terminate_rm_msg)
-        sandesha2_msg_ctx_free(terminate_rm_msg, env);
-    transport_out = axis2_msg_ctx_get_transport_out_desc(msg_ctx1, env);
-    
-    property = axutil_property_create_with_args(env, 0, 0,
-        axis2_transport_out_desc_free_void_arg, transport_out);
-    axis2_msg_ctx_set_property(msg_ctx1, env, 
-        SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property);
+    sandesha2_sender_bean_set_resend(terminate_sender_bean, env, AXIS2_FALSE);
+    sandesha2_sender_mgr_insert(sender_mgr, env, terminate_sender_bean);
     
     property = axutil_property_create_with_args(env, 0, AXIS2_TRUE, 0, key);
-    axis2_msg_ctx_set_property(msg_ctx1, env, SANDESHA2_MESSAGE_STORE_KEY, 
-        property);
+    axis2_msg_ctx_set_property(terminate_msg_ctx, env, SANDESHA2_MESSAGE_STORE_KEY, property);
                         
-    property = axutil_property_create_with_args(env, 0, 0, 0, 
-        AXIS2_VALUE_TRUE);
-    axis2_msg_ctx_set_property(msg_ctx1, env, SANDESHA2_SET_SEND_TO_TRUE, 
-        property);
+    /*property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+    axis2_msg_ctx_set_property(terminate_msg_ctx, env, SANDESHA2_SET_SEND_TO_TRUE, property);*/
                         
-    axis2_msg_ctx_set_transport_out_desc(msg_ctx1, env, 
-        sandesha2_utils_get_transport_out(env));
-    {                
-        axis2_endpoint_ref_t *reply_to_epr = NULL;
-        reply_to_epr = axis2_msg_ctx_get_to(msg_ctx, env);
-        if(reply_to_epr)
-            axis2_msg_ctx_set_reply_to(msg_ctx1, env, reply_to_epr);
+    reply_to_epr = axis2_msg_ctx_get_to(ack_msg_ctx, env);
+    if(reply_to_epr)
+    {
+        axis2_msg_ctx_set_reply_to(terminate_msg_ctx, env, sandesha2_util_endpoint_ref_clone(
+                    env, reply_to_epr));
     }
+
+    is_svr_side = sandesha2_msg_ctx_get_server_side(ack_rm_msg_ctx, env); /* Do we need this?:damitha */
     engine = axis2_engine_create(env, conf_ctx);
-    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]axis2_engine_send");
-    status = axis2_engine_send(engine, env, msg_ctx1);
+
+    replay_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
+        rms_sequence_id, SANDESHA2_SEQ_PROP_1_0_REPLAY);
+    if(replay_bean)
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] replay on");
+    }
+    if(sandesha2_utils_is_anon_uri(env, to_addr))
+    {
+        axis2_transport_out_desc_t *sandesha2_transport_out = NULL;
+
+        sandesha2_transport_out = sandesha2_utils_get_transport_out(env);
+        axis2_msg_ctx_set_transport_out_desc(terminate_msg_ctx, env, sandesha2_transport_out);
+        axis2_engine_send(engine, env, terminate_msg_ctx);
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] RM 1.1 replay");
+    }
+    else if(AXIS2_SUCCESS == axis2_engine_send(engine, env, terminate_msg_ctx))
+    {
+        if(replay_bean)
+        {
+            axiom_soap_envelope_t *res_envelope = NULL;
+            axis2_char_t *soap_ns_uri = NULL;
+            axis2_transport_out_desc_t *transport_out = NULL;
+            axis2_transport_sender_t *transport_sender = NULL;
+            
+            sandesha2_sender_bean_set_resend(terminate_sender_bean, env, AXIS2_TRUE);
+            soap_ns_uri = axis2_msg_ctx_get_is_soap_11(terminate_msg_ctx, env) ?
+                 AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI:
+                 AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+
+            res_envelope = axis2_msg_ctx_get_response_soap_envelope(terminate_msg_ctx, env);
+            if(!res_envelope)
+            {
+                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Response envelope not found");
+
+                res_envelope = (axiom_soap_envelope_t *) axis2_http_transport_utils_create_soap_msg(env, 
+                        terminate_msg_ctx, soap_ns_uri);
+            }
+
+            if(res_envelope)
+            {
+                status = sandesha2_terminate_mgr_process_terminate_msg_response(env, terminate_msg_ctx, storage_mgr);
+                if(AXIS2_SUCCESS != status)
+                {
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                        "[sandesha2] Terminate message response process failed for sequence %s", 
+                        internal_sequence_id);
+                }
+            }
+            transport_out = axis2_msg_ctx_get_transport_out_desc(terminate_msg_ctx, env);
+            if(transport_out)
+            {
+                transport_sender = axis2_transport_out_desc_get_sender(transport_out, env);
+            }
+
+            while(!res_envelope)
+            {
+                axis2_bool_t continue_sending = AXIS2_FALSE;
+                long retrans_delay = -1;
+
+                continue_sending = sandesha2_msg_retrans_adjuster_adjust_retrans(env, terminate_sender_bean, 
+                        conf_ctx, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
+
+                sandesha2_sender_mgr_update(sender_mgr, env, terminate_sender_bean);
+
+                if(!continue_sending)
+                {
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                            "[sandesha2] Do not continue sending the terminate sequence message");
+                    break;
+                }
+
+                retrans_delay = sandesha2_property_bean_get_retrans_interval(property_bean, env); 
+                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "retrans_delay:%ld", retrans_delay);
+                AXIS2_SLEEP(retrans_delay);
+
+                if(transport_sender)
+                {
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Resending the terminate message");
+                    /* This is neccessary to avoid a double free */
+                    axis2_msg_ctx_set_property(terminate_msg_ctx, env, AXIS2_TRANSPORT_IN, NULL);
+                    if(!AXIS2_TRANSPORT_SENDER_INVOKE(transport_sender, env, terminate_msg_ctx))
+                    {
+                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                                "[sandesha2] Transport sender invoke failed in sending terminate sequence message");
+                    }
+                }
+
+                res_envelope = axis2_msg_ctx_get_response_soap_envelope(terminate_msg_ctx, env);
+                if(!res_envelope)
+                {
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Response envelope not found");
+
+                    res_envelope = (axiom_soap_envelope_t *) axis2_http_transport_utils_create_soap_msg(env, 
+                            terminate_msg_ctx, soap_ns_uri);
+                }
+                
+                if(res_envelope)
+                {
+                    status = sandesha2_terminate_mgr_process_terminate_msg_response(env, 
+                            terminate_msg_ctx, storage_mgr);
+
+                    if(AXIS2_SUCCESS != status)
+                    {
+                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                            "[sandesha2] Terminate message response process failed for sequence %s", 
+                            internal_sequence_id);
+
+                        break;
+                    }
+                }
+            }
+
+            sandesha2_seq_property_bean_free(replay_bean, env);
+        }
+    }
+
+    sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, terminate_msg_ctx, AXIS2_TRUE);
+
+    if(terminate_sender_bean)
+    {
+        sandesha2_sender_bean_free(terminate_sender_bean, env);
+    }
+
+    /*sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx, internal_sequence_id, is_svr_side, 
+            storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);*/
+
+    terminate_added = sandesha2_seq_property_bean_create(env);
+    if(terminate_added)
+    {
+        sandesha2_seq_property_bean_set_name(terminate_added, env, SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
+        sandesha2_seq_property_bean_set_seq_id(terminate_added, env, internal_sequence_id);
+        sandesha2_seq_property_bean_set_value(terminate_added, env, AXIS2_VALUE_TRUE);
+        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, terminate_added);
+        sandesha2_seq_property_bean_free(terminate_added, env);
+    }
+
     if(engine)
+    {
         axis2_engine_free(engine, env);
+    }
+
+    if(terminate_rm_msg_ctx)
+    {
+        sandesha2_msg_ctx_free(terminate_rm_msg_ctx, env);
+    }
+
+    /* We have created this message context using sandesha2_utils_create_new_related_msg_ctx(). It is our
+     * reponsiblity to free if after use.
+     */
+    if(terminate_msg_ctx)
+    {
+        axis2_endpoint_ref_t *temp_epr = NULL;
+
+        temp_epr = axis2_msg_ctx_get_to(terminate_msg_ctx, env);
+        if(temp_epr)
+        {
+            axis2_endpoint_ref_free(temp_epr, env);
+            temp_epr = NULL;
+        }
+        
+        temp_epr = axis2_msg_ctx_get_reply_to(terminate_msg_ctx, env);
+        if(temp_epr)
+        {
+            axis2_endpoint_ref_free(temp_epr, env);
+        }
+
+        axis2_core_utils_reset_out_msg_ctx(env, terminate_msg_ctx);
+        axis2_msg_ctx_free(terminate_msg_ctx, env);
+    }
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_terminate_mgr_add_terminate_seq_msg");
+            "[sandesha2] Exit:sandesha2_terminate_mgr_send_terminate_seq_msg");
+
     return status;
 }
 
+static axis2_status_t AXIS2_CALL
+sandesha2_terminate_mgr_process_terminate_msg_response(
+    const axutil_env_t *env, 
+    axis2_msg_ctx_t *msg_ctx,
+    sandesha2_storage_mgr_t *storage_mgr)
+{
+    axis2_char_t *soap_ns_uri = NULL;
+    axis2_msg_ctx_t *response_msg_ctx = NULL;
+    axiom_soap_envelope_t *response_envelope = NULL;
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    axis2_engine_t *engine = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_endpoint_ref_t *to = NULL;
+   
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
+        "[sandesha2] Entry:sandesha2_terminate_mgr_process_terminate_msg_response");
+
+    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+
+    soap_ns_uri = axis2_msg_ctx_get_is_soap_11(msg_ctx, env) ?
+         AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI:
+         AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+
+    response_envelope = axis2_msg_ctx_get_response_soap_envelope(msg_ctx, env);
+    if(!response_envelope)
+    {
+        response_envelope = (axiom_soap_envelope_t *) axis2_http_transport_utils_create_soap_msg(env, 
+                msg_ctx, soap_ns_uri);
+        if(!response_envelope)
+        {
+            /* There is no response message context. */
+
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Response envelope not found");
+
+            return AXIS2_SUCCESS;
+        }
+    }
+
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+        "[sandesha2] Response envelope for CreateSequenceResponse message found");
+
+    response_msg_ctx = axis2_msg_ctx_create(env, conf_ctx, axis2_msg_ctx_get_transport_in_desc(msg_ctx, 
+                env), axis2_msg_ctx_get_transport_out_desc(msg_ctx, env));
+    
+    to = axis2_endpoint_ref_create(env, 
+        "http://localhost/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__");
+    axis2_msg_ctx_set_to(response_msg_ctx, env, to);
+
+    axis2_msg_ctx_set_wsa_action(response_msg_ctx, env, 
+            "http://localhost/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__");
+
+    axis2_msg_ctx_set_soap_envelope(response_msg_ctx, env, response_envelope);
+
+    /*axis2_msg_ctx_set_server_side(response_msg_ctx, env, AXIS2_TRUE);*/
+
+    axis2_msg_ctx_set_op_ctx(response_msg_ctx, env, axis2_msg_ctx_get_op_ctx(msg_ctx, env));
+    axis2_msg_ctx_set_svc_ctx(response_msg_ctx, env, axis2_msg_ctx_get_svc_ctx(msg_ctx, env));
+    axis2_msg_ctx_set_svc_grp_ctx(response_msg_ctx, env, axis2_msg_ctx_get_svc_grp_ctx(msg_ctx, env));
+    axis2_msg_ctx_set_conf_ctx(response_msg_ctx, env, conf_ctx);
+
+
+    engine = axis2_engine_create(env, conf_ctx);
+    if(engine)
+    {
+        if(sandesha2_util_is_fault_envelope(env, response_envelope))
+        {
+            status = axis2_engine_receive_fault(engine, env, response_msg_ctx);
+        }
+        else
+        {
+            status = axis2_engine_receive(engine, env, response_msg_ctx);
+        }
+            axis2_engine_free(engine, env);
+    }
+
+    axis2_msg_ctx_set_paused(response_msg_ctx, env, AXIS2_FALSE);
+    axis2_msg_ctx_free(response_msg_ctx, env);
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
+        "[sandesha2] Exit:sandesha2_terminate_mgr_process_terminate_msg_response");
+
+    return AXIS2_SUCCESS;
+}
+
+

Modified: webservices/sandesha/trunk/c/src/workers/sender.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/workers/sender.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/workers/sender.c (original)
+++ webservices/sandesha/trunk/c/src/workers/sender.c Thu Aug 28 23:56:29 2008
@@ -74,8 +74,7 @@
     axutil_thread_t *worker_thread = NULL;
     sandesha2_sender_args_t *args = NULL;
 
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Entry:sandesha2_sender_run_for_seq");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_sender_run_for_seq");
     
     axutil_allocator_switch_to_global_pool(env->allocator);
     args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_sender_args_t));
@@ -85,17 +84,18 @@
     args->seq_id = seq_id;
     args->persistent_msg_ctx = persistent_msg_ctx;
 
-    worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
-        sandesha2_sender_worker_func, (void*)args);
+    worker_thread = axutil_thread_pool_get_thread(env->thread_pool, sandesha2_sender_worker_func, 
+            (void*)args);
     if(!worker_thread)
     {
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
             "[sandesha2]Thread creation failed for sandesha2_sender_run");
         return AXIS2_FAILURE;
     }
+
     axutil_thread_pool_thread_detach(env->thread_pool, worker_thread);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_sender_run_for_seq");
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_sender_run_for_seq");
     return AXIS2_SUCCESS;
 }
 
@@ -194,6 +194,7 @@
         "[sandesha2]Exit:sandesha2_sender_worker_func");
     axutil_allocator_switch_to_local_pool(env->allocator);
 
+
     return NULL;
 }
 

Modified: webservices/sandesha/trunk/c/src/workers/sender_worker.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/workers/sender_worker.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/workers/sender_worker.c (original)
+++ webservices/sandesha/trunk/c/src/workers/sender_worker.c Thu Aug 28 23:56:29 2008
@@ -79,10 +79,10 @@
     sandesha2_storage_mgr_t *storage_mgr,
     int msg_type);
 
-static axis2_bool_t AXIS2_CALL
+/*static axis2_bool_t AXIS2_CALL
 sandesha2_sender_worker_is_fault_envelope(
     const axutil_env_t *env, 
-    axiom_soap_envelope_t *soap_envelope);
+    axiom_soap_envelope_t *soap_envelope);*/
 
 axis2_status_t AXIS2_CALL 
 sandesha2_sender_worker_free(
@@ -232,9 +232,8 @@
             sandesha2_sender_bean_free(sender_worker_bean, env);
         return AXIS2_SUCCESS;
     }
-    continue_sending = sandesha2_msg_retrans_adjuster_adjust_retrans(env,
-        sender_worker_bean, conf_ctx, storage_mgr, seq_prop_mgr, create_seq_mgr, 
-        sender_mgr);
+    continue_sending = sandesha2_msg_retrans_adjuster_adjust_retrans(env, sender_worker_bean, 
+            conf_ctx, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
     sandesha2_sender_mgr_update(sender_mgr, env, sender_worker_bean);
     if(!continue_sending)
     {
@@ -263,6 +262,8 @@
     }
     rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx);
     
+    msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env);
+
     prop_bean = sandesha2_utils_get_property_bean(env, 
         axis2_conf_ctx_get_conf(conf_ctx, env));
     if(prop_bean)
@@ -300,7 +301,6 @@
      *  This method is not implemented yet
      *  update_msg(sender_worker, env, msg_xtx);
      */
-    msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env);
     if(msg_type == SANDESHA2_MSG_TYPE_APPLICATION)
     {
         sandesha2_seq_t *seq = NULL;
@@ -310,13 +310,19 @@
         seq = sandesha2_msg_ctx_get_sequence(rm_msg_ctx, env);
         identifier = sandesha2_seq_get_identifier(seq, env);
         seq_id = sandesha2_identifier_get_identifier(identifier, env);
+        return AXIS2_SUCCESS;
+    }
+    if(msg_type == SANDESHA2_MSG_TYPE_ACK)
+    {
+        return AXIS2_SUCCESS;
     }
+
     if(sandesha2_sender_worker_is_piggybackable_msg_type(sender_worker, env,
         msg_type) && AXIS2_FALSE  == 
         sandesha2_sender_worker_is_ack_already_piggybacked(sender_worker, env,
         rm_msg_ctx))
     {
-        sandesha2_ack_mgr_piggyback_acks_if_present(env, rm_msg_ctx, 
+        sandesha2_ack_mgr_piggyback_acks_if_present(env, NULL, rm_msg_ctx,
             storage_mgr, seq_prop_mgr, sender_mgr);
     }
     
@@ -373,7 +379,7 @@
                     env), env);
         conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
         internal_seq_id = sandesha2_utils_get_seq_property(env, seq_id, 
-            SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID, seq_prop_mgr);
+            SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID, seq_prop_mgr);
         sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx,
             internal_seq_id, axis2_msg_ctx_get_server_side(msg_ctx, env), 
                 storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
@@ -386,15 +392,16 @@
     if(!resend && msg_type != SANDESHA2_MSG_TYPE_APPLICATION && 
         msg_type != SANDESHA2_MSG_TYPE_CREATE_SEQ)
     {
-        axis2_char_t *msg_stored_key = NULL;
+		axis2_char_t *msg_stored_key = NULL;
+
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "msg_type:%d*****************************", msg_type);
+        
         if(bean1)
         {
             msg_id = sandesha2_sender_bean_get_msg_id(bean1, env); 
             sandesha2_sender_mgr_remove(sender_mgr, env, msg_id);
-            msg_stored_key = sandesha2_sender_bean_get_msg_ctx_ref_key(
-                bean1, env);
-            sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-                msg_stored_key, conf_ctx, -1);
+            msg_stored_key = sandesha2_sender_bean_get_msg_ctx_ref_key(bean1, env);
+            sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, msg_stored_key, conf_ctx, -1);
         }
     }
     if(bean1)
@@ -456,9 +463,9 @@
         "[sandesha2]Entry:sandesha2_sender_worker_check_for_sync_res");
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
     
-    svr_side = axis2_msg_ctx_get_server_side(msg_ctx, env);
     if(!msg_ctx)
         return AXIS2_SUCCESS;
+    svr_side = axis2_msg_ctx_get_server_side(msg_ctx, env);
     soap_ns_uri = axis2_msg_ctx_get_is_soap_11(msg_ctx, env) ?
          AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI:
          AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
@@ -487,9 +494,7 @@
             soap_ns_uri);
         if(!res_envelope)
         {
-            if(msg_type == SANDESHA2_MSG_TYPE_CREATE_SEQ || msg_type ==
-                SANDESHA2_MSG_TYPE_TERMINATE_SEQ || msg_type ==
-                SANDESHA2_MSG_TYPE_ACK)
+            if(msg_type == SANDESHA2_MSG_TYPE_TERMINATE_SEQ || msg_type == SANDESHA2_MSG_TYPE_ACK)
             {
                 /* These are Sandesha2/C created messages. Also because there is 
                  * no response for these messages we can deduce that they are
@@ -621,23 +626,26 @@
         axis2_msg_ctx_set_soap_envelope(res_msg_ctx, env, res_envelope);
         engine = axis2_engine_create(env, axis2_msg_ctx_get_conf_ctx(msg_ctx, 
             env));
-        if(AXIS2_TRUE == sandesha2_sender_worker_is_fault_envelope(env, 
-            res_envelope))
+        if(sandesha2_util_is_fault_envelope(env, res_envelope))
+        {
             axis2_engine_receive_fault(engine, env, res_msg_ctx);
+        }
         else
+        {
             axis2_engine_receive(engine, env, res_msg_ctx);
+        }
         if(engine)
+        {
             axis2_engine_free(engine, env);
+        }
     }
-    if(msg_type == SANDESHA2_MSG_TYPE_CREATE_SEQ || msg_type ==
-        SANDESHA2_MSG_TYPE_TERMINATE_SEQ || msg_type == SANDESHA2_MSG_TYPE_ACK)
+    if(msg_type == SANDESHA2_MSG_TYPE_TERMINATE_SEQ || msg_type == SANDESHA2_MSG_TYPE_ACK)
     {
         axis2_op_ctx_t *op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx,
             env);
         axis2_op_ctx_free(op_ctx, env);
     }
-    if(msg_type == SANDESHA2_MSG_TYPE_CREATE_SEQ || msg_type == 
-            SANDESHA2_MSG_TYPE_APPLICATION)
+    if(msg_type == SANDESHA2_MSG_TYPE_APPLICATION)
     {
         axis2_op_ctx_t *op_ctx = axis2_msg_ctx_get_op_ctx(res_msg_ctx, env);
         axis2_op_ctx_free(op_ctx, env);
@@ -647,22 +655,6 @@
     return AXIS2_SUCCESS;
 }
 
-static axis2_bool_t AXIS2_CALL
-sandesha2_sender_worker_is_fault_envelope(
-    const axutil_env_t *env, 
-    axiom_soap_envelope_t *soap_envelope)
-{
-    axiom_soap_fault_t *fault = NULL;
-    AXIS2_PARAM_CHECK(env->error, soap_envelope, AXIS2_FAILURE);
-    
-    fault = axiom_soap_body_get_fault(axiom_soap_envelope_get_body(soap_envelope,
-        env), env);
-    if(fault)
-        return AXIS2_TRUE;
-        
-    return AXIS2_FALSE;
-}
-
 void sandesha2_sender_worker_set_transport_out(
     sandesha2_sender_worker_t *sender_worker,
     const axutil_env_t *env,

Modified: webservices/sandesha/trunk/c/src/wsrm/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/Makefile.am?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/Makefile.am (original)
+++ webservices/sandesha/trunk/c/src/wsrm/Makefile.am Thu Aug 28 23:56:29 2008
@@ -3,7 +3,9 @@
 
 libsandesha2_wsrm_la_SOURCES = ack_final.c\
                                identifier.c\
+                               endpoint.c\
                                address.c\
+                               mc_address.c\
                                acks_to.c\
 							   nack.c\
                                accept.c\

Modified: webservices/sandesha/trunk/c/src/wsrm/accept.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/accept.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/accept.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/accept.c Thu Aug 28 23:56:29 2008
@@ -63,7 +63,6 @@
     
     accept->rm_ns_val = (axis2_char_t *)axutil_strdup(env ,rm_ns_val);
     accept->addr_ns_val = (axis2_char_t *)axutil_strdup(env, addr_ns_val);
-    accept->acks_to = NULL;
     
 	return accept;
 }
@@ -74,18 +73,26 @@
     sandesha2_accept_t *accept, 
     const axutil_env_t *env)
 {
-    if(NULL != accept->addr_ns_val)
+    if(accept->addr_ns_val)
     {
         AXIS2_FREE(env->allocator, accept->addr_ns_val);
         accept->addr_ns_val = NULL;
     }
-    if(NULL != accept->rm_ns_val)
+
+    if(accept->rm_ns_val)
     {
         AXIS2_FREE(env->allocator, accept->rm_ns_val);
         accept->rm_ns_val = NULL;
     }
+    
+    if(accept->acks_to)
+    {
+        sandesha2_acks_to_free(accept->acks_to, env);
+        accept->acks_to = NULL;
+    }
         
 	AXIS2_FREE(env->allocator, accept);
+
 	return AXIS2_SUCCESS;
 }
 
@@ -136,16 +143,24 @@
             AXIS2_FAILURE);
         return NULL;
     }
-    accept->acks_to = sandesha2_acks_to_create(env, NULL, 
-        accept->rm_ns_val, accept->addr_ns_val);
-    if(NULL == accept->acks_to)
+    
+    if(accept->acks_to)
+    {
+        sandesha2_acks_to_free(accept->acks_to, env);
+        accept->acks_to = NULL;
+    }
+
+    accept->acks_to = sandesha2_acks_to_create(env, NULL, accept->rm_ns_val, accept->addr_ns_val);
+    if(!accept->acks_to)
     {
         return NULL;
     }
+
     if(!sandesha2_acks_to_from_om_node(accept->acks_to, env, child_om_node))
     {
         return NULL;
     }
+
     return accept;
 }
 
@@ -192,7 +207,12 @@
     const axutil_env_t *env, 
     sandesha2_acks_to_t *acks_to)
 {
-    /* TODO free old acks_to ?*/
+    if(accept->acks_to)
+    {
+        sandesha2_acks_to_free(accept->acks_to, env);
+        accept->acks_to = NULL;
+    }
+
     accept->acks_to = acks_to;
     return AXIS2_SUCCESS;
 }
@@ -214,7 +234,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/ack_final.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/ack_final.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/ack_final.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/ack_final.c Thu Aug 28 23:56:29 2008
@@ -157,7 +157,7 @@
     {
         return AXIS2_FALSE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     } 

Modified: webservices/sandesha/trunk/c/src/wsrm/ack_none.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/ack_none.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/ack_none.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/ack_none.c Thu Aug 28 23:56:29 2008
@@ -163,7 +163,7 @@
     {
         return AXIS2_FALSE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/ack_range.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/ack_range.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/ack_range.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/ack_range.c Thu Aug 28 23:56:29 2008
@@ -260,7 +260,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/ack_requested.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/ack_requested.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/ack_requested.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/ack_requested.c Thu Aug 28 23:56:29 2008
@@ -234,10 +234,10 @@
 {
  	if(ack_requested->identifier)
 	{
-		/*
-		SANDESHA2_IDENTIFIER_FREE(ack_requested->identifier, env);
+		
+		sandesha2_identifier_free(ack_requested->identifier, env);
 		ack_requested->identifier = NULL;
-		*/
+		
 	}
 	ack_requested->identifier = identifier;
  	return AXIS2_SUCCESS;
@@ -295,7 +295,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/acks_to.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/acks_to.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/acks_to.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/acks_to.c Thu Aug 28 23:56:29 2008
@@ -83,7 +83,11 @@
         AXIS2_FREE(env->allocator, acks_to->rm_ns_val);
         acks_to->rm_ns_val = NULL;
     }
-    acks_to->address = NULL;
+    if(acks_to->address)
+    {
+        sandesha2_address_free(acks_to->address, env);
+        acks_to->address = NULL;
+    }
     
 	AXIS2_FREE(env->allocator, acks_to);
 	return AXIS2_SUCCESS;
@@ -134,8 +138,14 @@
             AXIS2_FAILURE);
         return NULL;
     }
-    acks_to->address = sandesha2_address_create(env, 
-        acks_to->addr_ns_val, NULL);
+
+    if(acks_to->address)
+    {
+        sandesha2_address_free(acks_to->address, env);
+        acks_to->address = NULL;
+    }
+
+    acks_to->address = sandesha2_address_create(env, acks_to->addr_ns_val, NULL);
     if(NULL == acks_to->address)
     {
         return NULL;
@@ -159,21 +169,19 @@
     
     AXIS2_PARAM_CHECK(env->error, om_node, NULL);
     
-    if(NULL == acks_to->address)
+    if(!acks_to->address)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_OM_NULL_ELEMENT, 
-            AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_OM_NULL_ELEMENT, AXIS2_FAILURE);
         return NULL;
     }
-    rm_ns = axiom_namespace_create(env, acks_to->rm_ns_val,
-        SANDESHA2_WSRM_COMMON_NS_PREFIX_RM);
-    if(NULL == rm_ns)
+    rm_ns = axiom_namespace_create(env, acks_to->rm_ns_val, SANDESHA2_WSRM_COMMON_NS_PREFIX_RM);
+    if(!rm_ns)
     {
         return NULL;
     }
-    at_element = axiom_element_create(env, NULL, 
-        SANDESHA2_WSRM_COMMON_ACKS_TO, rm_ns, &at_node);
-    if(NULL == at_element)
+
+    at_element = axiom_element_create(env, NULL, SANDESHA2_WSRM_COMMON_ACKS_TO, rm_ns, &at_node);
+    if(!at_element)
     {
         return NULL;
     }
@@ -196,7 +204,14 @@
 	const axutil_env_t *env, 
     sandesha2_address_t *address) 
 {
+    if(acks_to->address)
+    {
+        sandesha2_address_free(acks_to->address, env);
+        acks_to->address = NULL;
+    }
+
 	acks_to->address = address;
+
     return AXIS2_SUCCESS;
 }
     
@@ -209,7 +224,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/address.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/address.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/address.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/address.c Thu Aug 28 23:56:29 2008
@@ -68,7 +68,13 @@
         AXIS2_FREE(env->allocator, address->ns_val);
         address->ns_val = NULL;
     }
-    address->epr = NULL;
+    
+    if(address->epr)
+    {
+        axis2_endpoint_ref_free(address->epr, env);
+        address->epr = NULL;
+    }
+
 	AXIS2_FREE(env->allocator, address);
 	return AXIS2_SUCCESS;
 }
@@ -123,7 +129,15 @@
             AXIS2_FAILURE);
         return NULL;
     }
+
+    if(address->epr)
+    {
+        axis2_endpoint_ref_free(address->epr, env);
+        address->epr = NULL;
+    }
+
     address->epr = axis2_endpoint_ref_create(env, str_address);
+
     if(!address->epr)
     {
         return NULL;
@@ -186,6 +200,13 @@
     axis2_endpoint_ref_t *epr)
 {
     AXIS2_PARAM_CHECK(env->error, epr, AXIS2_FAILURE);
+    
+    if(address->epr)
+    {
+        axis2_endpoint_ref_free(address->epr, env);
+        address->epr = NULL;
+    }
+
 	address->epr = epr;
     return AXIS2_SUCCESS;
 }
@@ -199,7 +220,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/close_seq.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/close_seq.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/close_seq.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/close_seq.c Thu Aug 28 23:56:29 2008
@@ -180,10 +180,10 @@
 {
  	if(close_seq->identifier)
 	{
-	    /*
-		SANDESHA2_IDENTIFIER_FREE(close_seq->identifier, env);
+	    
+		sandesha2_identifier_free(close_seq->identifier, env);
 		close_seq->identifier = NULL;
-		*/
+	
 	}
 	close_seq->identifier = identifier;
  	return AXIS2_SUCCESS;
@@ -227,7 +227,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/close_seq_res.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/close_seq_res.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/close_seq_res.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/close_seq_res.c Thu Aug 28 23:56:29 2008
@@ -184,10 +184,8 @@
 {
  	if(close_seq_res->identifier)
 	{
-	    /*
-		SANDESHA2_IDENTIFIER_FREE(close_seq_res->identifier, env);
+		sandesha2_identifier_free(close_seq_res->identifier, env);
 		close_seq_res->identifier = NULL;
-		*/
 	}
 	close_seq_res->identifier = identifier;
  	return AXIS2_SUCCESS;
@@ -230,7 +228,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/create_seq.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/create_seq.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/create_seq.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/create_seq.c Thu Aug 28 23:56:29 2008
@@ -84,7 +84,7 @@
 }
 
 axis2_status_t AXIS2_CALL 
-sandesha2_create_seq_free (
+sandesha2_create_seq_free(
     sandesha2_create_seq_t *create_seq, 
     const axutil_env_t *env)
 {
@@ -98,10 +98,23 @@
         AXIS2_FREE(env->allocator, create_seq->addr_ns_val);
         create_seq->addr_ns_val = NULL;
     }
-    create_seq->acks_to = NULL;
+
+ 	if(create_seq->acks_to)
+	{
+		sandesha2_acks_to_free(create_seq->acks_to, env);
+		create_seq->acks_to = NULL;
+	}
+
     create_seq->expires = NULL;
-    create_seq->seq_offer = NULL;
+
+    if(create_seq->seq_offer)
+    {
+        sandesha2_seq_offer_free(create_seq->seq_offer, env);
+        create_seq->seq_offer = NULL;
+    }
+
 	AXIS2_FREE(env->allocator, create_seq);
+
 	return AXIS2_SUCCESS;
 }
 
@@ -160,7 +173,7 @@
     if(offer_part)
     {
         create_seq->seq_offer = sandesha2_seq_offer_create(env, 
-            create_seq->rm_ns_val);  
+            create_seq->rm_ns_val, create_seq->addr_ns_val);  
         if(!create_seq->seq_offer)
         {
             return NULL;
@@ -324,7 +337,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/create_seq_res.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/create_seq_res.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/create_seq_res.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/create_seq_res.c Thu Aug 28 23:56:29 2008
@@ -46,21 +46,21 @@
     AXIS2_PARAM_CHECK(env->error, rm_ns_val, NULL);
     AXIS2_PARAM_CHECK(env->error, addr_ns_val, NULL);
     
-    if(AXIS2_FALSE == sandesha2_create_seq_res_is_namespace_supported(env, rm_ns_val))
+    if(!sandesha2_create_seq_res_is_namespace_supported(env, rm_ns_val))
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_UNSUPPORTED_NS, 
-            AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_UNSUPPORTED_NS, AXIS2_FAILURE);
         return NULL;
-    }    
-    create_seq_res =  (sandesha2_create_seq_res_t *)AXIS2_MALLOC 
-        (env->allocator, 
-        sizeof(sandesha2_create_seq_res_t));
+    }
+
+    create_seq_res =  (sandesha2_create_seq_res_t *) AXIS2_MALLOC(env->allocator, 
+            sizeof(sandesha2_create_seq_res_t));
 	
     if(!create_seq_res)
 	{
 		AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
 	}
+
     create_seq_res->rm_ns_val = NULL;
     create_seq_res->addr_ns_val = NULL;
     create_seq_res->identifier = NULL;
@@ -99,7 +99,27 @@
         AXIS2_FREE(env->allocator, create_seq_res->rm_ns_val);
         create_seq_res->rm_ns_val = NULL;
     }
+    
+    if(create_seq_res->identifier)
+    {
+        sandesha2_identifier_free(create_seq_res->identifier, env);
+        create_seq_res->identifier = NULL;
+    }
+
+    if(create_seq_res->accept)
+    {
+        sandesha2_accept_free(create_seq_res->accept, env);
+        create_seq_res->accept = NULL;
+    }
+
+    if(create_seq_res->expires)
+    {
+        sandesha2_expires_free(create_seq_res->expires, env);
+        create_seq_res->expires = NULL;
+    }
+
 	AXIS2_FREE(env->allocator, create_seq_res);
+
 	return AXIS2_SUCCESS;
 }
 
@@ -131,12 +151,10 @@
     csr_part =axiom_node_get_data_element(csr_node, env);
     if(!csr_part)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_OM_ELEMENT,
-            AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_OM_ELEMENT, AXIS2_FAILURE);
         return NULL;
     }
-    create_seq_res->identifier = sandesha2_identifier_create(env, 
-        create_seq_res->rm_ns_val);
+    create_seq_res->identifier = sandesha2_identifier_create(env, create_seq_res->rm_ns_val);
     if(!create_seq_res->identifier)
     {
         return NULL;
@@ -181,8 +199,15 @@
         axutil_qname_free(acc_qname, env);
     if(acc_part)
     {
-        create_seq_res->accept = sandesha2_accept_create(env, 
-            create_seq_res->rm_ns_val, create_seq_res->addr_ns_val);
+        if(create_seq_res->accept)
+        {
+            sandesha2_accept_free(create_seq_res->accept, env);
+            create_seq_res->accept = NULL;
+        }
+
+        create_seq_res->accept = sandesha2_accept_create(env, create_seq_res->rm_ns_val, 
+                create_seq_res->addr_ns_val);
+
         if(!create_seq_res->accept)
         {
             return NULL;
@@ -234,6 +259,7 @@
     {
         sandesha2_expires_to_om_node(create_seq_res->expires, env, csr_node);
     }
+
     axiom_node_add_child((axiom_node_t*)om_node, env, csr_node);
     return (axiom_node_t*)om_node;
 }
@@ -244,6 +270,12 @@
     const axutil_env_t *env, 
     sandesha2_identifier_t *identifier)
 {
+    if(create_seq_res->identifier)
+    {
+        sandesha2_identifier_free(create_seq_res->identifier, env);
+        create_seq_res->identifier = NULL;
+    }
+
     create_seq_res->identifier = identifier;
     return AXIS2_SUCCESS;
 }
@@ -262,6 +294,12 @@
     sandesha2_create_seq_res_t *create_seq_res,
     const axutil_env_t *env, sandesha2_accept_t *accept)
 {
+    if(create_seq_res->accept)
+    {
+        sandesha2_accept_free(create_seq_res->accept, env);
+        create_seq_res->accept = NULL;
+    }
+    
     create_seq_res->accept = accept;
     return AXIS2_SUCCESS;
 }
@@ -280,6 +318,12 @@
     sandesha2_create_seq_res_t *create_seq_res,
     const axutil_env_t *env, sandesha2_expires_t *expires)
 {
+    if(create_seq_res->expires)
+    {
+        sandesha2_expires_free(create_seq_res->expires, env);
+        create_seq_res->expires = NULL;
+    }
+
     create_seq_res->expires = expires;
     return AXIS2_SUCCESS;
 }
@@ -331,7 +375,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/expires.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/expires.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/expires.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/expires.c Thu Aug 28 23:56:29 2008
@@ -210,7 +210,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }

Modified: webservices/sandesha/trunk/c/src/wsrm/fault_code.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/wsrm/fault_code.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/wsrm/fault_code.c (original)
+++ webservices/sandesha/trunk/c/src/wsrm/fault_code.c Thu Aug 28 23:56:29 2008
@@ -212,7 +212,7 @@
     {
         return AXIS2_TRUE;
     }
-    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(namespace, SANDESHA2_SPEC_2007_02_NS_URI))
     {
         return AXIS2_TRUE;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org


Mime
View raw message