There might be errors before we save the operation in c_ops

This commit is contained in:
Ondřej Kuzník 2017-04-14 09:39:24 +01:00 committed by Ondřej Kuzník
parent b6b3f35aac
commit 2e2c86664a
4 changed files with 17 additions and 8 deletions

View File

@ -55,7 +55,7 @@ request_bind( Operation *op )
} else if ( version != LDAP_VERSION3 ) {
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
operation_send_reject(
op, LDAP_PROTOCOL_ERROR, "LDAP version unsupported" );
op, LDAP_PROTOCOL_ERROR, "LDAP version unsupported", 1 );
ber_free( copy, 0 );
return 0;
}
@ -286,7 +286,7 @@ client_bind( void *ctx, void *arg )
Debug( LDAP_DEBUG_STATS, "client_bind: "
"no available connection found\n" );
operation_send_reject(
op, LDAP_UNAVAILABLE, "no connections available" );
op, LDAP_UNAVAILABLE, "no connections available", 1 );
return NULL;
}

View File

@ -105,7 +105,8 @@ client_read_cb( evutil_socket_t s, short what, void *arg )
fail:
if ( op ) {
tavl_delete( &c->c_ops, op, operation_client_cmp );
operation_send_reject(
op, LDAP_OTHER, "server error or overloaded", 1 );
op->o_client = NULL;
operation_destroy( op );
}

View File

@ -229,17 +229,25 @@ done:
}
void
operation_send_reject( Operation *op, int result, const char *msg )
operation_send_reject(
Operation *op,
int result,
const char *msg,
int send_anyway )
{
Connection *c = op->o_client;
BerElement *ber;
int found;
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 );
ldap_pvt_thread_mutex_lock( &c->c_mutex );
found = ( tavl_delete( &c->c_ops, op, operation_client_cmp ) == op );
ldap_pvt_thread_mutex_unlock( &c->c_mutex );
if ( !found ) {
if ( !found && !send_anyway ) {
return;
}
@ -268,7 +276,7 @@ void
operation_lost_upstream( Operation *op )
{
operation_send_reject( op, LDAP_UNAVAILABLE,
"connection to the remote server has been severed" );
"connection to the remote server has been severed", 0 );
}
void *
@ -343,6 +351,6 @@ fail:
if ( upstream ) {
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
}
operation_send_reject( op, LDAP_OTHER, "internal error" );
operation_send_reject( op, LDAP_OTHER, "internal error", 0 );
return NULL;
}

View File

@ -151,7 +151,7 @@ LDAP_SLAPD_F (int) operation_upstream_cmp( const void *l, const void *r );
LDAP_SLAPD_F (int) operation_client_cmp( const void *l, const void *r );
LDAP_SLAPD_F (Operation *) operation_init( Connection *c, BerElement *ber );
LDAP_SLAPD_F (void) operation_abandon( Operation *op );
LDAP_SLAPD_F (void) operation_send_reject( Operation *op, int result, const char *msg );
LDAP_SLAPD_F (void) operation_send_reject( Operation *op, int result, const char *msg, int send_anyway );
LDAP_SLAPD_F (void) operation_lost_upstream( Operation *op );
LDAP_SLAPD_F (void) operation_destroy( Operation *op );
LDAP_SLAPD_F (void *) request_process( void *ctx, void *arg );