0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Fix unix socket parsing and add test SERVER-1867

This commit is contained in:
Mathias Stearn 2010-09-28 21:55:53 -07:00
parent b6716766b5
commit 4e1692b74f
2 changed files with 16 additions and 1 deletions

View File

@ -75,7 +75,7 @@ namespace mongo {
ConnectionString ConnectionString::parse( const string& host , string& errmsg ){
string::size_type i = host.find( '/' );
if ( i != string::npos ){
if ( i != string::npos && i != 0){
// replica set
return ConnectionString( SET , host.substr( i + 1 ) , host.substr( 0 , i ) );
}

15
jstests/unix_socket1.js Normal file
View File

@ -0,0 +1,15 @@
if ( ! _isWindows() ) {
hoststring = db.getMongo().host
index = hoststring.lastIndexOf(':')
if (index == -1){
port = '27017'
} else {
port = hoststring.substr(index + 1)
}
sock = new Mongo('/tmp/mongodb-' + port + '.sock')
sockdb = sock.getDB(db.getName())
assert( sockdb.runCommand('ping').ok )
} else {
print("Not testing unix sockets on Windows");
}