]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Do not read on the last iteration.
authorOndřej Kuzník <ondra@mistotebe.net>
Fri, 30 Jun 2017 09:10:29 +0000 (10:10 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
When the pdu processing limit is hit, we still attempt to read another
PDU. If we succeed, the ber_get_next call in the read callback will
abort since a full PDU is already present.

servers/lloadd/client.c
servers/lloadd/upstream.c

index 6b5fa612603ad25d476054dd0d3a7da6d69dd2aa..b742081a4d337efc482566767851b2067c863c8e 100644 (file)
@@ -130,8 +130,7 @@ handle_requests( void *ctx, void *arg )
     int requests_handled = 0;
 
     CONNECTION_LOCK_DECREF(c);
-    for ( ; requests_handled < slap_conn_max_pdus_per_cycle;
-            requests_handled++ ) {
+    for ( ;; ) {
         BerElement *ber;
         ber_tag_t tag;
         ber_len_t len;
@@ -145,6 +144,11 @@ handle_requests( void *ctx, void *arg )
         }
         /* Otherwise, handle_one_request leaves the connection locked */
 
+        if ( ++requests_handled >= slap_conn_max_pdus_per_cycle ) {
+            /* Do not read now, re-enable read event instead */
+            break;
+        }
+
         if ( (ber = ber_alloc()) == NULL ) {
             Debug( LDAP_DEBUG_ANY, "client_read_cb: "
                     "ber_alloc failed\n" );
index 84e8d1be8ffd5f9d03741e4ddf23a3e93edd1a1c..9272820441845cd1256a677ea5a287b5a7be6ed5 100644 (file)
@@ -465,8 +465,7 @@ handle_responses( void *ctx, void *arg )
     int responses_handled = 0;
 
     CONNECTION_LOCK_DECREF(c);
-    for ( ; responses_handled < slap_conn_max_pdus_per_cycle;
-            responses_handled++ ) {
+    for ( ;; ) {
         BerElement *ber;
         ber_tag_t tag;
         ber_len_t len;
@@ -480,6 +479,11 @@ handle_responses( void *ctx, void *arg )
         }
         /* Otherwise, handle_one_response leaves the connection locked */
 
+        if ( ++responses_handled >= slap_conn_max_pdus_per_cycle ) {
+            /* Do not read now, re-enable read event instead */
+            break;
+        }
+
         if ( (ber = ber_alloc()) == NULL ) {
             Debug( LDAP_DEBUG_ANY, "handle_responses: "
                     "ber_alloc failed\n" );