]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9338 Add backlog control for testing slapd write waits
authorHoward Chu <hyc@openldap.org>
Fri, 4 Sep 2020 16:49:38 +0000 (17:49 +0100)
committerHoward Chu <hyc@openldap.org>
Fri, 4 Sep 2020 19:23:44 +0000 (20:23 +0100)
clients/tools/common.c
clients/tools/common.h
clients/tools/ldapsearch.c

index 9501399f6112c3feeb15e4c30840fc89d96c0ddf..e1edd0e34d0d15e399cc4f281ed3a6defe4f5602 100644 (file)
@@ -210,6 +210,8 @@ static struct tool_ctrls_t {
 enum { Intr_None = 0, Intr_Abandon, Intr_Cancel, Intr_Ignore }; 
 static volatile sig_atomic_t   gotintr, abcan;
 
+int backlog;
+
 
 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
 static int
@@ -704,6 +706,13 @@ tool_args( int argc, char **argv )
                                        gotintr = abcan;
                                }
 
+                       } else if ( strcasecmp( control, "backlog" ) == 0 ) {
+                               /* special search: accumulate lots of responses
+                                * but don't read any, force slapd writer to wait.
+                                * Then abandon the search and issue a new one.
+                                */
+                               backlog = 1;
+
                        } else if ( tool_is_oid( control ) ) {
                                LDAPControl     *tmpctrls, ctrl;
 
index a7c18d1be373e0dfd37f8ed74105daa9016cc90a..aff5d1f04290f095375a156259ce7700916f847e 100644 (file)
@@ -99,6 +99,9 @@ extern ber_int_t      vlvPos;
 extern ber_int_t       vlvCount;
 extern struct berval   *vlvContext;
 
+/* features */
+extern int             backlog;
+
 /* options */
 extern struct timeval  nettimeout;
 
index b8a1f661db1230b5782d1c7176089a998d4caa63..55bf26432d042b9ec57617f2f9c5ef86ea21f641 100644 (file)
@@ -1742,6 +1742,7 @@ static int dosearch(
                tv_timelimitp = &tv_timelimit;
        }
 
+again:
        rc = ldap_search_ext( ld, base, scope, filter, attrs, attrsonly,
                sctrls, cctrls, tv_timelimitp, sizelimit, &msgid );
 
@@ -1765,6 +1766,21 @@ static int dosearch(
                tvp = &tv;
        }
 
+       if ( backlog == 1 ) {
+               printf( _("\nWaiting for responses to accumulate, press Enter to continue: "));
+               fflush( stdout );
+               getchar();
+               printf( _("Abandoning msgid %d\n"), msgid );
+               ldap_abandon_ext( ld, msgid, NULL, NULL );
+               /* turn off syncrepl control */
+               ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, NULL );
+               backlog = 2;
+               scope = LDAP_SCOPE_BASE;
+               goto again;
+       } else if ( backlog == 2 ) {
+               tv.tv_sec = timelimit;
+       }
+
        while ((rc = ldap_result( ld, LDAP_RES_ANY,
                sortattr ? LDAP_MSG_ALL : LDAP_MSG_ONE,
                tvp, &res )) > 0 )