mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-07-14 02:36:06 -04:00
Call attemptMergeAllCallback immediately after startup instead of after sleep of 5 minutes
This commit is contained in:
13
Loop.cpp
13
Loop.cpp
@ -193,8 +193,9 @@ bool Loop::registerWriteCallback ( int fd, void *state, void (* callback)(int fd
|
||||
}
|
||||
|
||||
// tick is in milliseconds
|
||||
bool Loop::registerSleepCallback ( int32_t tick, void *state, void (* callback)(int fd,void *state ), int32_t niceness ) {
|
||||
if ( ! addSlot ( true, MAX_NUM_FDS, state, callback , niceness ,tick) ) {
|
||||
bool Loop::registerSleepCallback ( int32_t tick, void *state, void (* callback)(int fd,void *state ),
|
||||
int32_t niceness, bool immediate ) {
|
||||
if ( ! addSlot ( true, MAX_NUM_FDS, state, callback, niceness, tick, immediate ) ) {
|
||||
log( LOG_WARN, "loop: Unable to register sleep callback" );
|
||||
return false;
|
||||
}
|
||||
@ -207,10 +208,8 @@ bool Loop::registerSleepCallback ( int32_t tick, void *state, void (* callback)(
|
||||
}
|
||||
|
||||
// . returns false and sets g_errno on error
|
||||
bool Loop::addSlot ( bool forReading , int fd, void *state,
|
||||
void (* callback)(int fd, void *state), int32_t niceness ,
|
||||
int32_t tick ) {
|
||||
|
||||
bool Loop::addSlot ( bool forReading , int fd, void *state, void (* callback)(int fd, void *state),
|
||||
int32_t niceness , int32_t tick, bool immediate ) {
|
||||
// ensure fd is >= 0
|
||||
if ( fd < 0 ) {
|
||||
g_errno = EBADENGINEER;
|
||||
@ -301,7 +300,7 @@ bool Loop::addSlot ( bool forReading , int fd, void *state,
|
||||
s->m_tick = tick;
|
||||
|
||||
// the last called time
|
||||
s->m_lastCall = gettimeofdayInMilliseconds();
|
||||
s->m_lastCall = immediate ? 0 : gettimeofdayInMilliseconds();
|
||||
|
||||
// debug msg
|
||||
//log("Loop::registered fd=%i state=%" PRIu32,fd,state);
|
||||
|
11
Loop.h
11
Loop.h
@ -121,10 +121,8 @@ class Loop {
|
||||
|
||||
// . register this callback to be called every second
|
||||
// . TODO: implement "seconds" parameter
|
||||
bool registerSleepCallback ( int32_t milliseconds ,
|
||||
void *state,
|
||||
void (* callback)(int fd,void *state ) ,
|
||||
int32_t niceness = 1 );
|
||||
bool registerSleepCallback ( int32_t milliseconds, void *state, void (* callback)(int fd,void *state ),
|
||||
int32_t niceness = 1, bool immediate = false );
|
||||
|
||||
// unregister call back for reading, writing or sleeping
|
||||
void unregisterReadCallback ( int fd, void *state , void (* callback)(int fd,void *state), bool silent = false );
|
||||
@ -173,9 +171,8 @@ class Loop {
|
||||
bool silent , // = false );
|
||||
bool forReading );
|
||||
|
||||
bool addSlot ( bool forReading , int fd , void *state ,
|
||||
void (* callback)(int fd , void *state ) ,
|
||||
int32_t niceness , int32_t tick = 0x7fffffff ) ;
|
||||
bool addSlot ( bool forReading , int fd , void *state , void (* callback)(int fd , void *state ),
|
||||
int32_t niceness , int32_t tick = 0x7fffffff, bool immediate = false ) ;
|
||||
|
||||
// set how long to pause waiting for singals (in milliseconds)
|
||||
void setSigWaitTime ( int32_t ms ) ;
|
||||
|
8
main.cpp
8
main.cpp
@ -2240,14 +2240,12 @@ int main2 ( int argc , char *argv[] ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// . register a callback to try to merge everything every 2 seconds
|
||||
// . register a callback to try to merge everything every 60 seconds
|
||||
// . do not exit if we couldn't do this, not a huge deal
|
||||
// . put this in here instead of Rdb.cpp because we don't want
|
||||
// generator commands merging on us
|
||||
// . the (void *)1 prevents gb from logging merge info every 2 seconds
|
||||
// . put this in here instead of Rdb.cpp because we don't want generator commands merging on us
|
||||
// . niceness is 1
|
||||
// BR: Upped from 2 sec to 60. No need to check for merge every 2 seconds.
|
||||
if ( !g_loop.registerSleepCallback( 60000, (void *)1, attemptMergeAllCallback, 1) ) {
|
||||
if ( !g_loop.registerSleepCallback( 60000, (void *)1, attemptMergeAllCallback, 1, true ) ) {
|
||||
log( LOG_WARN, "db: Failed to init merge sleep callback." );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user