From ff19c98b10b378ff7d6b441d12f2e31fa04b0d8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Thu, 7 Dec 2006 22:26:33 +0000 Subject: [PATCH] make Connection functions usable from other files, set GSS_C_NO_CREDENTIAL as the initial gsiCred, call gss_close only on open connections --- org.glite.lb.client/src/connection.c | 27 ++++++++++++++++----------- org.glite.lb.client/src/connection.h | 5 +++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/org.glite.lb.client/src/connection.c b/org.glite.lb.client/src/connection.c index 809f521..35fb63c 100644 --- a/org.glite.lb.client/src/connection.c +++ b/org.glite.lb.client/src/connection.c @@ -21,18 +21,20 @@ #include "connection.h" -static void CloseConnection(edg_wll_Context ctx, int* conn_index) +int CloseConnection(edg_wll_Context ctx, int* conn_index) +// XXX: should change the parameter conn_index to int (parameter is IN only) { - /* close connection ad free its structures */ + /* close connection and free its structures */ OM_uint32 min_stat; - int cIndex; + int cIndex,ret = 0; cIndex = *conn_index; assert(ctx->connections->connOpened); - edg_wll_gss_close(&ctx->connections->connPool[cIndex].gss, &ctx->p_tmp_timeout); - if (ctx->connections->connPool[cIndex].gsiCred) + if (ctx->connections->connPool[cIndex].gss.sock) + ret = edg_wll_gss_close(&ctx->connections->connPool[cIndex].gss, &ctx->p_tmp_timeout); + if (ctx->connections->connPool[cIndex].gsiCred != GSS_C_NO_CREDENTIAL) gss_release_cred(&min_stat, &ctx->connections->connPool[cIndex].gsiCred); free(ctx->connections->connPool[cIndex].peerName); free(ctx->connections->connPool[cIndex].buf); @@ -41,12 +43,14 @@ static void CloseConnection(edg_wll_Context ctx, int* conn_index) ctx->connections->connOpened--; - *conn_index = cIndex; +// XXX: not needed *conn_index = cIndex; + + return ret; } -static int ConnectionIndex(edg_wll_Context ctx, const char *name, int port) +int ConnectionIndex(edg_wll_Context ctx, const char *name, int port) { int i; @@ -82,7 +86,7 @@ static int ConnectionIndex(edg_wll_Context ctx, const char *name, int port) -static int AddConnection(edg_wll_Context ctx, char *name, int port) +int AddConnection(edg_wll_Context ctx, char *name, int port) { int i,index = -1; @@ -98,8 +102,9 @@ static int AddConnection(edg_wll_Context ctx, char *name, int port) if (index < 0) return -1; free(ctx->connections->connPool[index].peerName); // should be empty; just to be sure - ctx->connections->connPool[index].peerName = strdup(ctx->srvName); - ctx->connections->connPool[index].peerPort = ctx->srvPort; + ctx->connections->connPool[index].peerName = strdup(name); + ctx->connections->connPool[index].peerPort = port; + ctx->connections->connPool[index].gsiCred = GSS_C_NO_CREDENTIAL; // initial value ctx->connections->connOpened++; return index; @@ -107,7 +112,7 @@ static int AddConnection(edg_wll_Context ctx, char *name, int port) -static int ReleaseConnection(edg_wll_Context ctx, char *name, int port) +int ReleaseConnection(edg_wll_Context ctx, char *name, int port) { int i, index = 0, foundConnToDrop = 0; long min; diff --git a/org.glite.lb.client/src/connection.h b/org.glite.lb.client/src/connection.h index 1423d7e..3aab41d 100644 --- a/org.glite.lb.client/src/connection.h +++ b/org.glite.lb.client/src/connection.h @@ -13,6 +13,11 @@ int edg_wll_http_send_recv_proxy(edg_wll_Context, char *, const char * const *, int http_check_status(edg_wll_Context, char *); +int ConnectionIndex(edg_wll_Context ctx, const char *name, int port); +int AddConnection(edg_wll_Context ctx, char *name, int port); +int ReleaseConnection(edg_wll_Context ctx, char *name, int port); +int CloseConnection(edg_wll_Context ctx, int* conn_index); + #define PROXY_CONNECT_RETRY 10 /* ms */ -- 1.8.2.3