mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-03 13:40:37 -05:00
Passing the client directly will allow clearing it from op
This commit is contained in:
parent
1fd7249f8e
commit
ddd1acc327
4 changed files with 61 additions and 52 deletions
|
|
@ -333,9 +333,12 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
|||
}
|
||||
|
||||
int
|
||||
handle_bind_response( LloadOperation *op, BerElement *ber )
|
||||
handle_bind_response(
|
||||
LloadConnection *client,
|
||||
LloadOperation *op,
|
||||
BerElement *ber )
|
||||
{
|
||||
LloadConnection *client = op->o_client, *upstream = op->o_upstream;
|
||||
LloadConnection *upstream = op->o_upstream;
|
||||
BerValue response;
|
||||
BerElement *copy;
|
||||
ber_int_t result;
|
||||
|
|
@ -407,14 +410,16 @@ done:
|
|||
ber_free( ber, 1 );
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
return forward_final_response( op, ber );
|
||||
return forward_final_response( client, op, ber );
|
||||
}
|
||||
|
||||
#ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS
|
||||
int
|
||||
handle_vc_bind_response( LloadOperation *op, BerElement *ber )
|
||||
handle_vc_bind_response(
|
||||
LloadConnection *client,
|
||||
LloadOperation *op,
|
||||
BerElement *ber )
|
||||
{
|
||||
LloadConnection *c = op->o_client;
|
||||
BerElement *output;
|
||||
BerValue matched, diagmsg, creds = BER_BVNULL, controls = BER_BVNULL;
|
||||
ber_int_t result;
|
||||
|
|
@ -447,16 +452,16 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
|
|||
"connid=%lu, result=%d\n",
|
||||
op->o_client_msgid, op->o_client_connid, result );
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
CONNECTION_LOCK(client);
|
||||
|
||||
if ( tag == LDAP_TAG_EXOP_VERIFY_CREDENTIALS_COOKIE ) {
|
||||
if ( !BER_BVISNULL( &c->c_vc_cookie ) ) {
|
||||
ber_memfree( c->c_vc_cookie.bv_val );
|
||||
if ( !BER_BVISNULL( &client->c_vc_cookie ) ) {
|
||||
ber_memfree( client->c_vc_cookie.bv_val );
|
||||
}
|
||||
tag = ber_scanf( ber, "o", &c->c_vc_cookie );
|
||||
tag = ber_scanf( ber, "o", &client->c_vc_cookie );
|
||||
if ( tag == LBER_ERROR ) {
|
||||
rc = -1;
|
||||
CONNECTION_UNLOCK_INCREF(c);
|
||||
CONNECTION_UNLOCK_INCREF(client);
|
||||
goto done;
|
||||
}
|
||||
tag = ber_peek_tag( ber, &len );
|
||||
|
|
@ -466,7 +471,7 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
|
|||
tag = ber_scanf( ber, "m", &creds );
|
||||
if ( tag == LBER_ERROR ) {
|
||||
rc = -1;
|
||||
CONNECTION_UNLOCK_INCREF(c);
|
||||
CONNECTION_UNLOCK_INCREF(client);
|
||||
goto done;
|
||||
}
|
||||
tag = ber_peek_tag( ber, &len );
|
||||
|
|
@ -476,51 +481,51 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
|
|||
tag = ber_scanf( ber, "m", &controls );
|
||||
if ( tag == LBER_ERROR ) {
|
||||
rc = -1;
|
||||
CONNECTION_UNLOCK_INCREF(c);
|
||||
CONNECTION_UNLOCK_INCREF(client);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if ( c->c_state == LLOAD_C_BINDING ) {
|
||||
if ( client->c_state == LLOAD_C_BINDING ) {
|
||||
switch ( result ) {
|
||||
case LDAP_SASL_BIND_IN_PROGRESS:
|
||||
break;
|
||||
case LDAP_SUCCESS:
|
||||
default: {
|
||||
c->c_state = LLOAD_C_READY;
|
||||
c->c_type = LLOAD_C_OPEN;
|
||||
client->c_state = LLOAD_C_READY;
|
||||
client->c_type = LLOAD_C_OPEN;
|
||||
if ( result != LDAP_SUCCESS ) {
|
||||
ber_memfree( c->c_auth.bv_val );
|
||||
BER_BVZERO( &c->c_auth );
|
||||
ber_memfree( client->c_auth.bv_val );
|
||||
BER_BVZERO( &client->c_auth );
|
||||
} else if ( !ber_bvstrcasecmp(
|
||||
&c->c_auth, &lloadd_identity ) ) {
|
||||
c->c_type = LLOAD_C_PRIVILEGED;
|
||||
&client->c_auth, &lloadd_identity ) ) {
|
||||
client->c_type = LLOAD_C_PRIVILEGED;
|
||||
}
|
||||
if ( !BER_BVISNULL( &c->c_vc_cookie ) ) {
|
||||
ber_memfree( c->c_vc_cookie.bv_val );
|
||||
BER_BVZERO( &c->c_vc_cookie );
|
||||
if ( !BER_BVISNULL( &client->c_vc_cookie ) ) {
|
||||
ber_memfree( client->c_vc_cookie.bv_val );
|
||||
BER_BVZERO( &client->c_vc_cookie );
|
||||
}
|
||||
if ( !BER_BVISNULL( &c->c_sasl_bind_mech ) ) {
|
||||
ber_memfree( c->c_sasl_bind_mech.bv_val );
|
||||
BER_BVZERO( &c->c_sasl_bind_mech );
|
||||
if ( !BER_BVISNULL( &client->c_sasl_bind_mech ) ) {
|
||||
ber_memfree( client->c_sasl_bind_mech.bv_val );
|
||||
BER_BVZERO( &client->c_sasl_bind_mech );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assert( c->c_state == LLOAD_C_INVALID ||
|
||||
c->c_state == LLOAD_C_CLOSING );
|
||||
assert( client->c_state == LLOAD_C_INVALID ||
|
||||
client->c_state == LLOAD_C_CLOSING );
|
||||
}
|
||||
CONNECTION_UNLOCK_INCREF(c);
|
||||
CONNECTION_UNLOCK_INCREF(client);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
output = c->c_pendingber;
|
||||
ldap_pvt_thread_mutex_lock( &client->c_io_mutex );
|
||||
output = client->c_pendingber;
|
||||
if ( output == NULL && (output = ber_alloc()) == NULL ) {
|
||||
rc = -1;
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
goto done;
|
||||
}
|
||||
c->c_pendingber = output;
|
||||
client->c_pendingber = output;
|
||||
|
||||
rc = ber_printf( output, "t{tit{eOOtO}tO}", LDAP_TAG_MESSAGE,
|
||||
LDAP_TAG_MSGID, op->o_client_msgid, LDAP_RES_BIND,
|
||||
|
|
@ -528,16 +533,16 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
|
|||
LDAP_TAG_SASL_RES_CREDS, BER_BV_OPTIONAL( &creds ),
|
||||
LDAP_TAG_CONTROLS, BER_BV_OPTIONAL( &controls ) );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
if ( rc >= 0 ) {
|
||||
connection_write_cb( -1, 0, c );
|
||||
connection_write_cb( -1, 0, client );
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
done:
|
||||
CONNECTION_LOCK_DECREF(c);
|
||||
CONNECTION_LOCK_DECREF(client);
|
||||
operation_destroy_from_client( op );
|
||||
CONNECTION_UNLOCK_OR_DESTROY(c);
|
||||
CONNECTION_UNLOCK_OR_DESTROY(client);
|
||||
ber_free( ber, 1 );
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,9 @@ struct LloadBackend {
|
|||
LDAP_CIRCLEQ_ENTRY(LloadBackend) b_next;
|
||||
};
|
||||
|
||||
typedef int (*LloadOperationHandler)( LloadOperation *op, BerElement *ber );
|
||||
typedef int (*LloadOperationHandler)( LloadConnection *client,
|
||||
LloadOperation *op,
|
||||
BerElement *ber );
|
||||
typedef int (*RequestHandler)( LloadConnection *c, LloadOperation *op );
|
||||
typedef struct lload_exop_handlers_t {
|
||||
struct berval oid;
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ LDAP_SLAPD_F (void) backends_destroy( void );
|
|||
* bind.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) request_bind( LloadConnection *c, LloadOperation *op );
|
||||
LDAP_SLAPD_F (int) handle_bind_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) handle_vc_bind_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) handle_bind_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) handle_vc_bind_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
|
||||
|
||||
/*
|
||||
* client.c
|
||||
|
|
@ -151,8 +151,8 @@ LDAP_SLAPD_F (void) operations_timeout( evutil_socket_t s, short what, void *arg
|
|||
/*
|
||||
* upstream.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) forward_final_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) forward_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) forward_final_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) forward_response( LloadConnection *client, LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (LloadConnection *) upstream_init( ber_socket_t s, LloadBackend *b );
|
||||
LDAP_SLAPD_F (void) upstream_destroy( LloadConnection *c );
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@
|
|||
#include "lload.h"
|
||||
|
||||
int
|
||||
forward_response( LloadOperation *op, BerElement *ber )
|
||||
forward_response( LloadConnection *client, LloadOperation *op, BerElement *ber )
|
||||
{
|
||||
LloadConnection *c = op->o_client;
|
||||
BerElement *output;
|
||||
BerValue response, controls = BER_BVNULL;
|
||||
ber_tag_t tag, response_tag;
|
||||
|
|
@ -45,29 +44,32 @@ forward_response( LloadOperation *op, BerElement *ber )
|
|||
lload_msgtype2str( response_tag ), op->o_client_connid,
|
||||
op->o_client_msgid );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
output = c->c_pendingber;
|
||||
ldap_pvt_thread_mutex_lock( &client->c_io_mutex );
|
||||
output = client->c_pendingber;
|
||||
if ( output == NULL && (output = ber_alloc()) == NULL ) {
|
||||
ber_free( ber, 1 );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
return -1;
|
||||
}
|
||||
c->c_pendingber = output;
|
||||
client->c_pendingber = output;
|
||||
|
||||
ber_printf( output, "t{titOtO}", LDAP_TAG_MESSAGE,
|
||||
LDAP_TAG_MSGID, op->o_client_msgid,
|
||||
response_tag, &response,
|
||||
LDAP_TAG_CONTROLS, BER_BV_OPTIONAL( &controls ) );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
|
||||
ber_free( ber, 1 );
|
||||
connection_write_cb( -1, 0, c );
|
||||
connection_write_cb( -1, 0, client );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
forward_final_response( LloadOperation *op, BerElement *ber )
|
||||
forward_final_response(
|
||||
LloadConnection *client,
|
||||
LloadOperation *op,
|
||||
BerElement *ber )
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
|
@ -75,7 +77,7 @@ forward_final_response( LloadOperation *op, BerElement *ber )
|
|||
"connid=%lu msgid=%d finishing up with a request for "
|
||||
"client connid=%lu\n",
|
||||
op->o_upstream_connid, op->o_upstream_msgid, op->o_client_connid );
|
||||
rc = forward_response( op, ber );
|
||||
rc = forward_response( client, op, ber );
|
||||
CONNECTION_LOCK_DECREF(op->o_upstream);
|
||||
operation_destroy_from_upstream( op );
|
||||
CONNECTION_UNLOCK_INCREF(op->o_upstream);
|
||||
|
|
@ -223,7 +225,7 @@ handle_one_response( LloadConnection *c )
|
|||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
|
||||
if ( client ) {
|
||||
rc = handler( op, ber );
|
||||
rc = handler( client, op, ber );
|
||||
CONNECTION_LOCK_DECREF(client);
|
||||
op->o_client_refcnt--;
|
||||
if ( !op->o_client_refcnt ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue