mirror of https://github.com/mongodb/mongo
mongobridge close client ports on kill
This commit is contained in:
parent
3b2ae5b7fb
commit
c5ffd65fb2
|
|
@ -58,33 +58,26 @@ private:
|
|||
MessagingPort &mp_;
|
||||
};
|
||||
|
||||
set<MessagingPort*> ports;
|
||||
|
||||
class MyListener : public Listener {
|
||||
public:
|
||||
MyListener( int port ) : Listener( "", port ) {}
|
||||
virtual void accepted(MessagingPort *mp) {
|
||||
ports.insert( mp );
|
||||
Forwarder f( *mp );
|
||||
boost::thread t( f );
|
||||
}
|
||||
};
|
||||
|
||||
void helpExit() {
|
||||
cout << "usage mongobridge --port <port> --dest <destUri>" << endl;
|
||||
cout << " port: port to listen for mongo messages" << endl;
|
||||
cout << " destUri: uri of remote mongod instance" << endl;
|
||||
::exit( -1 );
|
||||
}
|
||||
|
||||
void check( bool b ) {
|
||||
if ( !b )
|
||||
helpExit();
|
||||
}
|
||||
|
||||
auto_ptr< MyListener > listener;
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <execinfo.h>
|
||||
void cleanup( int sig ) {
|
||||
close( listener->socket() );
|
||||
for ( set<MessagingPort*>::iterator i = ports.begin(); i != ports.end(); i++ )
|
||||
(*i)->shutdown();
|
||||
::exit( 0 );
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +94,18 @@ void setupSignals() {
|
|||
inline void setupSignals() {}
|
||||
#endif
|
||||
|
||||
void helpExit() {
|
||||
cout << "usage mongobridge --port <port> --dest <destUri>" << endl;
|
||||
cout << " port: port to listen for mongo messages" << endl;
|
||||
cout << " destUri: uri of remote mongod instance" << endl;
|
||||
::exit( -1 );
|
||||
}
|
||||
|
||||
void check( bool b ) {
|
||||
if ( !b )
|
||||
helpExit();
|
||||
}
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
setupSignals();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue