Author: damitha
Date: Wed Jan 16 17:38:24 2008
New Revision: 612676

URL: http://svn.apache.org/viewvc?rev=612676&view=rev
Log:
Fixing memory leaks

Modified:
    webservices/sandesha/trunk/c/include/sandesha2_constants.h
    webservices/sandesha/trunk/c/include/sandesha2_storage_mgr.h
    webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c
    webservices/sandesha/trunk/c/src/msgprocessors/ack_msg_processor.c
    webservices/sandesha/trunk/c/src/msgprocessors/ack_req_msg_processor.c
    webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c
    
webservices/sandesha/trunk/c/src/msgprocessors/create_seq_res_msg_processor.c
    
webservices/sandesha/trunk/c/src/msgprocessors/make_connection_msg_processor.c
    webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c
    webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c
    webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c
    webservices/sandesha/trunk/c/src/util/ack_mgr.c
    webservices/sandesha/trunk/c/src/util/msg_creator.c
    webservices/sandesha/trunk/c/src/util/msg_init.c
    webservices/sandesha/trunk/c/src/util/sandesha2_utils.c
    webservices/sandesha/trunk/c/src/util/terminate_mgr.c
    webservices/sandesha/trunk/c/src/workers/in_order_invoker.c
    webservices/sandesha/trunk/c/src/workers/sender_worker.c

Modified: webservices/sandesha/trunk/c/include/sandesha2_constants.h
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_constants.h?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/include/sandesha2_constants.h (original)
+++ webservices/sandesha/trunk/c/include/sandesha2_constants.h Wed Jan 16 
17:38:24 2008
@@ -471,7 +471,7 @@
        #define SANDESHA2_PERMANENT_STORAGE_MGR  "persistent"
        
     #define SANDESHA2_MSG_CTX_MAP  "msg_ctx_map"
-       
+    
        #define SANDESHA2_DEFAULT_STORAGE_MGR "persistent"
        
        #define SANDESHA2_SENDER  "Sender"

Modified: webservices/sandesha/trunk/c/include/sandesha2_storage_mgr.h
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_storage_mgr.h?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/include/sandesha2_storage_mgr.h (original)
+++ webservices/sandesha/trunk/c/include/sandesha2_storage_mgr.h Wed Jan 16 
17:38:24 2008
@@ -96,7 +96,8 @@
                 sandesha2_storage_mgr_t *storage_mgr,
                 const axutil_env_t *env,
                 axis2_char_t *key,
-                axis2_conf_ctx_t *conf_ctx);
+                axis2_conf_ctx_t *conf_ctx,
+                int msg_type);
 
     axis2_status_t (AXIS2_CALL *
             init_storage)(
@@ -215,7 +216,8 @@
     sandesha2_storage_mgr_t *storage_mgr,
     const axutil_env_t *env,
     axis2_char_t *key,
-    axis2_conf_ctx_t *conf_ctx);
+    axis2_conf_ctx_t *conf_ctx,
+    int msg_type);
 
 axis2_status_t AXIS2_CALL
 sandesha2_storage_mgr_init_storage(

Modified: webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c (original)
+++ webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c Wed Jan 16 
17:38:24 2008
@@ -128,16 +128,16 @@
     }
     rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx);
 
-    if(!AXIS2_ERROR_GET_STATUS_CODE(env->error))
+    /*if(!AXIS2_ERROR_GET_STATUS_CODE(env->error))
     {
-        /* Message should not be sent in an exception situation */
+        // Message should not be sent in an exception situation
         axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
             "[sandesha2] Cannot initialize the message");
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_INIT_MSG, 
                 AXIS2_FAILURE);
         return AXIS2_FAILURE;
-    }
+    }*/
     /* 
      * TODO Validate the message
      * sandesha2_msg_validator_validate(env, rm_msg_ctx);

Modified: webservices/sandesha/trunk/c/src/msgprocessors/ack_msg_processor.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/ack_msg_processor.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/msgprocessors/ack_msg_processor.c 
(original)
+++ webservices/sandesha/trunk/c/src/msgprocessors/ack_msg_processor.c Wed Jan 
16 17:38:24 2008
@@ -190,8 +190,8 @@
     
     dbname = sandesha2_util_get_dbname(env, conf_ctx); 
     storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
-    sandesha2_seq_ack_set_must_understand(seq_ack, env, AXIS2_FALSE);
-    sandesha2_msg_ctx_add_soap_envelope(rm_msg_ctx, env);
+    /*sandesha2_seq_ack_set_must_understand(seq_ack, env, AXIS2_FALSE);
+    sandesha2_msg_ctx_add_soap_envelope(rm_msg_ctx, env);*/
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
     sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
@@ -325,7 +325,7 @@
                     sandesha2_sender_bean_get_msg_id(retrans_bean, env));
                 sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env,
                     sandesha2_sender_bean_get_msg_ctx_ref_key(retrans_bean, 
-                        env), conf_ctx);
+                        env), conf_ctx, msg_type);
             }
             add_no = AXIS2_MALLOC(env->allocator, sizeof(long));
             *add_no = (long)j;

Modified: webservices/sandesha/trunk/c/src/msgprocessors/ack_req_msg_processor.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/ack_req_msg_processor.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/msgprocessors/ack_req_msg_processor.c 
(original)
+++ webservices/sandesha/trunk/c/src/msgprocessors/ack_req_msg_processor.c Wed 
Jan 16 17:38:24 2008
@@ -367,7 +367,7 @@
                 msg_stored_key = sandesha2_sender_bean_get_msg_ctx_ref_key(
                     old_ack_bean, env);
                 sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-                    msg_stored_key, conf_ctx);
+                    msg_stored_key, conf_ctx, -1);
             }
         }
         sandesha2_sender_bean_set_time_to_send(ack_bean, env, time_to_send); 

Modified: webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c 
(original)
+++ webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c Wed Jan 
16 17:38:24 2008
@@ -456,8 +456,8 @@
         sandesha2_seq_property_bean_t *highest_msg_key_bean = NULL;
         sandesha2_seq_property_bean_t *highest_msg_id_bean = NULL;
         const axis2_char_t *msg_id = NULL;
-        axiom_soap_envelope_t *response_envelope = NULL;
-        int soap_version = -1;
+        /*axiom_soap_envelope_t *response_envelope = NULL;*/
+        /*int soap_version = -1;*/
         axutil_property_t *property = NULL;
         axis2_char_t *client_seq_key = NULL;
         
@@ -473,10 +473,10 @@
             str_seq_id, SANDESHA2_SEQ_PROP_HIGHEST_IN_MSG_ID, 
                 (axis2_char_t *)msg_id);
         sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-            highest_in_msg_key_str, conf_ctx);
+            highest_in_msg_key_str, conf_ctx, -1);
         sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, 
             highest_in_msg_key_str, msg_ctx);
-        response_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+        /*response_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);*/
         property = axis2_msg_ctx_get_property(msg_ctx, env, 
             SANDESHA2_CLIENT_SEQ_KEY);
         if(property)
@@ -490,7 +490,7 @@
             AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
                 "[sandesha2]Client sequence key not found");
         }
-        if(client_seq_key)
+        /*if(client_seq_key)
         {
             if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
                 soap_version = SANDESHA2_SOAP_VERSION_1_1;
@@ -503,7 +503,7 @@
                 sandesha2_storage_mgr_store_response(storage_mgr, env, 
                     client_seq_key, response_envelope, msg_no, soap_version);
             }
-        }
+        }*/
         if(highest_in_msg_no_str)
         {
             sandesha2_seq_property_mgr_update(seq_prop_mgr, env, 

Modified: 
webservices/sandesha/trunk/c/src/msgprocessors/create_seq_res_msg_processor.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/create_seq_res_msg_processor.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/c/src/msgprocessors/create_seq_res_msg_processor.c 
(original)
+++ 
webservices/sandesha/trunk/c/src/msgprocessors/create_seq_res_msg_processor.c 
Wed Jan 16 17:38:24 2008
@@ -311,7 +311,7 @@
     create_seq_storage_key = sandesha2_sender_bean_get_msg_ctx_ref_key(
                         create_seq_sender_bean, env);
     sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-        create_seq_storage_key, conf_ctx);
+        create_seq_storage_key, conf_ctx, SANDESHA2_MSG_TYPE_CREATE_SEQ);
     if(create_seq_sender_bean)
         sandesha2_sender_bean_free(create_seq_sender_bean, env);
     sandesha2_sender_mgr_remove(sender_mgr, env, create_seq_msg_id);

Modified: 
webservices/sandesha/trunk/c/src/msgprocessors/make_connection_msg_processor.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/make_connection_msg_processor.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/c/src/msgprocessors/make_connection_msg_processor.c 
(original)
+++ 
webservices/sandesha/trunk/c/src/msgprocessors/make_connection_msg_processor.c 
Wed Jan 16 17:38:24 2008
@@ -478,7 +478,7 @@
             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);
+                msg_stored_key, conf_ctx, -1);
         }
         if(bean1)
             sandesha2_sender_bean_free(bean1, env);

Modified: webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c Wed Jan 16 
17:38:24 2008
@@ -94,9 +94,11 @@
     sandesha2_storage_mgr_t *storage_mgr,
     const axutil_env_t *env,
     axis2_char_t *key,
-    axis2_conf_ctx_t *conf_ctx)
+    axis2_conf_ctx_t *conf_ctx,
+    int msg_type)
 {
-     return storage_mgr->ops->remove_msg_ctx(storage_mgr, env, key, conf_ctx);
+     return storage_mgr->ops->remove_msg_ctx(storage_mgr, env, key, conf_ctx, 
+         msg_type);
 }
 
 axis2_status_t AXIS2_CALL

Modified: 
webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c 
(original)
+++ webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c Wed 
Jan 16 17:38:24 2008
@@ -42,6 +42,7 @@
 #include <axiom_xml_reader.h>
 #include <axiom_stax_builder.h>
 #include <axiom_soap_builder.h>
+#include <platforms/axutil_platform_auto_sense.h>
 
 /** 
  * @brief Sandesha2 Permanent Storage Manager Struct Impl
@@ -99,7 +100,8 @@
     sandesha2_storage_mgr_t *storage,
     const axutil_env_t *env,
     axis2_char_t *key,
-    axis2_conf_ctx_t *conf_ctx);
+    axis2_conf_ctx_t *conf_ctx,
+    int msg_type);
 
 axis2_status_t AXIS2_CALL
 sandesha2_permanent_storage_mgr_init_storage(
@@ -253,6 +255,7 @@
         if(property)
         {
             msg_ctx_map = axutil_property_get_value(property, env);
+
             axutil_hash_set(msg_ctx_map, axutil_strdup(env, key), 
                 AXIS2_HASH_KEY_STRING, msg_ctx);
         }
@@ -287,8 +290,10 @@
         {
             msg_ctx_map = axutil_property_get_value(property, env);
             if(msg_ctx_map)
+            {
                 axutil_hash_set(msg_ctx_map, key, AXIS2_HASH_KEY_STRING, 
                     msg_ctx);
+            }
         }
     }
 
@@ -308,12 +313,14 @@
     sandesha2_storage_mgr_t *storage_mgr,
     const axutil_env_t *env,
     axis2_char_t *key,
-    axis2_conf_ctx_t *conf_ctx)
+    axis2_conf_ctx_t *conf_ctx,
+    int msg_type)
 {
     sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL;
     storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr);
     {
         void *entry = NULL;
+        axis2_msg_ctx_t *msg_ctx = NULL;
         axutil_property_t *property = NULL;
         axis2_ctx_t *ctx = axis2_conf_ctx_get_base(conf_ctx, env);
         axutil_hash_t *msg_ctx_map = NULL;
@@ -323,14 +330,24 @@
         {
             msg_ctx_map = axutil_property_get_value(property, env);
             if(msg_ctx_map)
+            {
                 entry = axutil_hash_get(msg_ctx_map, key, 
AXIS2_HASH_KEY_STRING);
+                msg_ctx = (axis2_msg_ctx_t *) entry;
+            }
             if(entry)
             {
                 axis2_op_ctx_t *op_ctx = NULL;
                 op_ctx = 
-                    axis2_msg_ctx_get_op_ctx((axis2_msg_ctx_t *) entry, env);
+                    axis2_msg_ctx_get_op_ctx(msg_ctx, env);
                 axis2_op_ctx_set_in_use(op_ctx, env, AXIS2_FALSE);
                 axutil_hash_set(msg_ctx_map, key, AXIS2_HASH_KEY_STRING, NULL);
+                if(msg_type != SANDESHA2_MSG_TYPE_APPLICATION && 
+                    msg_type !=SANDESHA2_MSG_TYPE_CREATE_SEQ)
+                {
+                    axis2_msg_ctx_set_keep_alive(msg_ctx, env, AXIS2_FALSE);
+                    axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_FALSE);
+                    axis2_msg_ctx_free(msg_ctx, env);
+                }
             }
         }
     }

Modified: 
webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c 
(original)
+++ webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c Wed 
Jan 16 17:38:24 2008
@@ -193,10 +193,10 @@
     sandesha2_storage_mgr_update_msg_ctx(storage_mgr, env, key, msg_ctx);
     if(storage_mgr)
         sandesha2_storage_mgr_free(storage_mgr, env);
-    if(msg_ctx)
+    /*if(msg_ctx)
     {
         axis2_msg_ctx_free(msg_ctx, env);
-    }
+    }*/
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
          "[sandesha2]Exit:sandesha2_transport_sender_invoke");
     return AXIS2_SUCCESS;

Modified: webservices/sandesha/trunk/c/src/util/ack_mgr.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/ack_mgr.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/util/ack_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/util/ack_mgr.c Wed Jan 16 17:38:24 2008
@@ -348,7 +348,7 @@
             sandesha2_sender_mgr_remove(sender_mgr, env, 
                 sandesha2_sender_bean_get_msg_id(sender_bean, env));
             sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-                msg_ctx_ref_key, conf_ctx);
+                msg_ctx_ref_key, conf_ctx, -1);
             ack_rm_msg = sandesha2_msg_init_init_msg(env, msg_ctx1);
             if(SANDESHA2_MSG_TYPE_ACK != 
sandesha2_msg_ctx_get_msg_type(ack_rm_msg, 
                 env))

Modified: webservices/sandesha/trunk/c/src/util/msg_creator.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/msg_creator.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/util/msg_creator.c (original)
+++ webservices/sandesha/trunk/c/src/util/msg_creator.c Wed Jan 16 17:38:24 2008
@@ -537,7 +537,7 @@
     sandesha2_identifier_t *identifier = NULL;
 
     ref_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ref_rm_msg, env);
-    axis2_msg_ctx_set_keep_alive(ref_msg_ctx, env, AXIS2_TRUE);
+    /*axis2_msg_ctx_set_keep_alive(ref_msg_ctx, env, AXIS2_TRUE);*/
     if(!ref_msg_ctx)
     {
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_MSG_CTX,

Modified: webservices/sandesha/trunk/c/src/util/msg_init.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/msg_init.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/util/msg_init.c (original)
+++ webservices/sandesha/trunk/c/src/util/msg_init.c Wed Jan 16 17:38:24 2008
@@ -131,6 +131,8 @@
     /* If client side and the addressing version is not set. 
      * Assuming the default addressing version.
      */
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+        "[sandesha2]Entry:populate_rm_msg_ctx");
     if(msg_ctx)
         ctx = axis2_msg_ctx_get_base(msg_ctx, env);
     prop = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION);
@@ -267,6 +269,8 @@
     }
     if(rm_elements)
         sandesha2_rm_elements_free(rm_elements, env);
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+        "[sandesha2]Exit:populate_rm_msg_ctx");
     return AXIS2_SUCCESS;
 }
 

Modified: webservices/sandesha/trunk/c/src/util/sandesha2_utils.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/sandesha2_utils.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/util/sandesha2_utils.c (original)
+++ webservices/sandesha/trunk/c/src/util/sandesha2_utils.c Wed Jan 16 17:38:24 
2008
@@ -650,7 +650,7 @@
         env));
     axutil_allocator_switch_to_local_pool(env->allocator);
     axis2_msg_ctx_set_op_ctx(new_msg, env, op_ctx);
-     axis2_op_ctx_add_msg_ctx(op_ctx, env, new_msg);
+    /*axis2_op_ctx_add_msg_ctx(op_ctx, env, new_msg);*/
     
     soap_env = axiom_soap_envelope_create_default_soap_envelope(env, 
                         sandesha2_utils_get_soap_version(env, 
@@ -1382,8 +1382,8 @@
 
      axis2_msg_ctx_set_is_soap_11(new_msg_ctx, env,
              axis2_msg_ctx_get_is_soap_11(in_msg_ctx, env));
-     axis2_msg_ctx_set_keep_alive(new_msg_ctx, env,
-             axis2_msg_ctx_is_keep_alive(in_msg_ctx, env));
+     /*axis2_msg_ctx_set_keep_alive(new_msg_ctx, env,
+             axis2_msg_ctx_is_keep_alive(in_msg_ctx, env));*/
 
     axis2_msg_ctx_set_charset_encoding(new_msg_ctx, env,
         axis2_msg_ctx_get_charset_encoding(in_msg_ctx, env));

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=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/util/terminate_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/util/terminate_mgr.c Wed Jan 16 17:38:24 
2008
@@ -252,7 +252,7 @@
             if(key)
             {
                 sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, 
-                    conf_ctx);
+                    conf_ctx, -1);
             }
             seq_id = sandesha2_next_msg_bean_get_seq_id(bean, env);
             if(seq_id)
@@ -264,7 +264,7 @@
     if(highest_in_msg_key)
     {
         sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
-            highest_in_msg_key, conf_ctx);
+            highest_in_msg_key, conf_ctx, -1);
         if(highest_in_msg_key)
             AXIS2_FREE(env->allocator, highest_in_msg_key);
     }
@@ -357,7 +357,7 @@
                         "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);
+                        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, 
@@ -570,7 +570,7 @@
             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);
+                msg_store_key, conf_ctx, -1);
         }
     }
     
@@ -593,7 +593,7 @@
                 create_seq_bean, env);
             if(key) 
                sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, 
-                   conf_ctx);
+                   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"\
@@ -636,7 +636,7 @@
                         "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);
+                        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, 

Modified: webservices/sandesha/trunk/c/src/workers/in_order_invoker.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/workers/in_order_invoker.c?rev=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/workers/in_order_invoker.c (original)
+++ webservices/sandesha/trunk/c/src/workers/in_order_invoker.c Wed Jan 16 
17:38:24 2008
@@ -404,12 +404,12 @@
                 }
                 invoked = AXIS2_TRUE;
                 sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, key, 
-                    invoker->conf_ctx);
+                    invoker->conf_ctx, -1);
                 msg_ctx = sandesha2_storage_mgr_retrieve_msg_ctx(
                     storage_mgr, env, key, invoker->conf_ctx, AXIS2_FALSE);
                 if(msg_ctx)
                     sandesha2_storage_mgr_remove_msg_ctx(storage_mgr,
-                        env, key, invoker->conf_ctx);
+                        env, key, invoker->conf_ctx, -1);
                 if(SANDESHA2_MSG_TYPE_APPLICATION == 
                         sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env))
                 {

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=612676&r1=612675&r2=612676&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/workers/sender_worker.c (original)
+++ webservices/sandesha/trunk/c/src/workers/sender_worker.c Wed Jan 16 
17:38:24 2008
@@ -75,7 +75,9 @@
 static axis2_status_t AXIS2_CALL
 sandesha2_sender_worker_check_for_sync_res(
     const axutil_env_t *env, 
-    axis2_msg_ctx_t *msg_ctx);
+    axis2_msg_ctx_t *msg_ctx,
+    sandesha2_storage_mgr_t *storage_mgr,
+    int msg_type);
 
 static axis2_bool_t AXIS2_CALL
 sandesha2_sender_worker_is_fault_envelope(
@@ -191,6 +193,7 @@
     axis2_transport_sender_t *transport_sender = NULL;
     axis2_bool_t successfully_sent = AXIS2_FALSE;
     axis2_status_t status = AXIS2_SUCCESS;
+    axis2_bool_t resend = AXIS2_FALSE;
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
         "[sandesha2]Entry:sandesha2_sender_worker_send");        
@@ -202,7 +205,6 @@
             "[sandesha2]sender_worker_bean is NULL");
         return AXIS2_FAILURE;
     }
-
     key = sandesha2_sender_bean_get_msg_ctx_ref_key(sender_worker_bean, env);
     if(!msg_ctx)
     {
@@ -338,9 +340,7 @@
     msg_id = sandesha2_sender_bean_get_msg_id(sender_worker_bean, env);
     bean1 = sandesha2_sender_mgr_retrieve(sender_mgr, env, msg_id);
     if(bean1)
-    {
-        axis2_bool_t resend = AXIS2_FALSE;
-        
+    { 
         resend = sandesha2_sender_bean_is_resend(sender_worker_bean, env);
         if(resend)
         {
@@ -350,21 +350,7 @@
                 sandesha2_sender_bean_get_time_to_send(sender_worker_bean, 
env));
             sandesha2_sender_mgr_update(sender_mgr, env, bean1);
         }
-        else
-        {
-            axis2_char_t *msg_stored_key = NULL;
-            
-            msg_id = sandesha2_sender_bean_get_msg_id(bean1, env); 
-            sandesha2_sender_mgr_remove(sender_mgr, env, msg_id);
-            /* Removing the message from the storage */
-            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);
-        }
     }
-    if(bean1)
-        sandesha2_sender_bean_free(bean1, env);
     if(sender_worker_bean)
         sandesha2_sender_bean_free(sender_worker_bean, 
             env);
@@ -374,7 +360,8 @@
         AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
             "[sandesha2]message of msg_type:%d successfully sent", msg_type);
         if(AXIS2_FALSE == axis2_msg_ctx_get_server_side(msg_ctx, env))
-            sandesha2_sender_worker_check_for_sync_res(env, msg_ctx);
+            sandesha2_sender_worker_check_for_sync_res(env, msg_ctx, 
+                storage_mgr, msg_type);
     }
     if(SANDESHA2_MSG_TYPE_TERMINATE_SEQ == msg_type)
     {
@@ -401,6 +388,32 @@
          * status is false*/
         status = AXIS2_FAILURE;
     }
+    if(!resend && msg_type != SANDESHA2_MSG_TYPE_APPLICATION && 
+        msg_type != SANDESHA2_MSG_TYPE_CREATE_SEQ)
+    {
+        axis2_char_t *msg_stored_key = NULL;
+        msg_id = sandesha2_sender_bean_get_msg_id(bean1, env); 
+        sandesha2_sender_mgr_remove(sender_mgr, env, msg_id);
+        /* Removing the message from the storage */
+        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)
+        sandesha2_sender_bean_free(bean1, env);
+
+    /*if(msg_ctx && msg_type != SANDESHA2_MSG_TYPE_APPLICATION && 
+        msg_type != SANDESHA2_MSG_TYPE_CREATE_SEQ)
+    {
+        axis2_op_ctx_t *op_ctx = NULL;
+        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+        if(op_ctx)
+            axis2_op_ctx_free(op_ctx, env);
+        axis2_msg_ctx_set_keep_alive(msg_ctx, env, AXIS2_FALSE);
+        axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_FALSE);
+        axis2_msg_ctx_free(msg_ctx, env);
+    }*/
     /*if(rm_msg_ctx)
         sandesha2_msg_ctx_free(rm_msg_ctx, env);*/
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
@@ -438,28 +451,162 @@
 static axis2_status_t AXIS2_CALL
 sandesha2_sender_worker_check_for_sync_res(
     const axutil_env_t *env, 
-    axis2_msg_ctx_t *msg_ctx)
+    axis2_msg_ctx_t *msg_ctx,
+    sandesha2_storage_mgr_t *storage_mgr,
+    int msg_type)
 {
-    axutil_property_t *property = NULL;
+    /*axutil_property_t *property = NULL;*/
     axis2_msg_ctx_t *res_msg_ctx = NULL;
-    /*axis2_op_ctx_t *req_op_ctx = NULL;*/
     axiom_soap_envelope_t *res_envelope = NULL;
     axis2_char_t *soap_ns_uri = NULL;
+    /*axis2_svc_ctx_t *svc_ctx = NULL;*/
+    axis2_svc_grp_t *svc_grp = NULL;
+    axis2_svc_t *svc = NULL;
+    axis2_op_t *op = NULL;
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    axis2_conf_t *conf = NULL;
+    axis2_bool_t free_msg = AXIS2_FALSE;
    
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
         "[sandesha2]Entry:sandesha2_sender_worker_check_for_sync_res");
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+    if(!msg_ctx)
+        return AXIS2_SUCCESS;
+    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;
+
+    res_envelope = axis2_msg_ctx_get_response_soap_envelope(msg_ctx, env);
+    if(!res_envelope)
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+            "[sandesha2]Response envelope not found");
+        res_envelope = axis2_http_transport_utils_create_soap_msg(env, msg_ctx,
+            soap_ns_uri);
+        free_msg = AXIS2_TRUE;
+        if(!res_envelope)
+        {
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "came99");
+            return AXIS2_SUCCESS;
+        }
+    }
+    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+    svc_grp = axis2_msg_ctx_get_svc_grp(msg_ctx, env);
+    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
+    op = axis2_msg_ctx_get_op(msg_ctx, env);
+    res_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));
+    if(svc_grp)
+    {
+        axis2_char_t *svc_grp_name = (axis2_char_t *)  axis2_svc_grp_get_name(
+            svc_grp, env);
+        svc_grp = axis2_conf_get_svc_grp(conf, env, svc_grp_name);
+        if(svc_grp)
+            axis2_msg_ctx_set_svc_grp(res_msg_ctx, env, svc_grp);
+    }
+    if (svc) 
+    {
+        axis2_char_t *svc_name = (axis2_char_t *) axis2_svc_get_name(svc, env);
+        svc = axis2_conf_get_svc(conf, env, svc_name);
+        if(svc)
+            axis2_msg_ctx_set_svc(res_msg_ctx, env, svc);
+    }
+    if(op)
+    {
+        axutil_qname_t *qname = (axutil_qname_t *) axis2_op_get_qname(op, env);
+        axis2_char_t *op_mep_str = NULL;
+        axis2_char_t *op_name_str = NULL; 
+        if(qname)
+        {
+            op_name_str = axutil_qname_to_string(qname, env);
+        }
+        op_mep_str = (axis2_char_t *) axis2_op_get_msg_exchange_pattern(op, 
env);
+        if((op_name_str || op_mep_str) && svc)
+        {
+            axis2_op_t *op = NULL;
+            if(op_name_str)
+            {
+                axutil_qname_t *op_qname = 
axutil_qname_create_from_string(env, 
+                    op_name_str);
+                op = axis2_svc_get_op_with_qname(svc, env, op_qname);
+            }
+            if(!op && op_mep_str && svc)
+            {
+                axutil_hash_t *all_ops = NULL;
+                axutil_hash_index_t *index = NULL;
+                /* Finding an operation using the MEP */
+                all_ops = axis2_svc_get_all_ops(svc, env);
+                for (index = axutil_hash_first(all_ops, env); index; index = 
+                    axutil_hash_next(env, index))
+                {
+                    void *v = NULL;
+                    axis2_char_t *mep = NULL;
+                    axis2_op_t *temp = NULL;
+                    axutil_hash_this(index, NULL, NULL, &v);
+                    temp = (axis2_op_t *) v;
+                    mep = (axis2_char_t *) 
axis2_op_get_msg_exchange_pattern(temp, 
+                        env);
+                    if(0 == axutil_strcmp(mep, op_mep_str))
+                    {
+                        op = temp;
+                        break;
+                    }
+                }
+            }
+            if(op)
+                axis2_msg_ctx_set_op(res_msg_ctx, env, op);
+            else
+            {
+                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cant find a suitable 
"\
+                    "operation for the generated message");
+                AXIS2_ERROR_SET(env->error, 
+                    SANDESHA2_ERROR_CANNOT_FIND_OP_FOR_GENERATED_MSG, 
AXIS2_FAILURE);
+                return AXIS2_FAILURE;
+            }
+        }
+    }
+    /* Setting contexts TODO is this necessary? */
+    svc_grp = axis2_msg_ctx_get_svc_grp(res_msg_ctx, env);
+    if(svc_grp)
+    {
+        axis2_svc_grp_ctx_t *svc_grp_ctx = axis2_svc_grp_ctx_create(env, 
+            svc_grp, conf_ctx);
+        axis2_msg_ctx_set_svc_grp_ctx(res_msg_ctx, env, svc_grp_ctx);
+    }
+    svc = axis2_msg_ctx_get_svc(res_msg_ctx, env);
+    if(svc)
+    {
+        axis2_svc_grp_ctx_t *svc_grp_ctx = axis2_msg_ctx_get_svc_grp_ctx(
+            res_msg_ctx, env);
+        axis2_svc_ctx_t *svc_ctx = axis2_svc_ctx_create(env, svc, svc_grp_ctx);
+        if(svc_ctx)
+        {
+            axis2_svc_ctx_set_parent(svc_ctx, env, svc_grp_ctx);
+            axis2_msg_ctx_set_svc_ctx(res_msg_ctx, env, svc_ctx);
+        }
         
-    res_msg_ctx = axis2_msg_ctx_create(env, axis2_msg_ctx_get_conf_ctx(msg_ctx,
-        env), axis2_msg_ctx_get_transport_in_desc(
-        msg_ctx, env), axis2_msg_ctx_get_transport_out_desc(msg_ctx,
-        env));
+    }
+    op = axis2_msg_ctx_get_op(res_msg_ctx, env);
+    if(op)
+    {
+               axis2_op_ctx_t *op_ctx = NULL;
+        axis2_svc_ctx_t *svc_ctx = axis2_msg_ctx_get_svc_ctx(res_msg_ctx, env);
+               op_ctx = axis2_op_ctx_create(env, op, svc_ctx);
+        if(op_ctx)
+        {
+            axis2_op_ctx_set_parent(op_ctx, env, svc_ctx);
+            axis2_msg_ctx_set_op_ctx(res_msg_ctx, env, op_ctx);
+        }
+    }
     /*
      * Setting the message as serverSide will let it go through the 
      * Message Receiver (may be callback MR).
      */
     axis2_msg_ctx_set_server_side(res_msg_ctx, env, AXIS2_TRUE);
-    property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_TRANSPORT_IN);
+    /*property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_TRANSPORT_IN);
     if(property)
     {
                axutil_property_t *temp_prop = NULL;
@@ -468,45 +615,13 @@
             temp_prop);
     }
     else
-               AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "AXIS2_TRANSPORT_IN 
NULL");
+               AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "AXIS2_TRANSPORT_IN 
NULL");*/
 
-    axis2_msg_ctx_set_svc_ctx(res_msg_ctx, env, axis2_msg_ctx_get_svc_ctx(
-        msg_ctx, env));
+    /*svc_ctx = axis2_msg_ctx_get_svc_ctx(msg_ctx, env);
+    axis2_msg_ctx_set_svc_ctx(res_msg_ctx, env, svc_ctx);
     axis2_msg_ctx_set_svc_grp_ctx(res_msg_ctx, env, 
-        axis2_msg_ctx_get_svc_grp_ctx(msg_ctx, env));
-    /*req_op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
-    if(req_op_ctx)
-    {
-        axis2_ctx_t *ctx = NULL;
-        
-        ctx = axis2_op_ctx_get_base(req_op_ctx, env);
-        if(axis2_ctx_get_property(ctx, env, MTOM_RECIVED_CONTENT_TYPE))
-        {
-            axis2_msg_ctx_set_property(res_msg_ctx, env, 
-                MTOM_RECIVED_CONTENT_TYPE, axis2_ctx_get_property(ctx, env, 
-                MTOM_RECIVED_CONTENT_TYPE));
-        }
-        if(axis2_ctx_get_property(ctx, env, AXIS2_HTTP_CHAR_SET_ENCODING))
-        {
-            axis2_msg_ctx_set_property(res_msg_ctx, env, 
-                AXIS2_HTTP_CHAR_SET_ENCODING, axis2_ctx_get_property(ctx, env, 
-                AXIS2_HTTP_CHAR_SET_ENCODING));
-        }
-    }
-    axis2_msg_ctx_set_doing_rest(res_msg_ctx, env, 
axis2_msg_ctx_get_doing_rest(
-        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;
+        axis2_msg_ctx_get_svc_grp_ctx(msg_ctx, env));*/
 
-    res_envelope = axis2_msg_ctx_get_response_soap_envelope(msg_ctx, env);
-    if(!res_envelope)
-    {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Response envelope not found");
-        res_envelope = axis2_http_transport_utils_create_soap_msg(env, msg_ctx,
-            soap_ns_uri);
-    }
     if(res_envelope)
     {
         axis2_engine_t *engine = NULL;
@@ -524,14 +639,15 @@
         if(engine)
             axis2_engine_free(engine, env);
     }
+    if(free_msg)
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_msg_type1:%d", msg_type);
+        axiom_soap_envelope_free(res_envelope, env);
+    }
     /* To avoid a second passing through incoming handlers at op_client*/
-    property = axutil_property_create_with_args(env, 0, 0, 0, 
AXIS2_VALUE_TRUE);
+    /*property = axutil_property_create_with_args(env, 0, 0, 0, 
AXIS2_VALUE_TRUE);
     axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_HANDLER_ALREADY_VISITED, 
-        property);
-    axis2_op_ctx_t *op_ctx = NULL;
-    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
-    if(op_ctx)
-        axis2_op_ctx_free(op_ctx, env);
+        property);*/
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
         "[sandesha2]Exit:sandesha2_sender_worker_check_for_sync_res");
     return AXIS2_SUCCESS;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to