Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVER-7485 Allow ranges in the delay argument in mongobridge #317

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/mongo/tools/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ using namespace std;

int port = 0;
int delay = 0;
int delayBegin = 0;
int delayEnd = 0;
string destUri;
void cleanup( int sig );

Expand All @@ -52,7 +54,13 @@ class Forwarder {
mp_.shutdown();
break;
}
sleepmillis( delay );

if ( delayBegin && delayEnd ) {
sleepmillis( delayBegin + ( rand() % ( delayEnd - delayBegin ) ) );
}
else if ( delay ) {
sleepmillis( delay );
}

int oldId = m.header()->id;
if ( m.operation() == dbQuery || m.operation() == dbMsg || m.operation() == dbGetMore ) {
Expand Down Expand Up @@ -168,7 +176,14 @@ int main( int argc, char **argv, char** envp ) {
destUri = argv[ ++i ];
}
else if ( strcmp( argv[ i ], "--delay" ) == 0 ) {
delay = strtol( argv[ ++i ], 0, 10 );
i++;
if ( strchr( argv[ i ], '-' ) != NULL ) {
delayBegin = strtol( argv[ i ], 0, 10 );
delayEnd = strtol( strchr( argv[ i ], '-' ) + 1, 0, 10 );
}
else {
delay = strtol( argv[ i ], 0, 10 );
}
}
else {
check( false );
Expand Down