mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 23:29:21 +00:00
More logging stuff.
This commit is contained in:
+20
-10
@@ -55,7 +55,7 @@
|
|||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
|
|
||||||
#define LT_LOG_THIS(log_fmt, ...) \
|
#define LT_LOG_THIS(log_fmt, ...) \
|
||||||
lt_log_print_subsystem(torrent::LOG_DHT_ALL, "dht_manager", log_fmt, __VA_ARGS__);
|
lt_log_print_subsystem(torrent::LOG_DHT_MANAGER, "dht_manager", log_fmt, __VA_ARGS__);
|
||||||
|
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
@@ -73,20 +73,25 @@ DhtManager::load_dht_cache() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent::Object cache = torrent::Object::create_map();
|
std::string cache_filename = control->core()->download_store()->path() + "rtorrent.dht_cache";
|
||||||
std::fstream cache_file((control->core()->download_store()->path() + "rtorrent.dht_cache").c_str(), std::ios::in | std::ios::binary);
|
std::fstream cache_stream(cache_filename.c_str(), std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
if (cache_file.is_open()) {
|
torrent::Object cache = torrent::Object::create_map();
|
||||||
cache_file >> cache;
|
|
||||||
|
if (cache_stream.is_open()) {
|
||||||
|
cache_stream >> cache;
|
||||||
|
|
||||||
// If the cache file is corrupted we will just discard it with an
|
// If the cache file is corrupted we will just discard it with an
|
||||||
// error message.
|
// error message.
|
||||||
if (cache_file.fail()) {
|
if (cache_stream.fail()) {
|
||||||
LT_LOG_THIS("cache file corrupted, discarding", 0);
|
LT_LOG_THIS("cache file corrupted, discarding (path:%s)", cache_filename.c_str());
|
||||||
cache = torrent::Object::create_map();
|
cache = torrent::Object::create_map();
|
||||||
} else {
|
} else {
|
||||||
LT_LOG_THIS("cache file loaded", 0);
|
LT_LOG_THIS("cache file loaded (path:%s)", cache_filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LT_LOG_THIS("could not open cache file (path:%s)", cache_filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -104,8 +109,13 @@ void
|
|||||||
DhtManager::start_dht() {
|
DhtManager::start_dht() {
|
||||||
priority_queue_erase(&taskScheduler, &m_stopTimeout);
|
priority_queue_erase(&taskScheduler, &m_stopTimeout);
|
||||||
|
|
||||||
if (!torrent::dht_manager()->is_valid() || torrent::dht_manager()->is_active()) {
|
if (!torrent::dht_manager()->is_valid()) {
|
||||||
LT_LOG_THIS("server start skipped", 0);
|
LT_LOG_THIS("server start skipped, manager is invalid", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (torrent::dht_manager()->is_active()) {
|
||||||
|
LT_LOG_THIS("server start skipped, already active", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user