mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-07-14 02:36:06 -04:00
Introduce Process::isShuttingDown and use it instead of checking Process::EXIT_MODE
This commit is contained in:
@ -74,7 +74,7 @@ void Msg20::reset() {
|
||||
// not allowed to reset one in progress
|
||||
if ( m_inProgress ) {
|
||||
// do not core on abrupt exits!
|
||||
if (g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
log("msg20: msg20 not being freed because exiting.");
|
||||
return;
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ bool Msg25::doReadLoop() {
|
||||
ms,m_site,m_url,m_docId,KEYSTR(&startKey,LDBKS));
|
||||
}
|
||||
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
log(LOG_DEBUG, "linkdb: shutting down. exiting link text loop.");
|
||||
g_errno = ESHUTTINGDOWN;
|
||||
return false;
|
||||
|
2
Msg3.cpp
2
Msg3.cpp
@ -730,7 +730,7 @@ bool Msg3::doneScanning ( ) {
|
||||
|
||||
// if shutting down gb then limit to 20 so we can shutdown because
|
||||
// it can't shutdown until all threads are out of the queue i think
|
||||
if ( g_process.m_mode == Process::EXIT_MODE && max < 0 ) {
|
||||
if (g_process.isShuttingDown() && max < 0) {
|
||||
//log("msg3: forcing retries to 0 because shutting down");
|
||||
max = 0;
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ static float getDiskUsage ( int64_t *diskAvail ) {
|
||||
|
||||
void diskUsageWrapper(int /*fd*/, void * /*state*/) {
|
||||
// skip if exiting
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ int64_t Process::getTotalDocsIndexed() {
|
||||
|
||||
void processSleepWrapper(int /*fd*/, void * /*state*/) {
|
||||
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
g_process.shutdown2();
|
||||
return;
|
||||
}
|
||||
@ -547,7 +547,7 @@ bool Process::shutdown ( bool urgent, void *state, void (*callback) (void *stat
|
||||
// bail if doing something already
|
||||
if ( m_mode != Process::NO_MODE ) {
|
||||
// if already in exit mode, just return
|
||||
if ( m_mode == Process::EXIT_MODE ) {
|
||||
if (isShuttingDown()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ class Process {
|
||||
bool shutdown2 ( ) ;
|
||||
void disableTreeWrites ( bool shuttingDown ) ;
|
||||
void enableTreeWrites();
|
||||
|
||||
bool isShuttingDown() const { return m_mode == EXIT_MODE; }
|
||||
bool isRdbDumping ( ) ;
|
||||
bool isRdbMerging ( ) ;
|
||||
bool saveRdbTrees(bool shuttingDown);
|
||||
|
@ -1641,7 +1641,7 @@ bool RdbBase::attemptMerge(int32_t niceness, bool forceMergeAll, int32_t minToMe
|
||||
}
|
||||
|
||||
// shutting down? do not start another merge then
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
logTrace( g_conf.m_logTraceRdbBase, "END, shutting down" );
|
||||
return false;
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ void RdbMerge::doneMerging() {
|
||||
|
||||
// if we are exiting then dont bother renaming the files around now.
|
||||
// this prevents a core in RdbBase::incorporateMerge()
|
||||
if (g_process.m_mode == Process::EXIT_MODE) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
log(LOG_INFO, "merge: exiting. not ending merge.");
|
||||
return;
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ bool Rebalance::scanRdb ( ) {
|
||||
m_registered = false;
|
||||
}
|
||||
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) return false;
|
||||
if (g_process.isShuttingDown()) return false;
|
||||
|
||||
// . if this rdb is merging wait until merge is done
|
||||
// . we will be dumping out a lot of negative recs and if we are
|
||||
@ -376,7 +376,7 @@ bool Rebalance::scanRdb ( ) {
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) return false;
|
||||
if (g_process.isShuttingDown()) return false;
|
||||
|
||||
//log("rebal: loading list start = %s",KEYSTR(m_nextKey,rdb->m_ks));
|
||||
|
||||
|
@ -756,8 +756,7 @@ bool Repair::loop() {
|
||||
|
||||
loop1:
|
||||
|
||||
if ( g_process.m_mode == Process::EXIT_MODE )
|
||||
{
|
||||
if (g_process.isShuttingDown()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1505,7 +1505,7 @@ void SpiderColl::populateDoledbFromWaitingTree ( ) { // bool reentry ) {
|
||||
|
||||
// are we trying to exit? some firstip lists can be quite long, so
|
||||
// terminate here so all threads can return and we can exit properly
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
m_isPopulatingDoledb = false;
|
||||
logTrace( g_conf.m_logTraceSpider, "END, shutting down" );
|
||||
return;
|
||||
@ -1701,7 +1701,7 @@ void SpiderColl::gotSpiderdbListWrapper(void *state, RdbList *list, Msg5 *msg5)
|
||||
|
||||
// are we trying to exit? some firstip lists can be quite long, so
|
||||
// terminate here so all threads can return and we can exit properly
|
||||
if (g_process.m_mode == Process::EXIT_MODE) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1744,7 +1744,7 @@ bool SpiderColl::evalIpLoop ( ) {
|
||||
|
||||
// are we trying to exit? some firstip lists can be quite long, so
|
||||
// terminate here so all threads can return and we can exit properly
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
logTrace( g_conf.m_logTraceSpider, "END, shutting down" );
|
||||
return true;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void SpiderLoop::doneSleepingWrapperSL ( int fd , void *state ) {
|
||||
if ( ! g_hostdb.getMyHost( )->m_spiderEnabled ) return;
|
||||
|
||||
// or if trying to exit
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) return;
|
||||
if (g_process.isShuttingDown()) return;
|
||||
// skip if udp table is full
|
||||
if ( g_udpServer.getNumUsedSlotsIncoming() >= MAXUDPSLOTS ) return;
|
||||
|
||||
@ -317,7 +317,7 @@ subloop:
|
||||
}
|
||||
|
||||
// or if trying to exit
|
||||
if ( g_process.m_mode == Process::EXIT_MODE ) {
|
||||
if (g_process.isShuttingDown()) {
|
||||
logTrace( g_conf.m_logTraceSpider, "END, shutting down" );
|
||||
return;
|
||||
}
|
||||
@ -1069,7 +1069,7 @@ bool SpiderLoop::spiderUrl(SpiderRequest *sreq, key96_t *doledbKey, collnum_t co
|
||||
// turned off?
|
||||
if ( ( (! g_conf.m_spideringEnabled ||
|
||||
// or if trying to exit
|
||||
g_process.m_mode == Process::EXIT_MODE
|
||||
g_process.isShuttingDown()
|
||||
) && ! sreq->m_isInjecting ) ||
|
||||
// repairing the collection's rdbs?
|
||||
g_repairMode ) {
|
||||
|
Reference in New Issue
Block a user