From 463bcdd2c4619e3d50643493ce441fef238a5d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Wed, 12 Apr 2017 16:00:52 +0100 Subject: [PATCH] Update backend progress tracking --- servers/lloadd/backend.c | 16 ++++++++++++---- servers/lloadd/upstream.c | 2 -- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/servers/lloadd/backend.c b/servers/lloadd/backend.c index 3a6d96234b..d0d9b85e2c 100644 --- a/servers/lloadd/backend.c +++ b/servers/lloadd/backend.c @@ -31,7 +31,6 @@ static void upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg ) { Backend *b = arg; - Connection *c; ber_socket_t s = AC_SOCKET_INVALID; int rc; @@ -70,7 +69,11 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg ) goto fail; } - c = upstream_init( s, b ); + if ( !upstream_init( s, b ) ) { + goto fail; + } + b->b_opening--; + b->b_failed = 0; ldap_pvt_thread_mutex_unlock( &b->b_mutex ); backend_retry( b ); return; @@ -80,6 +83,7 @@ fail: evutil_closesocket( s ); } b->b_opening--; + b->b_failed++; ldap_pvt_thread_mutex_unlock( &b->b_mutex ); backend_retry( b ); } @@ -161,7 +165,6 @@ backend_connect( void *ctx, void *arg ) #ifdef LDAP_PF_LOCAL if ( b->b_proto == LDAP_PROTO_IPC ) { struct sockaddr_un addr; - Connection *c; ber_socket_t s = socket( PF_LOCAL, SOCK_STREAM, 0 ); int rc; @@ -190,7 +193,11 @@ backend_connect( void *ctx, void *arg ) goto fail; } - c = upstream_init( s, b ); + if ( !upstream_init( s, b ) ) { + goto fail; + } + b->b_opening--; + b->b_failed = 0; ldap_pvt_thread_mutex_unlock( &b->b_mutex ); backend_retry( b ); return NULL; @@ -210,6 +217,7 @@ backend_connect( void *ctx, void *arg ) fail: b->b_opening--; + b->b_failed++; ldap_pvt_thread_mutex_unlock( &b->b_mutex ); backend_retry( b ); return (void *)-1; diff --git a/servers/lloadd/upstream.c b/servers/lloadd/upstream.c index eb5291f3e2..e5bfd657fb 100644 --- a/servers/lloadd/upstream.c +++ b/servers/lloadd/upstream.c @@ -748,8 +748,6 @@ upstream_init( ber_socket_t s, Backend *b ) assert( b != NULL ); - b->b_opening--; - flags = (b->b_tls == LLOAD_LDAPS) ? CONN_IS_TLS : 0; c = connection_init( s, b->b_host, flags ); c->c_private = b;