From 81b10b80521b4bd20f2a12a853143d4058519260 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Wed, 28 Mar 2007 14:15:53 +0000 Subject: [PATCH] avoid leaking proxy sockets on connect() failure --- org.glite.lb.client/src/prod_proto.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/org.glite.lb.client/src/prod_proto.c b/org.glite.lb.client/src/prod_proto.c index f45234b..402f3e6 100644 --- a/org.glite.lb.client/src/prod_proto.c +++ b/org.glite.lb.client/src/prod_proto.c @@ -443,7 +443,7 @@ int edg_wll_log_proxy_connect(edg_wll_Context ctx, edg_wll_PlainConnection *conn ctx->p_lbproxy_store_sock: socket_path); if ((flags = fcntl(conn->sock, F_GETFL, 0)) < 0 || fcntl(conn->sock, F_SETFL, flags | O_NONBLOCK) < 0) { edg_wll_SetError(ctx,answer = errno,"edg_wll_log_proxy_connect(): fcntl() error"); - close(conn->sock); + close(conn->sock); conn->sock = -1; goto edg_wll_log_proxy_connect_end; } #ifdef EDG_WLL_LOG_STUB @@ -473,6 +473,12 @@ int edg_wll_log_proxy_connect(edg_wll_Context ctx, edg_wll_PlainConnection *conn } retries++; } + + if (answer) { + edg_wll_SetError(ctx,answer = (errno == EAGAIN ? ETIMEDOUT : errno),"edg_wll_log_proxy_connect()"); + close(conn->sock); conn->sock = -1; + } + #ifdef EDG_WLL_LOG_STUB if (retries) fprintf(stderr,"edg_wll_log_proxy_connect: there were %d connect retries\n",retries); #endif -- 1.8.2.3