mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-03 20:40:05 -05:00
Initial extension to upstream selection
This commit is contained in:
parent
c91d61cf19
commit
66f06f3fa9
4 changed files with 15 additions and 10 deletions
|
|
@ -176,7 +176,7 @@ fail:
|
|||
}
|
||||
|
||||
LloadConnection *
|
||||
backend_select( LloadOperation *op )
|
||||
backend_select( LloadOperation *op, int *res )
|
||||
{
|
||||
LloadBackend *b, *first, *next;
|
||||
|
||||
|
|
@ -184,6 +184,8 @@ backend_select( LloadOperation *op )
|
|||
first = b = current_backend;
|
||||
ldap_pvt_thread_mutex_unlock( &backend_mutex );
|
||||
|
||||
*res = LDAP_UNAVAILABLE;
|
||||
|
||||
if ( !first ) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -203,6 +205,7 @@ backend_select( LloadOperation *op )
|
|||
b->b_uri.bv_val );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
b = next;
|
||||
*res = LDAP_BUSY;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -215,6 +218,9 @@ backend_select( LloadOperation *op )
|
|||
} else {
|
||||
head = &b->b_conns;
|
||||
}
|
||||
if ( !LDAP_CIRCLEQ_EMPTY( head ) ) {
|
||||
*res = LDAP_BUSY;
|
||||
}
|
||||
|
||||
LDAP_CIRCLEQ_FOREACH ( c, head, c_next ) {
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
|
|
@ -243,6 +249,7 @@ backend_select( LloadOperation *op )
|
|||
CONNECTION_UNLOCK_INCREF(c);
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
*res = LDAP_SUCCESS;
|
||||
return c;
|
||||
}
|
||||
CONNECTION_UNLOCK(c);
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ int
|
|||
request_bind( LloadConnection *client, LloadOperation *op )
|
||||
{
|
||||
LloadConnection *upstream;
|
||||
int rc = LDAP_SUCCESS;
|
||||
int res, rc = LDAP_SUCCESS;
|
||||
|
||||
/* protect the Bind operation */
|
||||
op->o_client_refcnt++;
|
||||
|
|
@ -278,13 +278,12 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
|||
assert( rc == LDAP_SUCCESS );
|
||||
CONNECTION_UNLOCK_INCREF(client);
|
||||
|
||||
upstream = backend_select( op );
|
||||
upstream = backend_select( op, &res );
|
||||
if ( !upstream ) {
|
||||
Debug( LDAP_DEBUG_STATS, "client_bind: "
|
||||
"connid=%lu, msgid=%d no available connection found\n",
|
||||
op->o_client_connid, op->o_client_msgid );
|
||||
operation_send_reject(
|
||||
op, LDAP_UNAVAILABLE, "no connections available", 1 );
|
||||
operation_send_reject( op, res, "no connections available", 1 );
|
||||
CONNECTION_LOCK_DECREF(client);
|
||||
op->o_client_refcnt--;
|
||||
operation_destroy_from_client( op );
|
||||
|
|
|
|||
|
|
@ -86,19 +86,18 @@ request_process( LloadConnection *client, LloadOperation *op )
|
|||
BerElement *output;
|
||||
LloadConnection *upstream;
|
||||
ber_int_t msgid;
|
||||
int rc = LDAP_SUCCESS;
|
||||
int res, rc = LDAP_SUCCESS;
|
||||
|
||||
op->o_client_refcnt++;
|
||||
CONNECTION_UNLOCK_INCREF(client);
|
||||
|
||||
upstream = backend_select( op );
|
||||
upstream = backend_select( op, &res );
|
||||
if ( !upstream ) {
|
||||
Debug( LDAP_DEBUG_STATS, "request_process: "
|
||||
"connid=%lu, msgid=%d no available connection found\n",
|
||||
op->o_client_connid, op->o_client_msgid );
|
||||
|
||||
operation_send_reject(
|
||||
op, LDAP_UNAVAILABLE, "no connections available", 1 );
|
||||
operation_send_reject( op, res, "no connections available", 1 );
|
||||
goto fail;
|
||||
}
|
||||
op->o_upstream = upstream;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ struct config_reply_s; /* config.h */
|
|||
LDAP_SLAPD_F (void) backend_connect( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (void *) backend_connect_task( void *ctx, void *arg );
|
||||
LDAP_SLAPD_F (void) backend_retry( LloadBackend *b );
|
||||
LDAP_SLAPD_F (LloadConnection *) backend_select( LloadOperation *op );
|
||||
LDAP_SLAPD_F (LloadConnection *) backend_select( LloadOperation *op, int *res );
|
||||
LDAP_SLAPD_F (void) backends_destroy( void );
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue