Memory leaks - in client and common library when looking for non-existant job.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 4 Mar 2012 20:45:15 +0000 (20:45 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 4 Mar 2012 20:45:15 +0000 (20:45 +0000)
org.glite.lb.client/examples/job_status_threaded.c
org.glite.lb.client/src/consumer.c
org.glite.lb.common/src/xml_parse.c.T

index 66aec08..ea45813 100644 (file)
@@ -26,6 +26,7 @@ limitations under the License.
 #include <unistd.h>
 
 #include "glite/lb/context-int.h"
+#include "glite/lb/connpool.h"
 #ifdef BUILDING_LB_CLIENT
 #include "consumer.h"
 #else
@@ -69,13 +70,13 @@ void *thread_meat(char *jobid) {
                        dgerr(ctx,"edg_wll_JobStatus"); result = 1; 
                } else {
                        printstat_oneline(status,0);
+                       edg_wll_FreeStatus(&status);
                        break;
                }
                sleep(3); 
        }
 
        if (job) edg_wlc_JobIdFree(job);
-//     if (status.state) edg_wll_FreeStatus(&status);
 
        cleanup:
        
@@ -140,6 +141,7 @@ int main(int argc,char *argv[]) {
        }
 
        free(threads);
+       edg_wll_poolFree(); // for hunting memleaks
 
        return 0;
 }
index 8836d5c..a4a6c8c 100644 (file)
@@ -444,6 +444,7 @@ int set_server_name_and_port(edg_wll_Context ctx, const edg_wll_QueryRec **job_c
        }
        else if ( !ctx->srvName || !ctx->srvPort )
        {
+               if (found) free(srvName);
                if (!ctx->p_query_server) 
                        return(edg_wll_SetError(ctx, (edg_wll_ErrorCode) EINVAL, "Hostname of server to query is not set"));
                else ctx->srvName = strdup(ctx->p_query_server);
index 8e98502..ff2e0d1 100644 (file)
@@ -1395,7 +1395,14 @@ edg_wll_ErrorCode edg_wll_ParseQueryJobs(edg_wll_Context ctx, char *messageBody,
                 free(errorMessage);            
        }  else if (XMLCtx.errtxt) edg_wll_SetError(ctx, EDG_WLL_ERROR_XML_PARSE, XMLCtx.errtxt);
 
-        if ((errorCode = edg_wll_Error(ctx,NULL,NULL))) {
+       if (!(errorCode = edg_wll_Error(ctx,NULL,NULL))) {
+               if (XMLCtx.errDesc || XMLCtx.errCode) {
+                       ctx->errDesc = strdup(XMLCtx.errDesc);
+                       ctx->errCode = XMLCtx.errCode;
+                       errorCode = XMLCtx.errCode;
+               }
+       }
+        if (errorCode) {
                for (i=0; i<XMLCtx.position; i++)  edg_wlc_JobIdFree( (XMLCtx.jobsOutGlobal)[i] );
                free(XMLCtx.jobsOutGlobal);
                XMLCtx.jobsOutGlobal = NULL;
@@ -1413,6 +1420,8 @@ edg_wll_ErrorCode edg_wll_ParseQueryJobs(edg_wll_Context ctx, char *messageBody,
                         XMLCtx.errDesc = NULL;
                         XMLCtx.errCode = 0;
                 }
+
+               goto end;
         }
 
        /* malloc-ate one more row for NULL list termination */
@@ -1461,13 +1470,8 @@ edg_wll_ErrorCode edg_wll_ParseQueryJobs(edg_wll_Context ctx, char *messageBody,
                XMLCtx.jobStatGlobal = NULL; 
        }
        
-       if (XMLCtx.errDesc || XMLCtx.errCode) {
-               ctx->errDesc = XMLCtx.errDesc;
-               ctx->errCode = XMLCtx.errCode;
-               errorCode = XMLCtx.errCode;
-       }
-
 
+end:
        /* print all warning if corresponding env variable is set       */
        if (XMLCtx.warntxt && getenv("EDG_WLL_XML_WARNINGS")) {