}
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;
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;
"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 );
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 );
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,
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;
}
#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;
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;
"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);
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 ) {