return NULL;
}
+/*
+ * Needs exclusive access to the backend.
+ */
void
backend_reset( LloadBackend *b )
{
+ if ( b->b_cookie ) {
+ int rc;
+ rc = ldap_pvt_thread_pool_retract( b->b_cookie );
+ assert( rc == 1 );
+ b->b_cookie = NULL;
+ b->b_opening--;
+ }
+ if ( event_pending( b->b_retry_event, EV_TIMEOUT, NULL ) ) {
+ assert( b->b_failed );
+ event_del( b->b_retry_event );
+ b->b_opening--;
+ }
+ if ( b->b_dns_req ) {
+ evdns_getaddrinfo_cancel( b->b_dns_req );
+ b->b_dns_req = NULL;
+ b->b_opening--;
+ }
while ( !LDAP_LIST_EMPTY( &b->b_connecting ) ) {
LloadPendingConnection *pending = LDAP_LIST_FIRST( &b->b_connecting );
"destroying backend uri='%s', numconns=%d, numbindconns=%d\n",
b->b_uri.bv_val, b->b_numconns, b->b_numbindconns );
+ b->b_numconns = b->b_numbindconns = 0;
backend_reset( b );
LDAP_CIRCLEQ_REMOVE( &backend, b, b_next );
destroy_listeners();
/* TODO: Mark upstream connections closing */
+ LDAP_CIRCLEQ_FOREACH ( b, &backend, b_next ) {
+ ldap_pvt_thread_mutex_lock( &b->b_mutex );
+ b->b_numconns = b->b_numbindconns = 0;
+ backend_reset( b );
+ ldap_pvt_thread_mutex_unlock( &b->b_mutex );
+ }
for ( i = 0; i < lload_daemon_threads; i++ ) {
/*
&connection_pool, handle_pdus, backend_conn_cb, b );
ldap_pvt_thread_pool_walk(
&connection_pool, upstream_bind, backend_conn_cb, b );
- /* Drop the connection task if it's queued */
- if ( b->b_cookie ) {
- int rc = ldap_pvt_thread_pool_retract( b->b_cookie );
- assert( rc == 1 );
- b->b_opening--;
- }
lload_backend_destroy( b );
return;
}
b->b_opening--;
need_close--;
}
- event_del( b->b_retry_event );
+ if ( event_pending( b->b_retry_event, EV_TIMEOUT, NULL ) ) {
+ event_del( b->b_retry_event );
+ b->b_opening--;
+ }
assert( b->b_opening == 0 );
}