From: Aleš Křenek Date: Thu, 7 Jul 2005 11:42:53 +0000 (+0000) Subject: prevent closing an already closed connection X-Git-Tag: glite-lb-client_R_1_0_5~1 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=beca28fee01e09addf163d00851cc195819e92ac;p=jra1mw.git prevent closing an already closed connection --- diff --git a/org.glite.lb.client/src/connection.c b/org.glite.lb.client/src/connection.c index f7e666a..931a072 100644 --- a/org.glite.lb.client/src/connection.c +++ b/org.glite.lb.client/src/connection.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "glite/lb/consumer.h" #include "glite/lb/context-int.h" @@ -21,6 +22,9 @@ static void CloseConnection(edg_wll_Context ctx, int conn_index) /* close connection ad free its structures */ OM_uint32 min_stat; + assert(ctx->connOpened); + assert(conn_index < ctx->connOpened); + edg_wll_gss_close(&ctx->connPool[conn_index].gss, &ctx->p_tmp_timeout); if (ctx->connPool[conn_index].gsiCred) gss_release_cred(&min_stat, &ctx->connPool[conn_index].gsiCred); @@ -96,9 +100,11 @@ static void ReleaseConnection(edg_wll_Context ctx, char *name, int port) int edg_wll_close(edg_wll_Context ctx) { edg_wll_ResetError(ctx); + if (ctx->connToUse == -1) return 0; CloseConnection(ctx, ctx->connToUse); + ctx->connToUse = -1; return edg_wll_Error(ctx,NULL,NULL); } @@ -183,6 +189,7 @@ err: /* some error occured; close created connection * and free all fields in connPool[index] */ CloseConnection(ctx, index); + ctx->connToUse = -1; ok: return edg_wll_Error(ctx,NULL,NULL); } @@ -320,6 +327,7 @@ int edg_wll_http_send_recv( default: goto err; } + assert(ctx->connToUse >= 0); gettimeofday(&ctx->connPool[ctx->connToUse].lastUsed, NULL); return 0;