]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
There might be errors before we save the operation in c_ops
authorOndřej Kuzník <ondra@mistotebe.net>
Fri, 14 Apr 2017 08:39:24 +0000 (09:39 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
servers/lloadd/bind.c
servers/lloadd/client.c
servers/lloadd/operation.c
servers/lloadd/proto-slap.h

index bcdb3e11192811e99fbb212c0378a509f3373407..76cd45e3650e239d66ecc4a3cd32df30dab0e782 100644 (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;
     }
 
index 1a3565916b06e3f7a40ecafc3dbdc1e81239eaf6..bb81b90bd3aef1e8c454ae06b56507a3a6d1654f 100644 (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 );
     }
index e8cc3a0a9c932830367bf45a5322f4052b4e268f..66021dc4b36a93c183b947c89fb2c61471672723 100644 (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;
 }
index 16af23fc832ee6cb5f125c57f1346610936dd378..a945b797b8a7ae596c7e77d0593f096be45cc25d 100644 (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 );