mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 18:11:03 +00:00
ae2a50659f
new update of the pr with network limits more debug options: discarding downloaded blocks all or after given height. trying to trigger the locking errors. debug levels polished/tuned to sane values. debug/logging improved. warning: this pr should be correct code, but it could make an existing (in master version) locking error appear more often. it's a race on the list (map) of peers, e.g. between closing/deleting them versus working on them in net-limit sleep in sending chunk. the bug is not in this code/this pr, but in the master version. the locking problem of master will be fixed in other pr. problem is ub, and in practice is seems to usually cause program abort (tested on debian stable with updated gcc). see --help for option to add sleep to trigger the error faster.
49 lines
1,002 B
C++
49 lines
1,002 B
C++
#ifndef INCLUDED_p2p_data_logger_hpp
|
|
#define INCLUDED_p2p_data_logger_hpp
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <fstream>
|
|
#include <memory>
|
|
#include <thread>
|
|
#include <mutex>
|
|
#include <atomic>
|
|
|
|
namespace epee
|
|
{
|
|
namespace net_utils
|
|
{
|
|
|
|
class data_logger {
|
|
public:
|
|
static data_logger &get_instance();
|
|
data_logger(const data_logger &ob) = delete;
|
|
data_logger(data_logger &&ob) = delete;
|
|
void add_data(std::string filename, unsigned int data);
|
|
static std::atomic<bool> m_save_graph;
|
|
private:
|
|
data_logger();
|
|
class fileData
|
|
{
|
|
public:
|
|
fileData(){}
|
|
fileData(const fileData &ob) = delete;
|
|
fileData(std::string pFile);
|
|
|
|
std::shared_ptr<std::ofstream> mFile;
|
|
long int mDataToSave = 0;
|
|
static double get_current_time();
|
|
void save();
|
|
std::string mPath;
|
|
bool mLimitFile = false;
|
|
};
|
|
|
|
std::map <std::string, fileData> mFilesMap;
|
|
std::mutex mSaveMutex;
|
|
void saveToFile();
|
|
};
|
|
|
|
} // namespace
|
|
} // namespace
|
|
|
|
#endif
|