Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/mongo/tools/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using namespace mongo;
using namespace std;

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

Expand All @@ -50,6 +51,7 @@ class Forwarder {
mp_.shutdown();
break;
}
sleepmillis( delay );

int oldId = m.header()->id;
if ( m.operation() == dbQuery || m.operation() == dbMsg || m.operation() == dbGetMore ) {
Expand Down Expand Up @@ -135,9 +137,10 @@ inline void setupSignals() {}
#endif

void helpExit() {
cout << "usage mongobridge --port <port> --dest <destUri>" << endl;
cout << "usage mongobridge --port <port> --dest <destUri> [ --delay <ms> ]" << endl;
cout << " port: port to listen for mongo messages" << endl;
cout << " destUri: uri of remote mongod instance" << endl;
cout << " ms: transfer delay in milliseconds (default = 0)" << endl;
::_exit( -1 );
}

Expand All @@ -151,16 +154,19 @@ int main( int argc, char **argv ) {

setupSignals();

check( argc == 5 );
check( argc == 5 || argc == 7 );

for( int i = 1; i < 5; ++i ) {
for( int i = 1; i < argc; ++i ) {
check( i % 2 != 0 );
if ( strcmp( argv[ i ], "--port" ) == 0 ) {
port = strtol( argv[ ++i ], 0, 10 );
}
else if ( strcmp( argv[ i ], "--dest" ) == 0 ) {
destUri = argv[ ++i ];
}
else if ( strcmp( argv[ i ], "--delay" ) == 0 ) {
delay = strtol( argv[ ++i ], 0, 10 );
}
else {
check( false );
}
Expand Down