memleaks fixed
authorMiloš Mulač <mulac@civ.zcu.cz>
Thu, 15 Nov 2007 13:10:42 +0000 (13:10 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Thu, 15 Nov 2007 13:10:42 +0000 (13:10 +0000)
org.glite.lb.server/src/jobstat.h
org.glite.lb.server/src/process_event.c
org.glite.lb.server/src/srv_purge.c

index 77ac99d..99023c0 100644 (file)
@@ -39,6 +39,7 @@ typedef struct _branch_state {
        char    *destination;
        char    *ce_node;
        char    *jdl;
+       /*!! if adding new field, modify also free_branch_state() */
 } branch_state;
 
 
@@ -54,6 +55,8 @@ typedef struct _intJobStat {
 
                struct timeval  last_pbs_event_timestamp;
                int             pbs_reruning;           // true if rerun event arrived
+
+               /*!! if adding new field, modify also destroy_intJobStat_extension() */
        } intJobStat;
 
 typedef enum _edg_wll_PBSEventSource {
index 7024462..e305b08 100644 (file)
@@ -969,9 +969,13 @@ int add_stringlist(char ***lptr, const char *new_item)
 
 void destroy_intJobStat_extension(intJobStat *p)
 {
-       free(p->last_seqcode); p->last_seqcode = NULL;
-       free(p->last_cancel_seqcode); p->last_cancel_seqcode = NULL;
-                              p->resubmit_type = EDG_WLL_RESUBMISSION_UNDEFINED;
+       if (p->last_seqcode) free(p->last_seqcode);
+       if (p->last_cancel_seqcode) free(p->last_cancel_seqcode);
+       if (p->branch_tag_seqcode) free(p->branch_tag_seqcode);
+       if (p->last_branch_seqcode) free(p->last_branch_seqcode);
+       if (p->deep_resubmit_seqcode) free(p->deep_resubmit_seqcode);
+       free_branch_state(&p->branch_states);
+       memset(p,0,sizeof(*p));
 }
 
 void destroy_intJobStat(intJobStat *p)
index 016b87d..1337a97 100644 (file)
@@ -295,7 +295,10 @@ int edg_wll_PurgeServer(edg_wll_Context ctx,const edg_wll_PurgeRequest *request)
                                }
 
                                memset(&stat,0,sizeof stat);
-                               if (edg_wll_JobStatus(ctx,job,0,&stat)) goto abort; /* XXX: memory leak */
+                               if (edg_wll_JobStatus(ctx,job,0,&stat)) {
+                                       edg_wll_FreeStatus(&stat);
+                                       goto abort; 
+                               }
 
                                switch (stat.state) {
                                        case EDG_WLL_JOB_CLEARED:
@@ -309,8 +312,10 @@ int edg_wll_PurgeServer(edg_wll_Context ctx,const edg_wll_PurgeRequest *request)
 
                                if (now-stat.lastUpdateTime.tv_sec > timeout[i] && !check_strict_jobid(ctx,job))
                                {
-                                       if (purge_one(ctx,job,dumpfile,request->flags&EDG_WLL_PURGE_REALLY_PURGE))
+                                       if (purge_one(ctx,job,dumpfile,request->flags&EDG_WLL_PURGE_REALLY_PURGE)) {
+                                               edg_wll_FreeStatus(&stat);
                                                goto abort;
+                                       }
 
                                /* XXX: change with the streaming interface */
                                        if (request->flags & EDG_WLL_PURGE_LIST_JOBS) {
@@ -396,6 +401,8 @@ abort:
        asprintf(&response, "HTTP/1.1 %d %s", ret, edg_wll_HTTPErrorMessage(ret));
 
        edg_wll_http_send(ctx, response, resp_headers, message,ctx->connections->serverConnection);
+       if (response) free(response);
+       if (message) free(message);
 
        return edg_wll_Error(ctx,NULL,NULL);
 }