mirror of
https://github.com/uroni/urbackup_backend.git
synced 2025-10-26 11:36:50 +00:00
Flush file index during server shutdown
This commit is contained in:
parent
1e42813658
commit
2d4e100eba
@ -38,6 +38,7 @@ IMutex *FileIndex::mutex=NULL;
|
||||
ICondition *FileIndex::cond=NULL;
|
||||
bool FileIndex::do_shutdown=false;
|
||||
bool FileIndex::do_flush=false;
|
||||
bool FileIndex::do_accept = true;
|
||||
|
||||
|
||||
void FileIndex::operator()(void)
|
||||
@ -117,7 +118,7 @@ void FileIndex::put_delayed(const SIndexKey& key, int64 value)
|
||||
{
|
||||
IScopedLock lock(mutex);
|
||||
|
||||
while(active_cache_buffer->size()>=max_buffer_size)
|
||||
while(active_cache_buffer->size()>=max_buffer_size || !do_accept)
|
||||
{
|
||||
lock.relock(NULL);
|
||||
Server->wait(10);
|
||||
@ -313,3 +314,9 @@ void FileIndex::flush()
|
||||
lock.relock(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void FileIndex::stop_accept()
|
||||
{
|
||||
IScopedLock lock(mutex);
|
||||
do_accept = false;
|
||||
}
|
||||
|
||||
@ -138,6 +138,8 @@ public:
|
||||
|
||||
static void flush();
|
||||
|
||||
static void stop_accept();
|
||||
|
||||
private:
|
||||
|
||||
bool get_from_cache( const FileIndex::SIndexKey &key, const std::map<SIndexKey, int64>& cache, int64& res );
|
||||
@ -158,4 +160,5 @@ private:
|
||||
static bool do_shutdown;
|
||||
|
||||
static bool do_flush;
|
||||
static bool do_accept;
|
||||
};
|
||||
@ -805,12 +805,26 @@ DLLEXPORT void UnloadActions(void)
|
||||
ClientMain::destroy_mutex();
|
||||
}
|
||||
|
||||
IDatabase *db=Server->getDatabase(Server->getThreadID(), URBACKUPDB_SERVER);
|
||||
db->Write("PRAGMA wal_checkpoint");
|
||||
if(!shutdown_ok)
|
||||
db->BeginWriteTransaction();
|
||||
std::vector<DATABASE_ID> db_ids;
|
||||
db_ids.push_back(URBACKUPDB_SERVER);
|
||||
db_ids.push_back(URBACKUPDB_SERVER_FILES);
|
||||
db_ids.push_back(URBACKUPDB_SERVER_LINKS);
|
||||
db_ids.push_back(URBACKUPDB_SERVER_LINK_JOURNAL);
|
||||
|
||||
if (!shutdown_ok)
|
||||
{
|
||||
for (size_t i = 0; i < db_ids.size(); ++i)
|
||||
{
|
||||
IDatabase *db = Server->getDatabase(Server->getThreadID(), db_ids[i]);
|
||||
db->BeginWriteTransaction();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Server->destroyAllDatabases();
|
||||
}
|
||||
FileIndex::stop_accept();
|
||||
FileIndex::flush();
|
||||
}
|
||||
|
||||
#ifdef STATIC_PLUGIN
|
||||
|
||||
Loading…
Reference in New Issue
Block a user