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

Winsock startup at static init

This commit is contained in:
Mathias Stearn 2010-04-08 14:20:52 -04:00
parent 93b3a2e008
commit 6378b9da4c
3 changed files with 16 additions and 11 deletions

View File

@ -105,8 +105,6 @@ namespace mongo {
delete response;
}
};
static SockAddr unknownAddress( "0.0.0.0", 0 );
bool assembleResponse( Message &m, DbResponse &dbresponse, const SockAddr &client = unknownAddress );

View File

@ -167,18 +167,23 @@ namespace mongo {
}
void xmain();
struct SockStartupTests {
SockStartupTests() {
#if defined(_WIN32)
WSADATA d;
if ( WSAStartup(MAKEWORD(2,2), &d) != 0 ) {
out() << "ERROR: wsastartup failed " << OUTPUT_ERRNO << endl;
problem() << "ERROR: wsastartup failed " << OUTPUT_ERRNO << endl;
dbexit( EXIT_NTSERVICE_ERROR );
namespace {
struct WinsockInit {
WinsockInit() {
WSADATA d;
if ( WSAStartup(MAKEWORD(2,2), &d) != 0 ) {
out() << "ERROR: wsastartup failed " << OUTPUT_ERRNO << endl;
problem() << "ERROR: wsastartup failed " << OUTPUT_ERRNO << endl;
dbexit( EXIT_NTSERVICE_ERROR );
}
}
} winsock_init;
}
#endif
}
} sstests;
SockAddr unknownAddress( "0.0.0.0", 0 );
ListeningSockets* ListeningSockets::_instance = new ListeningSockets();

View File

@ -221,6 +221,8 @@ namespace mongo {
struct sockaddr_storage sa;
};
extern SockAddr unknownAddress; // ( "0.0.0.0", 0 )
const int MaxMTU = 16384;
inline string getHostName() {