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 ka...@apache.org on 2006/09/28 13:27:25 UTC

svn commit: r450809 - in /webservices/axis2/trunk/c: axiom/src/attachments/mime_parser.c axiom/src/soap/soap_builder.c modules/core/clientapi/svc_client.c modules/core/receivers/msg_recv.c samples/client/echo/echo.c util/src/platforms/unix/thread_unix.c

Author: kaushalye
Date: Thu Sep 28 04:27:24 2006
New Revision: 450809

URL: http://svn.apache.org/viewvc?view=rev&rev=450809
Log:
Applying patch for memory leaks fixed - JIRA AXIS2C-253


Modified:
    webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
    webservices/axis2/trunk/c/axiom/src/soap/soap_builder.c
    webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c
    webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c
    webservices/axis2/trunk/c/samples/client/echo/echo.c
    webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c

Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c?view=diff&rev=450809&r1=450808&r2=450809
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c Thu Sep 28 04:27:24 2006
@@ -200,10 +200,15 @@
                 }
             }
         }
-
     }
     while (!pos && len > 0);
 
+    if (root_mime)
+    {
+        AXIS2_FREE(env->allocator, root_mime);
+        root_mime = NULL;
+    }
+
     pos = NULL;
     len = 0;
 
@@ -450,13 +455,26 @@
 
             }
 
+            if (body_mime)
+            {
+                AXIS2_FREE(env->allocator, body_mime);
+                body_mime = NULL;
+            }
+
             body_mime = temp_body_mime;
             body_mime_len = temp_body_mime_len;
 
         }/*if (mime_parser_impl->mime_parts_map)*/
     }/* end while (!end_of_mime) */
 
+    if (body_mime)
+    {
+        AXIS2_FREE(env->allocator, body_mime);
+        body_mime = NULL;
+    }
+
     AXIS2_FREE(env->allocator, buffer);
+    buffer = NULL;
 
     return mime_parser_impl->mime_parts_map;
 }

Modified: webservices/axis2/trunk/c/axiom/src/soap/soap_builder.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/soap/soap_builder.c?view=diff&rev=450809&r1=450808&r2=450809
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/soap/soap_builder.c (original)
+++ webservices/axis2/trunk/c/axiom/src/soap/soap_builder.c Thu Sep 28 04:27:24 2006
@@ -278,12 +278,11 @@
             builder_impl->builder_helper = NULL;
         }
     }
-
-    /*if ( builder_impl->om_builder)
+    if ( builder_impl->om_builder)
     {
         AXIOM_STAX_BUILDER_FREE(builder_impl->om_builder, env);
         builder_impl->om_builder = NULL;
-    }*/
+    }
     if (builder->ops)
     {
         AXIS2_FREE(env->allocator, builder->ops);

Modified: webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c?view=diff&rev=450809&r1=450808&r2=450809
==============================================================================
--- webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c (original)
+++ webservices/axis2/trunk/c/modules/core/clientapi/svc_client.c Thu Sep 28 04:27:24 2006
@@ -766,6 +766,7 @@
     axis2_param_t *param = NULL;
     axis2_uri_t *action_uri = NULL;
     axis2_char_t *action_str = NULL;
+    axis2_bool_t qname_free_flag = AXIS2_FALSE;
 
     AXIS2_ENV_CHECK(env, NULL);
     svc_client_impl = AXIS2_INTF_TO_IMPL(svc_client);
@@ -784,6 +785,7 @@
 
     if (!op_qname)
     {
+        qname_free_flag = AXIS2_TRUE;
         op_qname = axis2_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
     }
 
@@ -881,8 +883,8 @@
         }
         if (svc_client_impl->op_client)
         {
-            /** free op_client of previous request
-            AXIS2_OP_CLIENT_FREE(svc_client_impl->op_client);
+            /** free op_client of previous request 
+            AXIS2_OP_CLIENT_FREE(svc_client_impl->op_client, env);
             */
         }
         svc_client_impl->op_client = op_client;
@@ -891,6 +893,12 @@
         AXIS2_OP_CLIENT_EXECUTE(op_client, env, AXIS2_TRUE);
         res_msg_ctx = (axis2_msg_ctx_t *)AXIS2_OP_CLIENT_GET_MSG_CTX(op_client, env, AXIS2_WSDL_MESSAGE_LABEL_IN_VALUE);
 
+        if (msg_ctx)
+        {
+            AXIS2_FREE(env->allocator, msg_ctx);
+            msg_ctx = NULL;
+        }
+
         if (!res_msg_ctx)
         {
             return NULL;
@@ -899,6 +907,12 @@
         soap_envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(res_msg_ctx, env);
     }
 
+    if (qname_free_flag)
+    {
+        AXIS2_QNAME_FREE((axis2_qname_t *) op_qname, env);
+        op_qname = NULL;
+    }
+
     if (!soap_envelope)
     {
         return NULL;
@@ -1322,6 +1336,17 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     svc_client_impl = AXIS2_INTF_TO_IMPL(svc_client);
+
+    /* TODO: Fix this memory leak. 
+     *
+     * Segfault occurs with dual clients
+     *
+    if (svc_client_impl->svc)
+    {
+        AXIS2_SVC_FREE(svc_client_impl->svc, env);
+        svc_client_impl->svc = NULL;
+    }
+    */
 
     if (svc_client_impl->callback_recv)
     {

Modified: webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c?view=diff&rev=450809&r1=450808&r2=450809
==============================================================================
--- webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c (original)
+++ webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c Thu Sep 28 04:27:24 2006
@@ -473,10 +473,10 @@
         }
     }
     AXIS2_ENGINE_FREE(engine, env);
-    /* test code: uncomment this when test is over */
-    /*axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
-    AXIS2_MSG_CTX_FREE(out_msg_ctx, env);*/
-    /* end test code */
+    /* test code: uncomment this when test is over */ 
+    axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
+    AXIS2_MSG_CTX_FREE(out_msg_ctx, env);
+    /*end test code */
     return status;
 }
 

Modified: webservices/axis2/trunk/c/samples/client/echo/echo.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/echo/echo.c?view=diff&rev=450809&r1=450808&r2=450809
==============================================================================
--- webservices/axis2/trunk/c/samples/client/echo/echo.c (original)
+++ webservices/axis2/trunk/c/samples/client/echo/echo.c Thu Sep 28 04:27:24 2006
@@ -100,6 +100,9 @@
         if (om_str)
             printf("\nReceived OM : %s\n", om_str);
         printf("\necho client invoke SUCCESSFUL!\n");
+
+        AXIOM_NODE_FREE_TREE(ret_node, env);
+        ret_node = NULL;
     }
     else
     {
@@ -109,6 +112,12 @@
         printf("echo client invoke FAILED!\n");
     }
 
+    if (payload)
+    {
+        AXIOM_NODE_FREE_TREE(payload, env);
+        payload = NULL;
+    }
+
     if (svc_client)
     {
         AXIS2_SVC_CLIENT_FREE(svc_client, env);
@@ -153,7 +162,10 @@
 
     om_str = AXIOM_NODE_TO_STRING(echo_om_node, env);
     if (om_str)
+    {
         printf("\nSending OM : %s\n", om_str);
-
+        AXIS2_FREE(env->allocator, om_str);
+        om_str =  NULL;
+    }
     return echo_om_node;
 }

Modified: webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c?view=diff&rev=450809&r1=450808&r2=450809
==============================================================================
--- webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c (original)
+++ webservices/axis2/trunk/c/util/src/platforms/unix/thread_unix.c Thu Sep 28 04:27:24 2006
@@ -45,7 +45,7 @@
     axis2_threadattr_t *attr = data;
     int rv;
 
-    rv = pthread_attr_destroy(&attr->attr);
+    rv = pthread_attr_destroy(&(attr->attr));
 
     if (0 != rv)
     {
@@ -59,7 +59,7 @@
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_threadattr_detach_set(axis2_threadattr_t *attr, axis2_bool_t detached)
 {
-    if (0 == pthread_attr_setdetachstate(&attr->attr, DETACH_ARG(detached)))
+    if (0 == pthread_attr_setdetachstate(&(attr->attr), DETACH_ARG(detached)))
     {
         return AXIS2_SUCCESS;
     }
@@ -70,7 +70,7 @@
 axis2_threadattr_detach_get(axis2_threadattr_t *attr)
 {
     int state = 0;
-    pthread_attr_getdetachstate(&attr->attr, &state);
+    pthread_attr_getdetachstate(&(attr->attr), &state);
     if (state == 1)
     {
         return AXIS2_TRUE;
@@ -109,7 +109,7 @@
 
     if (attr)
     {
-        temp = &attr->attr;
+        temp = &(attr->attr);
     }
     else
     {
@@ -156,7 +156,7 @@
 axis2_thread_join(axis2_thread_t *thd)
 {
     void *thread_stat;
-    if (0 == pthread_join(*thd->td, (void *)&thread_stat))
+    if (0 == pthread_join(*(thd->td), (void *)(&thread_stat)))
     {
         return AXIS2_SUCCESS;
     }
@@ -206,7 +206,7 @@
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_thread_once(axis2_thread_once_t *control, void(*func)(void))
 {
-    return pthread_once(&control->once, func);
+    return pthread_once(&(control->once), func);
 }
 
 /*************************Thread locking functions*****************************/
@@ -218,7 +218,7 @@
     new_mutex = AXIS2_MALLOC(allocator, sizeof(axis2_thread_mutex_t));
     new_mutex->allocator = allocator;
 
-    if (pthread_mutex_init(&new_mutex->mutex, NULL) != 0)
+    if (pthread_mutex_init(&(new_mutex->mutex), NULL) != 0)
     {
         AXIS2_FREE(allocator, new_mutex);
         return NULL;
@@ -229,13 +229,13 @@
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_thread_mutex_lock(axis2_thread_mutex_t *mutex)
 {
-    return pthread_mutex_lock(&mutex->mutex);
+    return pthread_mutex_lock(&(mutex->mutex));
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_thread_mutex_unlock(axis2_thread_mutex_t *mutex)
 {
-    if (pthread_mutex_unlock(&mutex->mutex) != 0)
+    if (pthread_mutex_unlock(&(mutex->mutex)) != 0)
     {
         return AXIS2_FAILURE;
     }
@@ -245,7 +245,7 @@
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_thread_mutex_destroy(axis2_thread_mutex_t *mutex)
 {
-    if (0 != pthread_mutex_destroy(&mutex->mutex))
+    if (0 != pthread_mutex_destroy(&(mutex->mutex)))
     {
         return AXIS2_FAILURE;
     }



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