urbackup_backend/urbackupclient/PersistentOpenFiles.h
Phil Lucido 0546b60c66 Handle USN records spanning calls to ChangeJournalWatcher::update()
Fix leak of files in open_write_files when a reference in one batch of journal records causes a file to be added to open_write_files, but then a write reference followed by a close reference in the next batch needs to remove the file from both local_open_write_files and open_write_files.
2015-02-13 00:38:17 -08:00

55 lines
869 B
C++

#pragma once
#include <string>
#include <map>
#include <vector>
#include "../Interface/Server.h"
#include "../Interface/File.h"
#include "../common/data.h"
const char PERSIST_ADD=0;
const char PERSIST_REMOVE=1;
class PersistentOpenFiles
{
public:
PersistentOpenFiles();
~PersistentOpenFiles();
void add(const std::wstring& fn);
void remove(const std::wstring& fn);
bool is_present(const std::wstring& fn);
std::vector<std::wstring> get();
bool flushf();
private:
bool flushf_int(bool allow_cycle);
bool load();
void addf(const std::wstring& fn, unsigned int id);
void removef(unsigned int id, size_t fn_size);
bool cycle();
CWData wdata;
IFile* persistf;
std::map<std::wstring, unsigned int> open_files;
size_t bytes_written;
size_t bytes_deleted;
unsigned int curr_id;
};