From 0b2c87ac487baa72705be60f0d5bb5a9295475d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Tue, 7 Jun 2005 15:55:46 +0000 Subject: [PATCH] Fixed double-purge bug. --- org.glite.lb.server/src/dump.c | 20 +++++++++++++++----- org.glite.lb.server/src/server_state.c | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/org.glite.lb.server/src/dump.c b/org.glite.lb.server/src/dump.c index afe262a..e14a55c 100644 --- a/org.glite.lb.server/src/dump.c +++ b/org.glite.lb.server/src/dump.c @@ -23,13 +23,14 @@ #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; +} diff --git a/org.glite.lb.server/src/server_state.c b/org.glite.lb.server/src/server_state.c index 4f82ecb..cc7401e 100644 --- a/org.glite.lb.server/src/server_state.c +++ b/org.glite.lb.server/src/server_state.c @@ -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)) { -- 1.8.2.3