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

Exit if can't bind to port SERVER-1141

This commit is contained in:
Mathias Stearn 2010-06-03 19:28:49 -04:00
parent 7adf138b31
commit 6a3199b14f
2 changed files with 5 additions and 4 deletions

1
pch.h
View File

@ -107,6 +107,7 @@ namespace mongo {
EXIT_OOM_REALLOC = 43 ,
EXIT_FS = 45 ,
EXIT_CLOCK_SKEW = 47 ,
EXIT_NET_ERROR = 48 ,
EXIT_POSSIBLE_CORRUPTION = 60 , // this means we detected a possible corruption situation, like a buf overflow
EXIT_UNCAUGHT = 100 , // top level exception that wasn't caught
EXIT_TEST = 101 ,

View File

@ -122,13 +122,13 @@ namespace mongo {
if ( x == EADDRINUSE )
log() << " addr already in use" << endl;
closesocket(sock);
return;
exitCleanly( EXIT_NET_ERROR );
}
if ( ::listen(sock, 128) != 0 ) {
log() << "listen(): listen() failed " << errnoWithDescription() << endl;
closesocket(sock);
return;
exitCleanly( EXIT_NET_ERROR );
}
ListeningSockets::get()->add( sock );
@ -162,7 +162,7 @@ namespace mongo {
#endif
if ( ! inShutdown() )
log() << "select() failure: ret=" << ret << " " << errnoWithDescription(x) << endl;
return;
exitCleanly( EXIT_NET_ERROR );
}
for (vector<int>::iterator it=socks.begin(), end=socks.end(); it != end; ++it){
@ -175,7 +175,7 @@ namespace mongo {
int x = errno; // so no global issues
if ( x == ECONNABORTED || x == EBADF ) {
log() << "Listener on port " << _port << " aborted" << endl;
return;
exitCleanly( EXIT_NET_ERROR );
} if ( x == 0 && inShutdown() ){
return; // socket closed
}