Commit 6b10c298 authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

Record pending DNS resolution to be able to cancel

parent b039e7c1
...@@ -95,6 +95,7 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg ) ...@@ -95,6 +95,7 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
ldap_pvt_thread_mutex_lock( &b->b_mutex ); ldap_pvt_thread_mutex_lock( &b->b_mutex );
b->b_dns_req = NULL;
if ( result || !res ) { if ( result || !res ) {
Debug( LDAP_DEBUG_ANY, "upstream_name_cb: " Debug( LDAP_DEBUG_ANY, "upstream_name_cb: "
"name resolution failed for backend '%s': %s\n", "name resolution failed for backend '%s': %s\n",
...@@ -169,7 +170,9 @@ fail: ...@@ -169,7 +170,9 @@ fail:
b->b_opening--; b->b_opening--;
b->b_failed++; b->b_failed++;
ldap_pvt_thread_mutex_unlock( &b->b_mutex ); ldap_pvt_thread_mutex_unlock( &b->b_mutex );
backend_retry( b ); if ( result != EVUTIL_EAI_CANCEL ) {
backend_retry( b );
}
if ( res ) { if ( res ) {
evutil_freeaddrinfo( res ); evutil_freeaddrinfo( res );
} }
...@@ -415,7 +418,9 @@ backend_connect( evutil_socket_t s, short what, void *arg ) ...@@ -415,7 +418,9 @@ backend_connect( evutil_socket_t s, short what, void *arg )
hostname = b->b_host; hostname = b->b_host;
ldap_pvt_thread_mutex_unlock( &b->b_mutex ); ldap_pvt_thread_mutex_unlock( &b->b_mutex );
evdns_getaddrinfo( dnsbase, hostname, NULL, &hints, upstream_name_cb, b ); assert( b->b_dns_req == NULL );
b->b_dns_req = evdns_getaddrinfo(
dnsbase, hostname, NULL, &hints, upstream_name_cb, b );
return; return;
fail: fail:
...@@ -483,6 +488,11 @@ backend_reset( LloadBackend *b ) ...@@ -483,6 +488,11 @@ backend_reset( LloadBackend *b )
CONNECTION_DESTROY(c); CONNECTION_DESTROY(c);
assert( !c ); assert( !c );
} }
if ( b->b_dns_req ) {
evdns_getaddrinfo_cancel( b->b_dns_req );
b->b_dns_req = NULL;
b->b_opening--;
}
} }
void void
......
...@@ -212,6 +212,8 @@ struct LloadBackend { ...@@ -212,6 +212,8 @@ struct LloadBackend {
monitor_subsys_t *b_monitor; monitor_subsys_t *b_monitor;
#endif /* BALANCER_MODULE */ #endif /* BALANCER_MODULE */
struct evdns_getaddrinfo_request *b_dns_req;
LDAP_CIRCLEQ_ENTRY(LloadBackend) b_next; LDAP_CIRCLEQ_ENTRY(LloadBackend) b_next;
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment