From cfc76041d184a67656b879780db41ddee3de2e42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Thu, 23 Jun 2005 10:40:01 +0000 Subject: [PATCH] - fix for #9183 - example code modified to trigger the bug --- org.glite.lb.client/examples/job_log.c | 7 ++---- org.glite.lb.client/project/version.properties | 2 +- org.glite.lb.client/src/connection.c | 32 ++++++++++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/org.glite.lb.client/examples/job_log.c b/org.glite.lb.client/examples/job_log.c index ca1c09e..4d7a550 100644 --- a/org.glite.lb.client/examples/job_log.c +++ b/org.glite.lb.client/examples/job_log.c @@ -44,7 +44,7 @@ int main(int argc,char **argv) { edg_wll_Context ctx; char *errt,*errd; - edg_wll_Event *events; + edg_wll_Event *events = NULL; edg_wlc_JobId job; int i,opt,delay = 1,count = 0; @@ -71,13 +71,10 @@ int main(int argc,char **argv) if ( edg_wll_JobLog(ctx,job,&events) ) { - if ( edg_wll_Error(ctx, &errt, &errd) != E2BIG ) - goto err; - fprintf(stderr,"%s: %s (%s)\n",argv[0],errt,errd); } - for ( i = 0; events[i].type != EDG_WLL_EVENT_UNDEF; i++ ) + for ( i = 0; events && events[i].type != EDG_WLL_EVENT_UNDEF; i++ ) { char *e = edg_wll_UnparseEvent(ctx,events+i); fputs(e,stdout); diff --git a/org.glite.lb.client/project/version.properties b/org.glite.lb.client/project/version.properties index e27af18..9a46fde 100644 --- a/org.glite.lb.client/project/version.properties +++ b/org.glite.lb.client/project/version.properties @@ -1,4 +1,4 @@ -module.version = 1.0.3 +module.version = 1.0.4 module.age = 1 diff --git a/org.glite.lb.client/src/connection.c b/org.glite.lb.client/src/connection.c index 173ef47..f7e666a 100644 --- a/org.glite.lb.client/src/connection.c +++ b/org.glite.lb.client/src/connection.c @@ -292,6 +292,9 @@ int edg_wll_http_send_recv( char ***resp_head, char **resp_body) { + int ec; + char *ed = NULL; + if (edg_wll_open(ctx)) return edg_wll_Error(ctx,NULL,NULL); switch (edg_wll_http_send(ctx,request,req_head,req_body)) { @@ -299,22 +302,33 @@ int edg_wll_http_send_recv( edg_wll_close(ctx); if (edg_wll_open(ctx) || edg_wll_http_send(ctx,request,req_head,req_body)) - return edg_wll_Error(ctx,NULL,NULL); + goto err; /* fallthrough */ case 0: break; - default: return edg_wll_Error(ctx,NULL,NULL); + default: goto err; } - if (edg_wll_http_recv(ctx,response,resp_head,resp_body) == ENOTCONN) { - edg_wll_close(ctx); - (void) (edg_wll_open(ctx) - || edg_wll_http_send(ctx,request,req_head,req_body) - || edg_wll_http_recv(ctx,response,resp_head,resp_body)); + switch (edg_wll_http_recv(ctx,response,resp_head,resp_body)) { + case ENOTCONN: + edg_wll_close(ctx); + if (edg_wll_open(ctx) + || edg_wll_http_send(ctx,request,req_head,req_body) + || edg_wll_http_recv(ctx,response,resp_head,resp_body)) + goto err; + /* fallthrough */ + case 0: break; + default: goto err; } gettimeofday(&ctx->connPool[ctx->connToUse].lastUsed, NULL); - - return edg_wll_Error(ctx,NULL,NULL); + return 0; + +err: + ec = edg_wll_Error(ctx,NULL,&ed); + edg_wll_close(ctx); + edg_wll_SetError(ctx,ec,ed); + free(ed); + return ec; } -- 1.8.2.3