summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-02-02 14:29:14 -0800
committerAaron <aaron@10gen.com>2010-02-23 22:27:26 -0800
commitc62aa841a22a391c9e1c9223955970cea9ec074f (patch)
treee133ebbe3abe71e1846fc23eb2ea6064d9f7ef66 /shell
parent5ded448a9079798a514121ad1879fc30116d1ed9 (diff)
downloadmongo-c62aa841a22a391c9e1c9223955970cea9ec074f.tar.gz
SERVER-500 try hardcoded ports
Diffstat (limited to 'shell')
-rw-r--r--shell/servers.js7
-rw-r--r--shell/utils.cpp37
2 files changed, 7 insertions, 37 deletions
diff --git a/shell/servers.js b/shell/servers.js
index e4ef3e3e5e7..ab3a25380fd 100644
--- a/shell/servers.js
+++ b/shell/servers.js
@@ -601,3 +601,10 @@ ReplTest.prototype.stop = function( master , signal ){
}
stopMongod( this.getPort( master ) , signal || 15 );
}
+
+allocatePorts = function( n ) {
+ var ret = [];
+ for( var i = 35000; i < 35000 + n; ++i )
+ ret.push( i );
+ return ret;
+} \ No newline at end of file
diff --git a/shell/utils.cpp b/shell/utils.cpp
index f9c3c46c03a..0db5734cdf3 100644
--- a/shell/utils.cpp
+++ b/shell/utils.cpp
@@ -139,42 +139,6 @@ namespace mongo {
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/wait.h>
-
- BSONObj AllocatePorts( const BSONObj &args ) {
- uassert( "allocatePorts takes exactly 1 argument", args.nFields() == 1 );
- uassert( "allocatePorts needs to be passed an integer", args.firstElement().isNumber() );
-
- int n = int( args.firstElement().number() );
-
- vector< int > ports;
- vector< int > sockets;
- for( int i = 0; i < n; ++i ) {
- int s = socket( AF_INET, SOCK_STREAM, 0 );
- assert( s );
-
- sockaddr_in address;
- memset(address.sin_zero, 0, sizeof(address.sin_zero));
- address.sin_family = AF_INET;
- address.sin_port = 0;
- address.sin_addr.s_addr = inet_addr( "127.0.0.1" );
- assert( 0 == ::bind( s, (sockaddr*)&address, sizeof( address ) ) );
-
- sockaddr_in newAddress;
- socklen_t len = sizeof( newAddress );
- assert( 0 == getsockname( s, (sockaddr*)&newAddress, &len ) );
- ports.push_back( ntohs( newAddress.sin_port ) );
- sockets.push_back( s );
- }
- for( vector< int >::const_iterator i = sockets.begin(); i != sockets.end(); ++i )
- assert( 0 == close( *i ) );
-
- sort( ports.begin(), ports.end() );
- for( unsigned i = 1; i < ports.size(); ++i )
- massert( "duplicate ports allocated", ports[ i - 1 ] != ports[ i ] );
- BSONObjBuilder b;
- b.append( "", ports );
- return b.obj();
- }
map< int, pair< pid_t, int > > dbs;
map< pid_t, int > shells;
@@ -483,7 +447,6 @@ namespace mongo {
scope.injectNative( "version" , JSVersion );
scope.injectNative( "hex_md5" , jsmd5 );
#if !defined(_WIN32)
- scope.injectNative( "allocatePorts", AllocatePorts );
scope.injectNative( "_startMongoProgram", StartMongoProgram );
scope.injectNative( "runMongoProgram", RunMongoProgram );
scope.injectNative( "stopMongod", StopMongoProgram );