You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by mi...@apache.org on 2008/05/22 16:17:43 UTC

svn commit: r659115 - in /webservices/axis2/trunk/c/src/core/transport/http: sender/http_sender.c util/http_transport_utils.c

Author: milinda
Date: Thu May 22 07:17:42 2008
New Revision: 659115

URL: http://svn.apache.org/viewvc?rev=659115&view=rev
Log:
Fixing MTOM sample memory leaks and part of yahoo sample memory leaks. (https://issues.apache.org/jira/browse/AXIS2C-1149 and https://issues.apache.org/jira/browse/AXIS2C-1148)

Modified:
    webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
    webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c

Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c?rev=659115&r1=659114&r2=659115&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c Thu May 22 07:17:42 2008
@@ -247,6 +247,7 @@
     axutil_param_t *write_xml_declaration_param = NULL;
     axutil_hash_t *transport_attrs = NULL;
     axis2_bool_t write_xml_declaration = AXIS2_FALSE;
+    axutil_property_t *property = NULL;/* Property for holding http client */
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_http_sender_send");
     soap_body = axiom_soap_envelope_get_body (out, env);
@@ -329,6 +330,16 @@
                          "sender->client creation failed for url %s", url);
         return AXIS2_FAILURE;
     }
+   
+    /* We put the client into msg_ctx so that we can free it once the processing
+     * is done at client side
+     */
+    property = axutil_property_create (env);
+    axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST);
+    axutil_property_set_free_func (property, env,
+                                   axis2_http_client_free_void_arg);
+    axutil_property_set_value (property, env, sender->client);
+    axis2_msg_ctx_set_property (msg_ctx, env, AXIS2_HTTP_CLIENT, property);
 
     /* configure proxy settings if we have set so
      */
@@ -402,16 +413,6 @@
     if (!send_via_get && !send_via_head && !send_via_delete)
     {
         /* processing POST and PUT methods */
-        axutil_property_t *property = NULL;
-        /* We put the client into msg_ctx so that we can free it once the processing
-         * is done at client side
-         */
-        property = axutil_property_create (env);
-        axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST);
-        axutil_property_set_free_func (property, env,
-                                       axis2_http_client_free_void_arg);
-        axutil_property_set_value (property, env, sender->client);
-        axis2_msg_ctx_set_property (msg_ctx, env, AXIS2_HTTP_CLIENT, property);
         AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "msg_ctx_id:%s", 
             axis2_msg_ctx_get_msg_id(msg_ctx,env));
 
@@ -531,11 +532,14 @@
             path = axutil_strcat (env,
                               axutil_url_get_path (url, env),
                               AXIS2_Q_MARK_STR, request_params, NULL);
+			AXIS2_FREE(env->allocator, request_params);
+			request_params = NULL;
         }
         else
         {
             path = axutil_url_to_external_form(url, env);
         }
+
         if (send_via_get)
         {
             request_line = axis2_http_request_line_create (env, 
@@ -3283,6 +3287,8 @@
                 axutil_array_list_add (param_list, env,
                                        axutil_strcat (env, name, "=",
                                                       encoded_value, NULL));
+				AXIS2_FREE(env->allocator, encoded_value);
+				encoded_value = NULL;
             }
         }
     }

Modified: webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c?rev=659115&r1=659114&r2=659115&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c Thu May 22 07:17:42 2008
@@ -1808,6 +1808,7 @@
     axutil_property_t *property = NULL;
     axutil_hash_t *binary_data_map = NULL;
     axiom_soap_envelope_t *soap_envelope = NULL;
+	axutil_stream_t *stream = NULL;
 
     AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
     AXIS2_PARAM_CHECK(env->error, soap_ns_uri, NULL);
@@ -1909,7 +1910,6 @@
         if (mime_boundary)
         {
             axiom_mime_parser_t *mime_parser = NULL;
-            axutil_stream_t *stream = NULL;
             int soap_body_len = 0;
             axis2_char_t *soap_body_str = NULL;
             axutil_param_t *chunk_buffer_size_param = NULL;
@@ -1981,6 +1981,15 @@
 
             axiom_mime_parser_free(mime_parser, env);
             mime_parser = NULL;
+			if(mime_boundary)
+			{
+	    		AXIS2_FREE(env->allocator, mime_boundary);
+			}
+
+			if(soap_body_str)
+			{
+			    AXIS2_FREE(env->allocator, soap_body_str); 
+			}
         }
     }
 
@@ -2035,6 +2044,11 @@
                 axiom_soap_body_has_fault(soap_body, env);
             }
         }
+		if(stream)
+		{
+			axutil_stream_free(stream, env);
+			callback_ctx->in_stream = NULL;
+		}
     }
     else
     {
@@ -2069,6 +2083,7 @@
         axiom_soap_body_add_child(def_body, env, root_node);
         axiom_stax_builder_free_self(om_builder, env);
     }
+
     return soap_envelope;
 }