void TCPSrc::stop() { closeAllSockets(&m_ssbSockets); closeAllSockets(&m_s16leSockets); if(m_tcpServer->isListening()) m_tcpServer->close(); delete m_tcpServer; }
void shutdown() { #ifndef _WIN32 { // close listener sockets // We would only hang here if a synchronous signal is received // during a registerListenerSocket() call, which we don't expect. boostlock lk( listenerSocketMutex ); for( vector< int >::iterator i = listenerSockets.begin(); i != listenerSockets.end(); ++i ) close( *i ); } #endif log() << "\t shutdown: going to flush oplog..." << endl; stringstream ss2; flushOpLog( ss2 ); rawOut( ss2.str() ); /* must do this before unmapping mem or you may get a seg fault */ log() << "\t shutdown: going to close sockets..." << endl; closeAllSockets(); // wait until file preallocation finishes // we would only hang here if the file_allocator code generates a // synchronous signal, which we don't expect log() << "\t shutdown: waiting for fs..." << endl; theFileAllocator().waitUntilFinished(); log() << "\t shutdown: closing all files..." << endl; stringstream ss3; MemoryMappedFile::closeAllFiles( ss3 ); rawOut( ss3.str() ); // should we be locked here? we aren't. might be ok as-is. recCacheCloseAll(); #if !defined(_WIN32) && !defined(__sunos__) if ( lockFile ){ log() << "\t shutdown: removing fs lock..." << endl; if( ftruncate( lockFile , 0 ) ) log() << "\t couldn't remove fs lock errno=" << errno << endl; flock( lockFile, LOCK_UN ); } #endif }