mirror of https://github.com/aria2/aria2
Added log messages to DHTRoutingTable IO routines.
parent
dea7a7969c
commit
292bbb3679
|
@ -48,6 +48,7 @@
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
|
#include "LogFactory.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -72,9 +73,12 @@ void readBytes(unsigned char* buf, size_t buflen,
|
||||||
|
|
||||||
void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
||||||
{
|
{
|
||||||
|
A2_LOG_INFO(fmt("Loading DHT routing table from %s.",
|
||||||
|
utf8ToNative(filename).c_str()));
|
||||||
FILE* fp = a2fopen(utf8ToWChar(filename).c_str(), "rb");
|
FILE* fp = a2fopen(utf8ToWChar(filename).c_str(), "rb");
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX("Failed to load DHT routing table.");
|
throw DL_ABORT_EX(fmt("Failed to load DHT routing table from %s",
|
||||||
|
utf8ToNative(filename).c_str()));
|
||||||
}
|
}
|
||||||
auto_delete_r<FILE*, int> deleter(fp, fclose);
|
auto_delete_r<FILE*, int> deleter(fp, fclose);
|
||||||
char header[8];
|
char header[8];
|
||||||
|
@ -116,7 +120,8 @@ void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
||||||
version = 2;
|
version = 2;
|
||||||
} else {
|
} else {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt("Failed to load DHT routing table. cause:%s",
|
(fmt("Failed to load DHT routing table from %s. cause:%s",
|
||||||
|
utf8ToNative(filename).c_str(),
|
||||||
"bad header"));
|
"bad header"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +196,7 @@ void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
||||||
}
|
}
|
||||||
localNode_ = localNode;
|
localNode_ = localNode;
|
||||||
nodes_ = nodes;
|
nodes_ = nodes;
|
||||||
|
A2_LOG_INFO("DHT routing table was loaded successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "TimeA2.h"
|
#include "TimeA2.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
#include "LogFactory.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -76,6 +77,8 @@ void DHTRoutingTableSerializer::setNodes
|
||||||
|
|
||||||
void DHTRoutingTableSerializer::serialize(const std::string& filename)
|
void DHTRoutingTableSerializer::serialize(const std::string& filename)
|
||||||
{
|
{
|
||||||
|
A2_LOG_INFO(fmt("Saving DHT routing table to %s.",
|
||||||
|
utf8ToNative(filename).c_str()));
|
||||||
std::string filenameTemp = filename+"__temp";
|
std::string filenameTemp = filename+"__temp";
|
||||||
FILE* fp = a2fopen(utf8ToWChar(filenameTemp).c_str(), "wb");
|
FILE* fp = a2fopen(utf8ToWChar(filenameTemp).c_str(), "wb");
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
|
@ -149,6 +152,7 @@ void DHTRoutingTableSerializer::serialize(const std::string& filename)
|
||||||
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
||||||
utf8ToNative(filename).c_str()));
|
utf8ToNative(filename).c_str()));
|
||||||
}
|
}
|
||||||
|
A2_LOG_INFO("DHT routing table was saved successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Loading…
Reference in New Issue