Fix bug caused by RP #96.

This commit is contained in:
Thomas Yuan 2015-08-27 22:37:17 -04:00
parent cc29a99c90
commit 71b6b3c262
1 changed files with 11 additions and 2 deletions

View File

@ -302,14 +302,23 @@ bool rpc_manager::incoming(msg const& m, node_id* id
if (m.message.dict_find_string_value("y") == "e")
{
// it's an error.
// It's an error.
#ifndef TORRENT_DISABLE_LOGGING
bdecode_node err_ent = m.message.dict_find("e");
TORRENT_ASSERT(err_ent);
m_log->log(dht_logger::rpc_manager, "reply with error from %s: %s"
, print_endpoint(m.addr).c_str(), err_ent.list_string_value_at(1).c_str());
#endif
o->reply(m);
// Logically, we should call o->reply(m) since we get a reply.
// a reply could be "response" or "error", here the reply is an "error".
// if the reply is an "error", basically the observer could/will
// do nothing with it, especially when observer::reply() is intended to
// handle a "response", not an "error".
// A "response" should somehow call algorithm->finished(), and an error/timeout
// should call algorithm->failed(). From this point of view,
// we should call o->timeout() instead of o->reply(m) because o->reply()
// will call algorithm->finished().
o->timeout();
return false;
}