summaryrefslogtreecommitdiff
path: root/src/mongo/util/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/net')
-rw-r--r--src/mongo/util/net/hostandport.h16
-rw-r--r--src/mongo/util/net/listen.cpp7
-rw-r--r--src/mongo/util/net/message.h18
-rw-r--r--src/mongo/util/net/message_port.cpp1
-rw-r--r--src/mongo/util/net/message_port.h4
-rw-r--r--src/mongo/util/net/message_server_port.cpp3
-rw-r--r--src/mongo/util/net/sock.cpp8
-rw-r--r--src/mongo/util/net/sock_test.cpp4
-rw-r--r--src/mongo/util/net/ssl_options.cpp13
9 files changed, 41 insertions, 33 deletions
diff --git a/src/mongo/util/net/hostandport.h b/src/mongo/util/net/hostandport.h
index ff47d7f9ef4..aa1a395643b 100644
--- a/src/mongo/util/net/hostandport.h
+++ b/src/mongo/util/net/hostandport.h
@@ -18,7 +18,7 @@
#pragma once
#include "mongo/bson/util/builder.h"
-#include "mongo/db/cmdline.h"
+#include "mongo/db/server_options.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/sock.h"
@@ -38,7 +38,7 @@ namespace mongo {
/** @param p port number. -1 is ok to use default. */
HostAndPort(const std::string& h, int p /*= -1*/) : _host(h), _port(p) {
- verify( !str::startsWith(h, '#') );
+ verify(!mongoutils::str::startsWith(h, '#'));
}
HostAndPort(const SockAddr& sock ) : _host( sock.getAddr() ) , _port( sock.getPort() ) { }
@@ -84,7 +84,7 @@ namespace mongo {
int port() const {
if (hasPort())
return _port;
- return CmdLine::DefaultDBPort;
+ return ServerGlobalParams::DefaultDBPort;
}
bool hasPort() const {
return _port >= 0;
@@ -100,7 +100,7 @@ namespace mongo {
};
inline HostAndPort HostAndPort::me() {
- const char* ips = cmdLine.bind_ip.c_str();
+ const char* ips = serverGlobalParams.bind_ip.c_str();
while(*ips) {
string ip;
const char * comma = strchr(ips, ',');
@@ -112,7 +112,7 @@ namespace mongo {
ip = string(ips);
ips = "";
}
- HostAndPort h = HostAndPort(ip, cmdLine.port);
+ HostAndPort h = HostAndPort(ip, serverGlobalParams.port);
if (!h.isLocalHost()) {
return h;
}
@@ -121,7 +121,7 @@ namespace mongo {
string h = getHostName();
verify( !h.empty() );
verify( h != "localhost" );
- return HostAndPort(h, cmdLine.port);
+ return HostAndPort(h, serverGlobalParams.port);
}
inline string HostAndPort::toString( bool includePort ) const {
@@ -142,7 +142,7 @@ namespace mongo {
ss << ':';
#if defined(_DEBUG)
if( p >= 44000 && p < 44100 ) {
- log() << "warning: special debug port 44xxx used" << endl;
+ log() << "warning: special debug port 44xxx used" << std::endl;
ss << p+1;
}
else
@@ -158,7 +158,7 @@ namespace mongo {
inline bool HostAndPort::isLocalHost() const {
string _host = host();
return ( _host == "localhost"
- || startsWith(_host.c_str(), "127.")
+ || mongoutils::str::startsWith(_host.c_str(), "127.")
|| _host == "::1"
|| _host == "anonymous unix socket"
|| _host.c_str()[0] == '/' // unix socket
diff --git a/src/mongo/util/net/listen.cpp b/src/mongo/util/net/listen.cpp
index 3492dc76b69..845681881ad 100644
--- a/src/mongo/util/net/listen.cpp
+++ b/src/mongo/util/net/listen.cpp
@@ -115,7 +115,8 @@ namespace mongo {
checkTicketNumbers();
#if !defined(_WIN32)
- _mine = ipToAddrs(_ip.c_str(), _port, (!cmdLine.noUnixSocket && useUnixSockets()));
+ _mine = ipToAddrs(_ip.c_str(), _port, (!serverGlobalParams.noUnixSocket &&
+ useUnixSockets()));
#else
_mine = ipToAddrs(_ip.c_str(), _port, false);
#endif
@@ -289,7 +290,7 @@ namespace mongo {
long long myConnectionNumber = globalConnectionNumber.addAndFetch(1);
- if ( _logConnect && ! cmdLine.quiet ){
+ if (_logConnect && !serverGlobalParams.quiet) {
int conns = globalTicketHolder.used()+1;
const char* word = (conns == 1 ? " connection" : " connections");
log() << "connection accepted from " << from.toString() << " #" << myConnectionNumber << " (" << conns << word << " now open)" << endl;
@@ -483,7 +484,7 @@ namespace mongo {
long long myConnectionNumber = globalConnectionNumber.addAndFetch(1);
- if ( _logConnect && ! cmdLine.quiet ){
+ if (_logConnect && !serverGlobalParams.quiet) {
int conns = globalTicketHolder.used()+1;
const char* word = (conns == 1 ? " connection" : " connections");
log() << "connection accepted from " << from.toString() << " #" << myConnectionNumber << " (" << conns << word << " now open)" << endl;
diff --git a/src/mongo/util/net/message.h b/src/mongo/util/net/message.h
index 738d3a34ba5..aa30bd85cfc 100644
--- a/src/mongo/util/net/message.h
+++ b/src/mongo/util/net/message.h
@@ -17,7 +17,10 @@
#pragma once
+#include <vector>
+
#include "mongo/bson/util/atomic_int.h"
+#include "mongo/util/goodies.h"
#include "mongo/util/net/hostandport.h"
#include "mongo/util/net/sock.h"
@@ -201,12 +204,14 @@ namespace mongo {
verify( _freeIt );
int totalSize = 0;
- for( vector< pair< char *, int > >::const_iterator i = _data.begin(); i != _data.end(); ++i ) {
+ for (std::vector< std::pair< char *, int > >::const_iterator i = _data.begin();
+ i != _data.end(); ++i) {
totalSize += i->second;
}
char *buf = (char*)malloc( totalSize );
char *p = buf;
- for( vector< pair< char *, int > >::const_iterator i = _data.begin(); i != _data.end(); ++i ) {
+ for (std::vector< std::pair< char *, int > >::const_iterator i = _data.begin();
+ i != _data.end(); ++i) {
memcpy( p, i->first, i->second );
p += i->second;
}
@@ -233,7 +238,8 @@ namespace mongo {
if ( _buf ) {
free( _buf );
}
- for( vector< pair< char *, int > >::const_iterator i = _data.begin(); i != _data.end(); ++i ) {
+ for (std::vector< std::pair< char *, int > >::const_iterator i = _data.begin();
+ i != _data.end(); ++i) {
free(i->first);
}
}
@@ -256,10 +262,10 @@ namespace mongo {
}
verify( _freeIt );
if ( _buf ) {
- _data.push_back( make_pair( (char*)_buf, _buf->len ) );
+ _data.push_back(std::make_pair((char*)_buf, _buf->len));
_buf = 0;
}
- _data.push_back( make_pair( d, size ) );
+ _data.push_back(std::make_pair(d, size));
header()->len += size;
}
@@ -297,7 +303,7 @@ namespace mongo {
// if just one buffer, keep it in _buf, otherwise keep a sequence of buffers in _data
MsgData * _buf;
// byte buffer(s) - the first must contain at least a full MsgData unless using _buf for storage instead
- typedef vector< pair< char*, int > > MsgVec;
+ typedef std::vector< std::pair< char*, int > > MsgVec;
MsgVec _data;
bool _freeIt;
};
diff --git a/src/mongo/util/net/message_port.cpp b/src/mongo/util/net/message_port.cpp
index 1138865c294..772eeff77e9 100644
--- a/src/mongo/util/net/message_port.cpp
+++ b/src/mongo/util/net/message_port.cpp
@@ -22,7 +22,6 @@
#include <fcntl.h>
#include <time.h>
-#include "mongo/db/cmdline.h"
#include "mongo/util/background.h"
#include "mongo/util/goodies.h"
#include "mongo/util/net/listen.h"
diff --git a/src/mongo/util/net/message_port.h b/src/mongo/util/net/message_port.h
index cf11bea8773..8949f8081fb 100644
--- a/src/mongo/util/net/message_port.h
+++ b/src/mongo/util/net/message_port.h
@@ -17,6 +17,8 @@
#pragma once
+#include <vector>
+
#include "mongo/util/net/message.h"
#include "mongo/util/net/sock.h"
@@ -112,7 +114,7 @@ namespace mongo {
void send( const char * data , int len, const char *context ) {
psock->send( data, len, context );
}
- void send( const vector< pair< char *, int > > &data, const char *context ) {
+ void send(const std::vector< std::pair< char *, int > > &data, const char *context) {
psock->send( data, context );
}
bool connect(SockAddr& farEnd) {
diff --git a/src/mongo/util/net/message_server_port.cpp b/src/mongo/util/net/message_server_port.cpp
index cdcaef2c6fa..f1fec225e49 100644
--- a/src/mongo/util/net/message_server_port.cpp
+++ b/src/mongo/util/net/message_server_port.cpp
@@ -22,7 +22,6 @@
#ifndef USE_ASIO
-#include "mongo/db/cmdline.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/stats/counters.h"
#include "mongo/util/concurrency/ticketholder.h"
@@ -198,7 +197,7 @@ namespace mongo {
p->psock->clearCounters();
if ( ! p->recv(m) ) {
- if( !cmdLine.quiet ){
+ if (!serverGlobalParams.quiet) {
int conns = Listener::globalTicketHolder.used()-1;
const char* word = (conns == 1 ? " connection" : " connections");
log() << "end connection " << otherSide << " (" << conns << word << " now open)" << endl;
diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp
index 5afd18c4c70..327296257d2 100644
--- a/src/mongo/util/net/sock.cpp
+++ b/src/mongo/util/net/sock.cpp
@@ -40,7 +40,6 @@
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/message.h"
#include "mongo/util/net/ssl_manager.h"
-#include "mongo/db/cmdline.h"
namespace mongo {
MONGO_FP_DECLARE(throwSockExcep);
@@ -316,7 +315,8 @@ namespace mongo {
SockAddr unknownAddress( "0.0.0.0", 0 );
string makeUnixSockPath(int port) {
- return mongoutils::str::stream() << cmdLine.socket << "/mongodb-" << port << ".sock";
+ return mongoutils::str::stream() << serverGlobalParams.socket << "/mongodb-" << port
+ << ".sock";
}
@@ -357,8 +357,8 @@ namespace mongo {
string prettyHostName() {
StringBuilder s;
s << getHostNameCached();
- if( cmdLine.port != CmdLine::DefaultDBPort )
- s << ':' << mongo::cmdLine.port;
+ if (serverGlobalParams.port != ServerGlobalParams::DefaultDBPort)
+ s << ':' << mongo::serverGlobalParams.port;
return s.str();
}
diff --git a/src/mongo/util/net/sock_test.cpp b/src/mongo/util/net/sock_test.cpp
index 1bba7228e82..349e4b0903a 100644
--- a/src/mongo/util/net/sock_test.cpp
+++ b/src/mongo/util/net/sock_test.cpp
@@ -38,14 +38,14 @@
#include <sys/types.h>
#endif
-#include "mongo/db/cmdline.h"
+#include "mongo/db/server_options.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/concurrency/synchronization.h"
#include "mongo/util/fail_point_service.h"
namespace mongo {
- CmdLine cmdLine;
+ ServerGlobalParams serverGlobalParams;
bool inShutdown() {
return false;
diff --git a/src/mongo/util/net/ssl_options.cpp b/src/mongo/util/net/ssl_options.cpp
index ee1900dbb75..3251b7fd3d5 100644
--- a/src/mongo/util/net/ssl_options.cpp
+++ b/src/mongo/util/net/ssl_options.cpp
@@ -18,7 +18,7 @@
#include <boost/filesystem/operations.hpp>
#include "mongo/base/status.h"
-#include "mongo/db/cmdline.h"
+#include "mongo/db/server_options.h"
#include "mongo/util/options_parser/environment.h"
#include "mongo/util/options_parser/option_description.h"
#include "mongo/util/options_parser/option_section.h"
@@ -176,16 +176,17 @@ namespace mongo {
sslGlobalParams.sslFIPSMode) {
return Status(ErrorCodes::BadValue, "need to enable sslOnNormalPorts");
}
- if (cmdLine.clusterAuthMode == "sendKeyfile" ||
- cmdLine.clusterAuthMode == "sendX509" ||
- cmdLine.clusterAuthMode == "x509") {
+ if (serverGlobalParams.clusterAuthMode == "sendKeyfile" ||
+ serverGlobalParams.clusterAuthMode == "sendX509" ||
+ serverGlobalParams.clusterAuthMode == "x509") {
if (!sslGlobalParams.sslOnNormalPorts){
return Status(ErrorCodes::BadValue, "need to enable sslOnNormalPorts");
}
}
- else if (params.count("clusterAuthMode") && cmdLine.clusterAuthMode != "keyfile") {
+ else if (params.count("clusterAuthMode") &&
+ serverGlobalParams.clusterAuthMode != "keyfile") {
StringBuilder sb;
- sb << "unsupported value for clusterAuthMode " << cmdLine.clusterAuthMode;
+ sb << "unsupported value for clusterAuthMode " << serverGlobalParams.clusterAuthMode;
return Status(ErrorCodes::BadValue, sb.str());
}