Memleaks in lb.server (cca 450 kB per 500 request).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 15 Feb 2013 08:15:11 +0000 (08:15 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 15 Feb 2013 21:59:02 +0000 (22:59 +0100)
org.glite.lb.server/src/notif_match.c
org.glite.lb.server/src/stats.c
org.glite.lb.server/src/store.c.T

index c663e83..883cb73 100644 (file)
@@ -116,6 +116,8 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons
                ju = edg_wlc_JobIdGetUnique(stat->jobId),NOTIF_ALL_JOBS,cond_where ? cond_where : "",cond_and_where ? cond_and_where : "");
 
        free(ju); ju = NULL;
+       free(cond_where); cond_where = NULL;
+       free(cond_and_where); cond_and_where = NULL;
        glite_common_log_msg(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, jobq);
 
        if (edg_wll_ExecSQL(ctx,jobq,&jobs) < 0) goto err;
@@ -220,6 +222,8 @@ err:
        if ( nid ) edg_wll_NotifIdFree(nid);
        free(jobq);
        glite_lbu_FreeStmt(&jobs);
+       free(cond_where);
+       free(cond_and_where);
        return edg_wll_Error(ctx,NULL,NULL);
 }
 
index 58a43a2..5b58a00 100644 (file)
@@ -83,9 +83,11 @@ int edg_wll_InitStatistics(edg_wll_Context ctx)
 {
        edg_wll_Stats *stats = default_stats;   /* XXX: hardcoded */
        int     i,j;
+       char *zero = NULL;
+       size_t zero_size = 0;
 
        for (i=0; stats[i].type; i++) {
-               char    fname[50],*zero;
+               char    fname[50];
 
                strcpy(fname,"/tmp/lb_stats.XXXXXX");
                stats[i].fd = mkstemp(fname);
@@ -99,7 +101,11 @@ int edg_wll_InitStatistics(edg_wll_Context ctx)
                        stats[i].grpsize += sizeof(struct edg_wll_stats_archive)-sizeof(struct edg_wll_stats_cell);
                        stats[i].grpsize += stats[i].archives[j].length * sizeof(struct edg_wll_stats_cell);
                }
-               zero = calloc(1,stats[i].grpsize);
+               if (stats[i].grpsize > zero_size) {
+                       free(zero);
+                       zero = calloc(1, stats[i].grpsize);
+                       zero_size = stats[i].grpsize;
+               }
                write(stats[i].fd,zero,stats[i].grpsize);
                stats[i].map = mmap(NULL,stats[i].grpsize,PROT_READ|PROT_WRITE,MAP_SHARED,stats[i].fd,0);
                if (stats[i].map == MAP_FAILED) return edg_wll_SetError(ctx,errno,"mmap()");
@@ -119,6 +125,7 @@ int edg_wll_InitStatistics(edg_wll_Context ctx)
                        stats[i].htab = NULL;
                }
        }
+       free(zero);
        return 0;
 }
 
index ddadbbb..23eb558 100644 (file)
@@ -532,6 +532,7 @@ static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,char
        glite_common_log_msg(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) err = edg_wll_Error(ctx,NULL,NULL);
+       free(stmt);
 #endif
 
        return err;