]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9651 ldapmodify: add -i option for interval between ops
authorHoward Chu <hyc@openldap.org>
Thu, 26 Aug 2021 14:40:33 +0000 (15:40 +0100)
committerHoward Chu <hyc@openldap.org>
Thu, 26 Aug 2021 14:40:33 +0000 (15:40 +0100)
clients/tools/ldapmodify.c
doc/man/man1/ldapmodify.1

index 23c15a94d0e790f70152d12f8123451cf5c9ad19..402f4e57d041fbff2c846e47fa94783c2f252a5e 100644 (file)
@@ -94,6 +94,8 @@ static int process_response(
        int res,
        const struct berval *dn );
 
+static long interval;
+static struct timeval interval_tv;
 static int txn = 0;
 static int txnabort = 0;
 struct berval *txn_id = NULL;
@@ -113,6 +115,7 @@ usage( void )
        fprintf( stderr, _("  -E [!]ext=extparam        modify extensions"
                " (! indicate s criticality)\n"));
        fprintf( stderr, _("  -f file    read operations from `file'\n"));
+       fprintf( stderr, _("  -i time    wait `time' microseconds between operations\n"));
        fprintf( stderr, _("  -M         enable Manage DSA IT control (-MM to make critical)\n"));
        fprintf( stderr, _("  -P version protocol version (default: 3)\n"));
        fprintf( stderr,
@@ -125,7 +128,7 @@ usage( void )
 
 
 const char options[] = "aE:rS:"
-       "cd:D:e:f:h:H:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
+       "cd:D:e:f:h:H:i:IMnNO:o:p:P:QR:U:vVw:WxX:y:Y:Z";
 
 int
 handle_private_option( int i )
@@ -187,6 +190,19 @@ handle_private_option( int i )
                ldapadd = 1;
                break;
 
+       case 'i':       /* interval */
+               {
+                       char *next;
+                       interval = strtol( optarg, &next, 10 );
+                       if ( !next || *next ) {
+                               fprintf( stderr, "%s: unable to parse interval \"%s\"\n", prog, optarg);
+                exit(EXIT_FAILURE);
+                       }
+                       interval_tv.tv_usec = interval % 1000000;
+                       interval_tv.tv_sec = interval / 1000000;
+               }
+               break;
+
        case 'r':       /* replace (obsolete) */
                break;
 
@@ -296,6 +312,10 @@ main( int argc, char **argv )
                        memcpy( rejbuf, rbuf, len+1 );
                }
 
+               if ( interval ) {
+                       select( 0, NULL, NULL, NULL, &interval_tv );
+               }
+
                rc = process_ldif_rec( rbuf, lineno );
                lineno = nextline+1;
 
index 353b075b4107b005ea3e9ad49ccd1a9885535174..2bab29356654d33aea0baac6cede282f046fa1c0 100644 (file)
@@ -21,6 +21,8 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
 [\c
 .BI \-f \ file\fR]
 [\c
+.BI \-i \ time\fR]
+[\c
 .BI \-S \ file\fR]
 [\c
 .BR \-M [ M ]]
@@ -77,6 +79,8 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
 [\c
 .BI \-f \ file\fR]
 [\c
+.BI \-i \ time\fR]
+[\c
 .BI \-S \ file\fR]
 [\c
 .BR \-M [ M ]]
@@ -171,6 +175,9 @@ reporting an error.
 Read the entry modification information from \fIfile\fP instead of from
 standard input.
 .TP
+.BI \-i \ time
+Wait \fItime\fP microseconds before issuing an operation.
+.TP
 .BI \-S \ file
 Add or change records which were skipped due to an error are written to \fIfile\fP 
 and the error message returned by the server is added as a comment. Most useful in