You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by di...@apache.org on 2013/04/12 06:03:43 UTC

svn commit: r1467162 - in /axis/axis2/c/core/trunk: samples/client/google/ samples/client/math/ samples/client/mtom/ samples/client/version/ src/core/context/ src/core/transport/http/common/ src/core/transport/http/sender/ util/src/

Author: dinesh
Date: Fri Apr 12 04:03:42 2013
New Revision: 1467162

URL: http://svn.apache.org/r1467162
Log:
applying patch Alex Mantaut provided for 1632 to fix a memory leak

Modified:
    axis/axis2/c/core/trunk/samples/client/google/google_client.c
    axis/axis2/c/core/trunk/samples/client/math/math_client.c
    axis/axis2/c/core/trunk/samples/client/mtom/mtom_client.c
    axis/axis2/c/core/trunk/samples/client/version/version_client.c
    axis/axis2/c/core/trunk/src/core/context/ctx.c
    axis/axis2/c/core/trunk/src/core/transport/http/common/http_simple_request.c
    axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c
    axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c
    axis/axis2/c/core/trunk/util/src/property.c

Modified: axis/axis2/c/core/trunk/samples/client/google/google_client.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/samples/client/google/google_client.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/samples/client/google/google_client.c (original)
+++ axis/axis2/c/core/trunk/samples/client/google/google_client.c Fri Apr 12 04:03:42 2013
@@ -276,6 +276,11 @@ build_soap_body_content(
     buffer = axiom_node_to_string(google_om_node, env);
     printf("%s\n", buffer);
     AXIS2_FREE (env->allocator, buffer);
+
+    axiom_namespace_free(ns0, env);
+    axiom_namespace_free(ns1, env);
+    axiom_namespace_free(ns2, env);
+    axiom_namespace_free(ns3, env);
     return google_om_node;
 }
 

Modified: axis/axis2/c/core/trunk/samples/client/math/math_client.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/samples/client/math/math_client.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/samples/client/math/math_client.c (original)
+++ axis/axis2/c/core/trunk/samples/client/math/math_client.c Fri Apr 12 04:03:42 2013
@@ -197,5 +197,6 @@ build_om_programatically(
         om_output = NULL;
     }
 
+    axiom_namespace_free(ns1, env);
     return math_om_node;
 }

Modified: axis/axis2/c/core/trunk/samples/client/mtom/mtom_client.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/samples/client/mtom/mtom_client.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/samples/client/mtom/mtom_client.c (original)
+++ axis/axis2/c/core/trunk/samples/client/mtom/mtom_client.c Fri Apr 12 04:03:42 2013
@@ -230,6 +230,8 @@ build_om_programatically(
         printf("%s", om_str);
         AXIS2_FREE(env->allocator, om_str);
     }
+
+    axiom_namespace_free(ns1, env);
     return mtom_om_node;
 }
 

Modified: axis/axis2/c/core/trunk/samples/client/version/version_client.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/samples/client/version/version_client.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/samples/client/version/version_client.c (original)
+++ axis/axis2/c/core/trunk/samples/client/version/version_client.c Fri Apr 12 04:03:42 2013
@@ -181,5 +181,6 @@ build_om_programatically(
         om_output = NULL;
     }
 
+    axiom_namespace_free(ns1, env);
     return version_om_node;
 }

Modified: axis/axis2/c/core/trunk/src/core/context/ctx.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/context/ctx.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/context/ctx.c (original)
+++ axis/axis2/c/core/trunk/src/core/context/ctx.c Fri Apr 12 04:03:42 2013
@@ -65,6 +65,8 @@ axis2_ctx_set_property(
     axutil_property_t * value)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, ctx, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, ctx->property_map, AXIS2_FAILURE);
 
     if(value)
     {
@@ -74,12 +76,8 @@ axis2_ctx_set_property(
             AXIS2_HASH_KEY_STRING);
         if(temp_value)
         {
-            void *temp_value_value = axutil_property_get_value(temp_value, env);
-            void *value_value = axutil_property_get_value(value, env);
-            if(temp_value_value != value_value)
-            {
-                axutil_property_free(temp_value, env);
-            }
+            /**Free the previous value (it will be replaced)*/
+            axutil_property_free(temp_value, env);
         }
     }
     if(ctx->property_map)

Modified: axis/axis2/c/core/trunk/src/core/transport/http/common/http_simple_request.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/transport/http/common/http_simple_request.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/transport/http/common/http_simple_request.c (original)
+++ axis/axis2/c/core/trunk/src/core/transport/http/common/http_simple_request.c Fri Apr 12 04:03:42 2013
@@ -50,6 +50,7 @@ axis2_http_simple_request_create(
     memset((void *)simple_request, 0, sizeof(axis2_http_simple_request_t));
     simple_request->request_line = request_line;
     simple_request->stream = content;
+    simple_request->owns_stream = AXIS2_FALSE;
 
     if(!(simple_request->stream))
     {

Modified: axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c (original)
+++ axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c Fri Apr 12 04:03:42 2013
@@ -296,7 +296,8 @@ axis2_http_client_send(
     }
     else
     {
-        client->data_stream = axutil_stream_create_socket(env, client->sockfd);
+        if(!client->data_stream)
+            client->data_stream = axutil_stream_create_socket(env, client->sockfd);
     }
 
     if(!client->data_stream)

Modified: axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c (original)
+++ axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c Fri Apr 12 04:03:42 2013
@@ -339,8 +339,6 @@ axis2_http_sender_send(
         is_soap = AXIS2_TRUE;
     }
 
-    url = axutil_url_parse_string(env, str_url);
-
     if(!is_soap)
     {
         if(soap_body)
@@ -377,12 +375,6 @@ axis2_http_sender_send(
         }
     }
 
-    if(!url)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "url is null for string %s", str_url);
-        return AXIS2_FAILURE;
-    }
-
     /*if(sender->client)
     {
         axis2_http_client_free(sender->client, env);
@@ -447,18 +439,44 @@ axis2_http_sender_send(
             add_keepalive_header = AXIS2_TRUE;
         }
     } /* End if sender->keep_alive */
+
+    url = axutil_url_parse_string(env, str_url);
+
+    if(!url)
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "url is null for string %s", str_url);
+        return AXIS2_FAILURE;
+    }
+
+    /*If the client didn't already exist for this sender (it could be fetched from connection_map) */
     if(!sender->client)
     {
         sender->client = axis2_http_client_create(env, url);
+
+        /* Fail when creating the client*/
+        if(sender->client && sender->keep_alive)
+        {
+            /* While using keepalive the client must be kept for future use*/
+            if(connection_map)
+                axis2_http_sender_connection_map_add(sender, connection_map, env, msg_ctx);
+        }
+        else
+        {
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "sender->client creation failed for url %s", url);
+            return AXIS2_FAILURE;
+        }
     }
-    if(!sender->client)
+    else
+        axis2_http_client_set_url(sender->client,env,url);
+
+    if(!url)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "sender->client creation failed for url %s", url);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "url is null for string %s", str_url);
         return AXIS2_FAILURE;
     }
+
     /* configure proxy settings if we have set so
      */
-
     axis2_http_sender_configure_proxy(sender, env, msg_ctx);
 
     if(conf)
@@ -1384,6 +1402,13 @@ axis2_http_sender_send(
             return axis2_http_sender_process_response(sender, env, msg_ctx, response);
         }
     }
+    else
+    {
+        /*In case of a not found error, process the response, but end with an ERROR
+          this way the resources allocated by the client will be freed*/
+        if(AXIS2_HTTP_RESPONSE_NOT_FOUND_CODE_VAL == status_code)
+            axis2_http_sender_process_response(sender, env, msg_ctx, response);
+    }
 
     AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR, AXIS2_FAILURE);
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_http_sender_send");

Modified: axis/axis2/c/core/trunk/util/src/property.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/src/property.c?rev=1467162&r1=1467161&r2=1467162&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/src/property.c (original)
+++ axis/axis2/c/core/trunk/util/src/property.c Fri Apr 12 04:03:42 2013
@@ -83,6 +83,7 @@ axutil_property_free(
     const axutil_env_t * env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, property,);
 
     if(property->value)
     {
@@ -137,6 +138,7 @@ axutil_property_set_value(
     void *value)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, property, AXIS2_FAILURE);
 
     if(property->value)
     {