Save connection ids on operation for logging purposes

This commit is contained in:
Ondřej Kuzník 2017-04-14 09:43:37 +01:00 committed by Ondřej Kuzník
parent 54cd3a27f0
commit e5fcf17506
4 changed files with 23 additions and 9 deletions

View File

@ -91,6 +91,10 @@ request_bind( Operation *op )
LDAP_REQ_BIND, &op->o_request,
LDAP_TAG_CONTROLS, BER_BV_OPTIONAL( &op->o_ctrls ) );
Debug( LDAP_DEBUG_TRACE, "request_bind: "
"added bind from client connid=%lu to upstream connid=%lu as "
"msgid=%d\n",
op->o_client_connid, op->o_upstream_connid, op->o_upstream_msgid );
if ( tavl_insert( &upstream->c_ops, op, operation_upstream_cmp,
avl_dup_error ) ) {
assert(0);
@ -216,6 +220,10 @@ request_bind_as_vc( Operation *op )
}
ldap_pvt_thread_mutex_lock( &upstream->c_mutex );
Debug( LDAP_DEBUG_TRACE, "request_bind_as_vc: "
"added bind from client connid=%lu to upstream connid=%lu as VC "
"exop msgid=%d\n",
op->o_client_connid, op->o_upstream_connid, op->o_upstream_msgid );
if ( tavl_insert( &upstream->c_ops, op, operation_upstream_cmp,
avl_dup_error ) ) {
assert(0);
@ -300,6 +308,7 @@ client_bind( void *ctx, void *arg )
}
op->o_upstream = upstream;
op->o_upstream_connid = upstream->c_connid;
if ( lload_features & LLOAD_FEATURE_VC ) {
rc = request_bind_as_vc( op );
} else {

View File

@ -139,6 +139,7 @@ operation_init( Connection *c, BerElement *ber )
op = ch_calloc( 1, sizeof(Operation) );
op->o_client = c;
op->o_client_connid = c->c_connid;
op->o_ber = ber;
tag = ber_get_int( ber, &op->o_client_msgid );
@ -149,9 +150,9 @@ operation_init( Connection *c, BerElement *ber )
rc = tavl_insert( &c->c_ops, op, operation_client_cmp, avl_dup_error );
if ( rc ) {
Debug( LDAP_DEBUG_PACKETS, "operation_init: "
"several operations with same msgid=%d in-flight "
"from the client\n",
op->o_client_msgid );
"several operations with same msgid=%d in-flight from client "
"%lu\n",
op->o_client_msgid, op->o_client_connid );
goto fail;
}
@ -173,7 +174,8 @@ operation_init( Connection *c, BerElement *ber )
Debug( LDAP_DEBUG_TRACE, "operation_init: "
"set up a new operation, %s with msgid=%d for client %lu\n",
slap_msgtype2str( op->o_tag ), op->o_client_msgid, c->c_connid );
slap_msgtype2str( op->o_tag ), op->o_client_msgid,
op->o_client_connid );
return op;
@ -241,7 +243,7 @@ operation_send_reject(
Debug( LDAP_DEBUG_TRACE, "operation_send_reject: "
"rejecting %s from client %lu with message: \"%s\"\n",
slap_msgtype2str( op->o_tag ), c->c_connid, msg );
slap_msgtype2str( op->o_tag ), op->o_client_connid, msg );
ldap_pvt_thread_mutex_lock( &c->c_mutex );
found = ( tavl_delete( &c->c_ops, op, operation_client_cmp ) == op );
@ -295,6 +297,7 @@ request_process( void *ctx, void *arg )
goto fail;
}
op->o_upstream = upstream;
op->o_upstream_connid = upstream->c_connid;
output = upstream->c_pendingber;
if ( output == NULL && (output = ber_alloc()) == NULL ) {

View File

@ -330,6 +330,7 @@ struct Connection {
struct Operation {
Connection *o_client, *o_upstream;
unsigned long o_client_connid, o_upstream_connid;
ber_int_t o_client_msgid, o_upstream_msgid;
ber_tag_t o_tag;

View File

@ -42,7 +42,8 @@ forward_response( Operation *op, BerElement *ber )
Debug( LDAP_DEBUG_CONNS, "forward_response: "
"%s to client %lu request #%d\n",
slap_msgtype2str( response_tag ), c->c_connid, op->o_client_msgid );
slap_msgtype2str( response_tag ), op->o_client_connid,
op->o_client_msgid );
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
output = c->c_pendingber;
@ -72,7 +73,7 @@ forward_final_response( Operation *op, BerElement *ber )
Debug( LDAP_DEBUG_CONNS, "forward_final_response: "
"finishing up with request #%d for client %lu\n",
op->o_client_msgid, op->o_client->c_connid );
op->o_client_msgid, op->o_client_connid );
rc = forward_response( op, ber );
operation_destroy( op );
@ -104,7 +105,7 @@ handle_bind_response( Operation *op, BerElement *ber )
Debug( LDAP_DEBUG_CONNS, "handle_bind_response: "
"received response for bind request by client %lu, result=%d\n",
c->c_connid, result );
op->o_client_connid, result );
switch ( result ) {
case LDAP_SASL_BIND_IN_PROGRESS:
@ -360,7 +361,7 @@ handle_one_response( Connection *c )
if ( op ) {
Debug( LDAP_DEBUG_TRACE, "handle_one_response: "
"upstream=%lu, processing response for client %lu, msgid=%d\n",
c->c_connid, op->o_client->c_connid, op->o_client_msgid );
c->c_connid, op->o_client_connid, op->o_client_msgid );
} else {
tag = ber_peek_tag( ber, &len );
Debug( LDAP_DEBUG_TRACE, "handle_one_response: "