Unverified Commit af0ba8f5 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #38

Fix basp::application test
parents cdea6c3b 093f8e2f
...@@ -191,7 +191,7 @@ private: ...@@ -191,7 +191,7 @@ private:
std::unordered_set<actor_addr> monitored_actors_; // TODO: this is unused std::unordered_set<actor_addr> monitored_actors_; // TODO: this is unused
/// Caches actor handles obtained via `resolve`. /// Caches actor handles obtained via `resolve`.
std::unordered_map<uint64_t, response_promise> pending_resolves_; std::unordered_map<uint64_t, actor> pending_resolves_;
/// Ascending ID generator for requests to our peer. /// Ascending ID generator for requests to our peer.
uint64_t next_request_id_ = 1; uint64_t next_request_id_ = 1;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "caf/no_stages.hpp" #include "caf/no_stages.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/send.hpp"
#include "caf/serializer_impl.hpp" #include "caf/serializer_impl.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
#include "caf/type_erased_tuple.hpp" #include "caf/type_erased_tuple.hpp"
...@@ -96,9 +97,7 @@ void application::resolve(packet_writer& writer, string_view path, ...@@ -96,9 +97,7 @@ void application::resolve(packet_writer& writer, string_view path,
static_cast<uint32_t>(payload.size()), req_id}, static_cast<uint32_t>(payload.size()), req_id},
hdr); hdr);
writer.write_packet(hdr, payload); writer.write_packet(hdr, payload);
response_promise rp{nullptr, actor_cast<strong_actor_ptr>(listener), pending_resolves_.emplace(req_id, listener);
no_stages, make_message_id()};
pending_resolves_.emplace(req_id, std::move(rp));
} }
void application::new_proxy(packet_writer& writer, actor_id id) { void application::new_proxy(packet_writer& writer, actor_id id) {
...@@ -332,21 +331,19 @@ error application::handle_resolve_response(packet_writer&, header received_hdr, ...@@ -332,21 +331,19 @@ error application::handle_resolve_response(packet_writer&, header received_hdr,
CAF_LOG_ERROR("received unknown ID in resolve_response message"); CAF_LOG_ERROR("received unknown ID in resolve_response message");
return none; return none;
} }
auto guard = detail::make_scope_guard([&] { auto guard = detail::make_scope_guard([&] { pending_resolves_.erase(i); });
if (i->second.pending())
i->second.deliver(sec::remote_lookup_failed);
pending_resolves_.erase(i);
});
actor_id aid; actor_id aid;
std::set<std::string> ifs; std::set<std::string> ifs;
binary_deserializer source{&executor_, received}; binary_deserializer source{&executor_, received};
if (auto err = source(aid, ifs)) if (auto err = source(aid, ifs)) {
anon_send(i->second, sec::remote_lookup_failed);
return err; return err;
}
if (aid == 0) { if (aid == 0) {
i->second.deliver(strong_actor_ptr{nullptr}, std::move(ifs)); anon_send(i->second, strong_actor_ptr{nullptr}, std::move(ifs));
return none; return none;
} }
i->second.deliver(proxies_.get_or_put(peer_id_, aid), std::move(ifs)); anon_send(i->second, proxies_.get_or_put(peer_id_, aid), std::move(ifs));
return none; return none;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment