Fixed double-purge bug.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 7 Jun 2005 15:55:46 +0000 (15:55 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 7 Jun 2005 15:55:46 +0000 (15:55 +0000)
org.glite.lb.server/src/dump.c
org.glite.lb.server/src/server_state.c

index afe262a..e14a55c 100644 (file)
 #include "server_state.h"
 #include "purge.h"
 
+static char *time_to_string(time_t t, char **ptr);
 static int handle_specials(edg_wll_Context,time_t *);
 
 #define sizofa(a) (sizeof(a)/sizeof((a)[0]))
 
 int edg_wll_DumpEvents(edg_wll_Context ctx,const edg_wll_DumpRequest *req,edg_wll_DumpResult *result)
 {
-       char    *from_s, *to_s, *stmt, *time_s;
+       char    *from_s, *to_s, *stmt, *time_s, *ptr;
        char    *tmpfname;
        time_t  start,end;
        edg_wll_Stmt    q = NULL;
@@ -130,13 +131,13 @@ int edg_wll_DumpEvents(edg_wll_Context ctx,const edg_wll_DumpRequest *req,edg_wl
        }
 
        time(&end);
-       time_s = strdup(edg_wll_TimeToDB(start));
+       time_s = time_to_string(start, &ptr);
        edg_wll_SetServerState(ctx,EDG_WLL_STATE_DUMP_START,time_s);
-       free(time_s);
+       free(ptr);
        
-       time_s = strdup(edg_wll_TimeToDB(end));
+       time_s = time_to_string(end, &ptr);
        edg_wll_SetServerState(ctx,EDG_WLL_STATE_DUMP_END,time_s);
-       free(time_s);
+       free(ptr);
 
        result->from = from;
        result->to = to;
@@ -187,3 +188,12 @@ static int handle_specials(edg_wll_Context ctx,time_t *t)
 }
 
 
+static char *time_to_string(time_t t, char **ptr) {
+       char *s;
+
+       s = edg_wll_TimeToDB(t);
+       s[strlen(s) - 1] = '\0';
+       *ptr = s;
+
+       return s + 1;
+}
index 4f82ecb..cc7401e 100644 (file)
@@ -32,7 +32,7 @@ int edg_wll_SetServerState(edg_wll_Context ctx,const char *name,const char *val)
        char    *stmt = NULL;
 
        trio_asprintf(&stmt,"insert into server_state (prefix,name,value) "
-                       "values ('https://%|Ss:%d','%|Ss',%s)",
+                       "values ('https://%|Ss:%d','%|Ss','%|Ss')",
                        ctx->srvName,ctx->srvPort,name,val);
 
        switch(edg_wll_ExecStmt(ctx,stmt,NULL)) {