Handle response with unexpected format.

This commit is contained in:
Thomas Yuan 2015-08-31 22:37:46 -04:00
parent 71b6b3c262
commit ef16ae4e27
5 changed files with 10 additions and 3 deletions

View File

@ -95,7 +95,7 @@ struct observer : boost::noncopyable
bool has_short_timeout() const { return (flags & flag_short_timeout) != 0; }
// this is called when no reply has been received within
// some timeout
// some timeout, or a reply with incorrect format.
virtual void timeout();
// if this is called the destructor should

View File

@ -56,6 +56,7 @@ void find_data_observer::reply(msg const& m)
get_observer()->log(dht_logger::traversal, "[%p] missing response dict"
, static_cast<void*>(algorithm()));
#endif
timeout();
return;
}
@ -66,6 +67,7 @@ void find_data_observer::reply(msg const& m)
get_observer()->log(dht_logger::traversal, "[%p] invalid id in response"
, static_cast<void*>(algorithm()));
#endif
timeout();
return;
}
bdecode_node token = r.dict_find_string("token");

View File

@ -271,6 +271,7 @@ void get_item_observer::reply(msg const& m)
get_observer()->log(dht_logger::traversal, "[%p] missing response dict"
, static_cast<void*>(algorithm()));
#endif
timeout();
return;
}
@ -286,7 +287,10 @@ void get_item_observer::reply(msg const& m)
if (q)
seq = q.int_value();
else if (pk && sig)
{
timeout();
return;
}
bdecode_node v = r.dict_find("v");
if (v)

View File

@ -54,6 +54,7 @@ void get_peers_observer::reply(msg const& m)
get_observer()->log(dht_logger::traversal, "[%p] missing response dict"
, static_cast<void*>(algorithm()));
#endif
timeout();
return;
}
@ -312,6 +313,7 @@ void obfuscated_get_peers_observer::reply(msg const& m)
get_observer()->log(dht_logger::traversal, "[%p] missing response dict"
, static_cast<void*>(algorithm()));
#endif
timeout();
return;
}
@ -322,6 +324,7 @@ void obfuscated_get_peers_observer::reply(msg const& m)
get_observer()->log(dht_logger::traversal, "[%p] invalid id in response"
, static_cast<void*>(algorithm()));
#endif
timeout();
return;
}

View File

@ -141,8 +141,6 @@ void observer::short_timeout()
m_algorithm->failed(observer_ptr(this), traversal_algorithm::short_timeout);
}
// this is called when no reply has been received within
// some timeout
void observer::timeout()
{
if (flags & flag_done) return;