Commit ba5cd462 authored by Dominik Charousset's avatar Dominik Charousset

Fix shadowing warnings

parent 69f75141
...@@ -152,14 +152,14 @@ protected: ...@@ -152,14 +152,14 @@ protected:
// handles `exit_msg`, `sys_atom` messages, and additionally `down_msg` // handles `exit_msg`, `sys_atom` messages, and additionally `down_msg`
// with `down_msg_handler`; returns true if the message is handled // with `down_msg_handler`; returns true if the message is handled
template <class F> template <class F>
bool handle_system_message(mailbox_element& node, execution_unit* context, bool handle_system_message(mailbox_element& x, execution_unit* context,
bool trap_exit, F& down_msg_handler) { bool trap_exit, F& down_msg_handler) {
auto& msg = node.msg; auto& msg = x.msg;
if (msg.size() == 1 && msg.match_element<down_msg>(0)) { if (msg.size() == 1 && msg.match_element<down_msg>(0)) {
down_msg_handler(msg.get_as_mutable<down_msg>(0)); down_msg_handler(msg.get_as_mutable<down_msg>(0));
return true; return true;
} }
return handle_system_message(node, context, trap_exit); return handle_system_message(x, context, trap_exit);
} }
// Calls `fun` with exclusive access to an actor's state. // Calls `fun` with exclusive access to an actor's state.
......
...@@ -49,8 +49,8 @@ class optional { ...@@ -49,8 +49,8 @@ class optional {
class E = typename std::enable_if< class E = typename std::enable_if<
std::is_convertible<U, T>::value std::is_convertible<U, T>::value
>::type> >::type>
optional(U value) : m_valid(false) { optional(U x) : m_valid(false) {
cr(std::move(value)); cr(std::move(x));
} }
optional(const optional& other) : m_valid(false) { optional(const optional& other) : m_valid(false) {
...@@ -151,10 +151,10 @@ class optional { ...@@ -151,10 +151,10 @@ class optional {
} }
template <class V> template <class V>
void cr(V&& value) { void cr(V&& x) {
CAF_ASSERT(! m_valid); CAF_ASSERT(! m_valid);
m_valid = true; m_valid = true;
new (&m_value) T(std::forward<V>(value)); new (&m_value) T(std::forward<V>(x));
} }
bool m_valid; bool m_valid;
...@@ -172,7 +172,7 @@ class optional<T&> { ...@@ -172,7 +172,7 @@ class optional<T&> {
// nop // nop
} }
optional(T& value) : m_value(&value) { optional(T& x) : m_value(&x) {
// nop // nop
} }
......
...@@ -47,8 +47,8 @@ public: ...@@ -47,8 +47,8 @@ public:
using worker_type = worker<Policy>; using worker_type = worker<Policy>;
worker_type* worker_by_id(size_t id) {//override { worker_type* worker_by_id(size_t x) {
return workers_[id].get(); return workers_[x].get();
} }
policy_data& data() { policy_data& data() {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#elif defined(CAF_WINDOWS) #elif defined(CAF_WINDOWS)
#include <Windows.h> #include <Windows.h>
#include <Psapi.h> #include <Psapi.h>
#else #else
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time, GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time,
&kernel_time, &user_time); &kernel_time, &user_time);
GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
m.mem = pmc.PeakWorkingSetSize / 1024; m.mem = pmc.PeakWorkingSetSize / 1024;
...@@ -256,11 +256,11 @@ public: ...@@ -256,11 +256,11 @@ public:
} }
template <class Time, class Label> template <class Time, class Label>
void record(Time t, Label label, size_t id, const measurement& m) { void record(Time t, Label label, size_t rec_id, const measurement& m) {
using std::setw; using std::setw;
file_ << setw(21) << t.time_since_epoch().count() file_ << setw(21) << t.time_since_epoch().count()
<< setw(10) << label << setw(10) << label
<< setw(10) << id << setw(10) << rec_id
<< m << m
<< '\n'; << '\n';
} }
......
...@@ -43,10 +43,10 @@ void actor_companion::enqueue(mailbox_element_ptr ptr, execution_unit*) { ...@@ -43,10 +43,10 @@ void actor_companion::enqueue(mailbox_element_ptr ptr, execution_unit*) {
on_enqueue_(std::move(ptr)); on_enqueue_(std::move(ptr));
} }
void actor_companion::enqueue(strong_actor_ptr sender, message_id mid, void actor_companion::enqueue(strong_actor_ptr src, message_id mid,
message content, execution_unit* eu) { message content, execution_unit* eu) {
using detail::memory; using detail::memory;
auto ptr = mailbox_element::make(sender, mid, {}, std::move(content)); auto ptr = mailbox_element::make(std::move(src), mid, {}, std::move(content));
enqueue(std::move(ptr), eu); enqueue(std::move(ptr), eu);
} }
......
...@@ -272,17 +272,16 @@ actor_system_config::add_error_category(atom_value x, error_renderer y) { ...@@ -272,17 +272,16 @@ actor_system_config::add_error_category(atom_value x, error_renderer y) {
return *this; return *this;
} }
actor_system_config& actor_system_config& actor_system_config::set(const char* cn, config_value cv) {
actor_system_config::set(const char* config_name, config_value config_value) { std::string full_name;
std::string cn;
for (auto& x : options_) { for (auto& x : options_) {
// config_name has format "$category.$name" // config_name has format "$category.$name"
cn = x->category(); full_name = x->category();
cn += '.'; full_name += '.';
cn += x->name(); full_name += x->name();
if (cn == config_name) { if (full_name == cn) {
auto f = x->to_sink(); auto f = x->to_sink();
f(0, config_value); f(0, cv);
} }
} }
return *this; return *this;
......
...@@ -39,12 +39,12 @@ blocking_actor::~blocking_actor() { ...@@ -39,12 +39,12 @@ blocking_actor::~blocking_actor() {
void blocking_actor::enqueue(mailbox_element_ptr ptr, execution_unit*) { void blocking_actor::enqueue(mailbox_element_ptr ptr, execution_unit*) {
auto mid = ptr->mid; auto mid = ptr->mid;
auto sender = ptr->sender; auto src = ptr->sender;
// returns false if mailbox has been closed // returns false if mailbox has been closed
if (! mailbox().synchronized_enqueue(mtx_, cv_, ptr.release())) { if (! mailbox().synchronized_enqueue(mtx_, cv_, ptr.release())) {
if (mid.is_request()) { if (mid.is_request()) {
detail::sync_request_bouncer srb{exit_reason()}; detail::sync_request_bouncer srb{exit_reason()};
srb(sender, mid); srb(src, mid);
} }
} }
} }
......
...@@ -23,11 +23,10 @@ ...@@ -23,11 +23,10 @@
namespace caf { namespace caf {
config_option::config_option(const char* category, const char* name, config_option::config_option(const char* cat, const char* nm, const char* expl)
const char* explanation) : category_(cat),
: category_(category), name_(nm),
name_(name), explanation_(expl),
explanation_(explanation),
short_name_('\0') { short_name_('\0') {
auto last = name_.end(); auto last = name_.end();
auto comma = std::find(name_.begin(), last, ','); auto comma = std::find(name_.begin(), last, ',');
......
...@@ -198,11 +198,11 @@ public: ...@@ -198,11 +198,11 @@ public:
private: private:
void send_to_acquaintances(const message& what) { void send_to_acquaintances(const message& what) {
// send to all remote subscribers // send to all remote subscribers
auto sender = current_element_->sender; auto src = current_element_->sender;
CAF_LOG_DEBUG(CAF_ARG(acquaintances_.size()) CAF_LOG_DEBUG(CAF_ARG(acquaintances_.size())
<< CAF_ARG(sender) << CAF_ARG(what)); << CAF_ARG(src) << CAF_ARG(what));
for (auto& acquaintance : acquaintances_) for (auto& acquaintance : acquaintances_)
acquaintance->enqueue(sender, invalid_message_id, what, context()); acquaintance->enqueue(src, invalid_message_id, what, context());
} }
local_group_ptr group_; local_group_ptr group_;
......
...@@ -319,9 +319,9 @@ uint32_t local_actor::active_timeout_id() const { ...@@ -319,9 +319,9 @@ uint32_t local_actor::active_timeout_id() const {
return timeout_id_; return timeout_id_;
} }
local_actor::msg_type local_actor::filter_msg(mailbox_element& node) { local_actor::msg_type local_actor::filter_msg(mailbox_element& x) {
message& msg = node.msg; message& msg = x.msg;
auto mid = node.mid; auto mid = x.mid;
if (mid.is_response()) if (mid.is_response())
return msg_type::response; return msg_type::response;
switch (msg.type_token()) { switch (msg.type_token()) {
...@@ -331,14 +331,14 @@ local_actor::msg_type local_actor::filter_msg(mailbox_element& node) { ...@@ -331,14 +331,14 @@ local_actor::msg_type local_actor::filter_msg(mailbox_element& node) {
auto& what = msg.get_as<std::string>(2); auto& what = msg.get_as<std::string>(2);
if (what == "info") { if (what == "info") {
CAF_LOG_DEBUG("reply to 'info' message"); CAF_LOG_DEBUG("reply to 'info' message");
node.sender->enqueue( x.sender->enqueue(
mailbox_element::make(ctrl(), node.mid.response_id(), mailbox_element::make(ctrl(), x.mid.response_id(),
{}, ok_atom::value, std::move(what), {}, ok_atom::value, std::move(what),
address(), name()), address(), name()),
context()); context());
} else { } else {
node.sender->enqueue( x.sender->enqueue(
mailbox_element::make(ctrl(), node.mid.response_id(), mailbox_element::make(ctrl(), x.mid.response_id(),
{}, sec::unsupported_sys_key), {}, sec::unsupported_sys_key),
context()); context());
} }
......
...@@ -285,18 +285,18 @@ void logger::run() { ...@@ -285,18 +285,18 @@ void logger::run() {
<< "_" << to_string(system_.node()) << "_" << to_string(system_.node())
<< ".log"; << ".log";
std::fstream out(fname.str().c_str(), std::ios::out | std::ios::app); std::fstream out(fname.str().c_str(), std::ios::out | std::ios::app);
std::unique_ptr<event> event; std::unique_ptr<event> ptr;
for (;;) { for (;;) {
// make sure we have data to read // make sure we have data to read
queue_.synchronized_await(queue_mtx_, queue_cv_); queue_.synchronized_await(queue_mtx_, queue_cv_);
// read & process event // read & process event
event.reset(queue_.try_pop()); ptr.reset(queue_.try_pop());
CAF_ASSERT(event != nullptr); CAF_ASSERT(ptr != nullptr);
if (event->msg.empty()) { if (ptr->msg.empty()) {
out.close(); out.close();
return; return;
} }
out << event->msg << std::flush; out << ptr->msg << std::flush;
} }
} }
......
...@@ -237,18 +237,18 @@ size_t monitorable_actor::detach_impl(const attachable::token& what, ...@@ -237,18 +237,18 @@ size_t monitorable_actor::detach_impl(const attachable::token& what,
return detach_impl(what, ptr->next, stop_on_hit, dry_run); return detach_impl(what, ptr->next, stop_on_hit, dry_run);
} }
bool monitorable_actor::handle_system_message(mailbox_element& node, bool monitorable_actor::handle_system_message(mailbox_element& x,
execution_unit* context, execution_unit* ctx,
bool trap_exit) { bool trap_exit) {
auto& msg = node.msg; auto& msg = x.msg;
if (! trap_exit && msg.size() == 1 && msg.match_element<exit_msg>(0)) { if (! trap_exit && msg.size() == 1 && msg.match_element<exit_msg>(0)) {
// exits for non-normal exit reasons // exits for non-normal exit reasons
auto& em = msg.get_as_mutable<exit_msg>(0); auto& em = msg.get_as_mutable<exit_msg>(0);
if (em.reason) if (em.reason)
cleanup(std::move(em.reason), context); cleanup(std::move(em.reason), ctx);
return true; return true;
} else if (msg.size() > 1 && msg.match_element<sys_atom>(0)) { } else if (msg.size() > 1 && msg.match_element<sys_atom>(0)) {
if (! node.sender) if (! x.sender)
return true; return true;
error err; error err;
mailbox_element_ptr res; mailbox_element_ptr res;
...@@ -259,20 +259,20 @@ bool monitorable_actor::handle_system_message(mailbox_element& node, ...@@ -259,20 +259,20 @@ bool monitorable_actor::handle_system_message(mailbox_element& node,
err = sec::unsupported_sys_key; err = sec::unsupported_sys_key;
return; return;
} }
res = mailbox_element::make(ctrl(), node.mid.response_id(), {}, res = mailbox_element::make(ctrl(), x.mid.response_id(), {},
ok_atom::value, std::move(what), ok_atom::value, std::move(what),
address(), name()); address(), name());
} }
}); });
if (! res && ! err) if (! res && ! err)
err = sec::unsupported_sys_message; err = sec::unsupported_sys_message;
if (err && node.mid.is_request()) if (err && x.mid.is_request())
res = mailbox_element::make(ctrl(), node.mid.response_id(), res = mailbox_element::make(ctrl(), x.mid.response_id(),
{}, std::move(err)); {}, std::move(err));
if (res) { if (res) {
auto s = actor_cast<strong_actor_ptr>(node.sender); auto s = actor_cast<strong_actor_ptr>(x.sender);
if (s) if (s)
s->enqueue(std::move(res), context); s->enqueue(std::move(res), ctx);
} }
return true; return true;
} }
......
...@@ -30,8 +30,8 @@ response_promise::response_promise() ...@@ -30,8 +30,8 @@ response_promise::response_promise()
// nop // nop
} }
response_promise::response_promise(local_actor* self, mailbox_element& src) response_promise::response_promise(local_actor* ptr, mailbox_element& src)
: self_(self), : self_(ptr),
id_(src.mid) { id_(src.mid) {
// form an invalid request promise when initialized from a // form an invalid request promise when initialized from a
// response ID, since CAF always drops messages in this case // response ID, since CAF always drops messages in this case
......
...@@ -38,26 +38,26 @@ behavior mirror_impl(event_based_actor* self) { ...@@ -38,26 +38,26 @@ behavior mirror_impl(event_based_actor* self) {
struct fixture { struct fixture {
actor_system system; actor_system system;
scoped_actor self; scoped_actor scoped_self;
actor mirror; actor mirror;
actor testee; actor testee;
fixture() fixture()
: self(system), : scoped_self(system),
mirror(system.spawn(mirror_impl)), mirror(system.spawn(mirror_impl)),
testee(unsafe_actor_handle_init) { testee(unsafe_actor_handle_init) {
self->set_down_handler([](local_actor*, down_msg& dm) { scoped_self->set_down_handler([](local_actor*, down_msg& dm) {
CAF_CHECK_EQUAL(dm.reason, exit_reason::normal); CAF_CHECK_EQUAL(dm.reason, exit_reason::normal);
}); });
} }
template <class... Ts> template <class... Ts>
void spawn(Ts&&... xs) { void spawn(Ts&&... xs) {
testee = self->spawn<monitored>(std::forward<Ts>(xs)...); testee = scoped_self->spawn<monitored>(std::forward<Ts>(xs)...);
} }
~fixture() { ~fixture() {
self->wait_for(testee); scoped_self->wait_for(testee);
} }
}; };
......
...@@ -259,16 +259,16 @@ CAF_TEST(test_void_res) { ...@@ -259,16 +259,16 @@ CAF_TEST(test_void_res) {
} }
CAF_TEST(pending_quit) { CAF_TEST(pending_quit) {
auto mirror = system.spawn([](event_based_actor* self) -> behavior { auto mirror = system.spawn([](event_based_actor* ptr) -> behavior {
self->set_default_handler(reflect); ptr->set_default_handler(reflect);
return { return {
[] { [] {
// nop // nop
} }
}; };
}); });
system.spawn([mirror](event_based_actor* self) { system.spawn([mirror](event_based_actor* ptr) {
self->request(mirror, infinite, 42).then( ptr->request(mirror, infinite, 42).then(
[](int) { [](int) {
CAF_ERROR("received result, should've been terminated already"); CAF_ERROR("received result, should've been terminated already");
}, },
...@@ -276,7 +276,7 @@ CAF_TEST(pending_quit) { ...@@ -276,7 +276,7 @@ CAF_TEST(pending_quit) {
CAF_CHECK_EQUAL(err, sec::request_receiver_down); CAF_CHECK_EQUAL(err, sec::request_receiver_down);
} }
); );
self->quit(); ptr->quit();
}); });
} }
...@@ -334,7 +334,6 @@ CAF_TEST(request_to_mirror) { ...@@ -334,7 +334,6 @@ CAF_TEST(request_to_mirror) {
} }
CAF_TEST(request_to_a_fwd2_b_fwd2_c) { CAF_TEST(request_to_a_fwd2_b_fwd2_c) {
scoped_actor self{system};
self->request(self->spawn<A, monitored>(self), infinite, self->request(self->spawn<A, monitored>(self), infinite,
go_atom::value, self->spawn<B>(self->spawn<C>())).receive( go_atom::value, self->spawn<B>(self->spawn<C>())).receive(
[](ok_atom) { [](ok_atom) {
...@@ -428,21 +427,21 @@ CAF_TEST(request_no_then) { ...@@ -428,21 +427,21 @@ CAF_TEST(request_no_then) {
} }
CAF_TEST(async_request) { CAF_TEST(async_request) {
auto foo = system.spawn([](event_based_actor* self) -> behavior { auto foo = system.spawn([](event_based_actor* ptr) -> behavior {
auto receiver = self->spawn<linked>([](event_based_actor* ptr) -> behavior { auto receiver = ptr->spawn<linked>([](event_based_actor* ptr2) -> behavior {
return { return {
[=](int) { [=](int) {
return ptr->make_response_promise(); return ptr2->make_response_promise();
} }
}; };
}); });
self->request(receiver, infinite, 1).then( ptr->request(receiver, infinite, 1).then(
[=](int) {} [=](int) {}
); );
return { return {
[=](int) { [=](int) {
CAF_MESSAGE("int received"); CAF_MESSAGE("int received");
self->quit(exit_reason::user_shutdown); ptr->quit(exit_reason::user_shutdown);
} }
}; };
}); });
......
...@@ -413,7 +413,6 @@ CAF_TEST(string_delegator_chain) { ...@@ -413,7 +413,6 @@ CAF_TEST(string_delegator_chain) {
} }
CAF_TEST(maybe_string_delegator_chain) { CAF_TEST(maybe_string_delegator_chain) {
scoped_actor self{system};
CAF_LOG_TRACE(CAF_ARG(self)); CAF_LOG_TRACE(CAF_ARG(self));
auto aut = system.spawn(maybe_string_delegator, auto aut = system.spawn(maybe_string_delegator,
system.spawn(maybe_string_reverter)); system.spawn(maybe_string_reverter));
...@@ -437,7 +436,6 @@ CAF_TEST(maybe_string_delegator_chain) { ...@@ -437,7 +436,6 @@ CAF_TEST(maybe_string_delegator_chain) {
} }
CAF_TEST(sending_typed_actors) { CAF_TEST(sending_typed_actors) {
scoped_actor self{system};
auto aut = system.spawn(int_fun); auto aut = system.spawn(int_fun);
self->send(self->spawn(foo), 10, aut); self->send(self->spawn(foo), 10, aut);
self->receive( self->receive(
...@@ -448,7 +446,6 @@ CAF_TEST(sending_typed_actors) { ...@@ -448,7 +446,6 @@ CAF_TEST(sending_typed_actors) {
} }
CAF_TEST(sending_typed_actors_and_down_msg) { CAF_TEST(sending_typed_actors_and_down_msg) {
scoped_actor self{system};
auto aut = system.spawn(int_fun2); auto aut = system.spawn(int_fun2);
self->send(self->spawn(foo2), 10, aut); self->send(self->spawn(foo2), 10, aut);
self->receive([](int i) { self->receive([](int i) {
...@@ -460,20 +457,20 @@ CAF_TEST(check_signature) { ...@@ -460,20 +457,20 @@ CAF_TEST(check_signature) {
using foo_type = typed_actor<replies_to<put_atom>::with<ok_atom>>; using foo_type = typed_actor<replies_to<put_atom>::with<ok_atom>>;
using foo_result_type = optional<ok_atom>; using foo_result_type = optional<ok_atom>;
using bar_type = typed_actor<reacts_to<ok_atom>>; using bar_type = typed_actor<reacts_to<ok_atom>>;
auto foo_action = [](foo_type::pointer self) -> foo_type::behavior_type { auto foo_action = [](foo_type::pointer ptr) -> foo_type::behavior_type {
return { return {
[=] (put_atom) -> foo_result_type { [=] (put_atom) -> foo_result_type {
self->quit(); ptr->quit();
return {ok_atom::value}; return {ok_atom::value};
} }
}; };
}; };
auto bar_action = [=](bar_type::pointer self) -> bar_type::behavior_type { auto bar_action = [=](bar_type::pointer ptr) -> bar_type::behavior_type {
auto foo = self->spawn<linked>(foo_action); auto foo = ptr->spawn<linked>(foo_action);
self->send(foo, put_atom::value); ptr->send(foo, put_atom::value);
return { return {
[=](ok_atom) { [=](ok_atom) {
self->quit(); ptr->quit();
} }
}; };
}; };
......
...@@ -279,10 +279,10 @@ private: ...@@ -279,10 +279,10 @@ private:
auto hdl = backend().new_tcp_scribe(host, port); auto hdl = backend().new_tcp_scribe(host, port);
detail::init_fun_factory<Impl, F> fac; detail::init_fun_factory<Impl, F> fac;
actor_config cfg{&backend()}; actor_config cfg{&backend()};
auto init = fac(std::move(fun), hdl, std::forward<Ts>(xs)...); auto init_fun = fac(std::move(fun), hdl, std::forward<Ts>(xs)...);
cfg.init_fun = [hdl, init](local_actor* ptr) -> behavior { cfg.init_fun = [hdl, init_fun](local_actor* ptr) -> behavior {
static_cast<abstract_broker*>(ptr)->assign_tcp_scribe(hdl); static_cast<abstract_broker*>(ptr)->assign_tcp_scribe(hdl);
return init(ptr); return init_fun(ptr);
}; };
return system().spawn_class<Impl, Os>(cfg); return system().spawn_class<Impl, Os>(cfg);
} }
...@@ -291,12 +291,12 @@ private: ...@@ -291,12 +291,12 @@ private:
typename infer_handle_from_class<Impl>::type typename infer_handle_from_class<Impl>::type
spawn_server_impl(F fun, uint16_t port, Ts&&... xs) { spawn_server_impl(F fun, uint16_t port, Ts&&... xs) {
detail::init_fun_factory<Impl, F> fac; detail::init_fun_factory<Impl, F> fac;
auto init = fac(std::move(fun), std::forward<Ts>(xs)...); auto init_fun = fac(std::move(fun), std::forward<Ts>(xs)...);
auto hdl = backend().new_tcp_doorman(port).first; auto hdl = backend().new_tcp_doorman(port).first;
actor_config cfg{&backend()}; actor_config cfg{&backend()};
cfg.init_fun = [hdl, init](local_actor* ptr) -> behavior { cfg.init_fun = [hdl, init_fun](local_actor* ptr) -> behavior {
static_cast<abstract_broker*>(ptr)->assign_tcp_doorman(hdl); static_cast<abstract_broker*>(ptr)->assign_tcp_doorman(hdl);
return init(ptr); return init_fun(ptr);
}; };
return system().spawn_class<Impl, Os>(cfg); return system().spawn_class<Impl, Os>(cfg);
} }
......
...@@ -194,10 +194,10 @@ resumable::subtype_t abstract_broker::subtype() const { ...@@ -194,10 +194,10 @@ resumable::subtype_t abstract_broker::subtype() const {
} }
resumable::resume_result resumable::resume_result
abstract_broker::resume(execution_unit* context, size_t mt) { abstract_broker::resume(execution_unit* ctx, size_t mt) {
CAF_ASSERT(context != nullptr); CAF_ASSERT(ctx != nullptr);
CAF_ASSERT(context == &backend()); CAF_ASSERT(ctx == &backend());
return local_actor::resume(context, mt); return local_actor::resume(ctx, mt);
} }
const char* abstract_broker::name() const { const char* abstract_broker::name() const {
......
...@@ -486,50 +486,50 @@ behavior basp_broker::make_behavior() { ...@@ -486,50 +486,50 @@ behavior basp_broker::make_behavior() {
} }
}, },
// received from proxy instances // received from proxy instances
[=](forward_atom, strong_actor_ptr& sender, [=](forward_atom, strong_actor_ptr& src,
const std::vector<strong_actor_ptr>& fwd_stack, const std::vector<strong_actor_ptr>& fwd_stack,
strong_actor_ptr& receiver, message_id mid, const message& msg) { strong_actor_ptr& dest, message_id mid, const message& msg) {
CAF_LOG_TRACE(CAF_ARG(sender) << CAF_ARG(receiver) CAF_LOG_TRACE(CAF_ARG(src) << CAF_ARG(dest)
<< CAF_ARG(mid) << CAF_ARG(msg)); << CAF_ARG(mid) << CAF_ARG(msg));
if (! receiver || system().node() == receiver->node()) { if (! dest || system().node() == dest->node()) {
CAF_LOG_WARNING("cannot forward to invalid or local actor:" CAF_LOG_WARNING("cannot forward to invalid or local actor:"
<< CAF_ARG(receiver)); << CAF_ARG(dest));
return; return;
} }
if (sender && system().node() == sender->node()) if (src && system().node() == src->node())
system().registry().put(sender->id(), sender); system().registry().put(src->id(), src);
if (! state.instance.dispatch(context(), sender, fwd_stack, if (! state.instance.dispatch(context(), src, fwd_stack,
receiver, mid, msg) dest, mid, msg)
&& mid.is_request()) { && mid.is_request()) {
detail::sync_request_bouncer srb{exit_reason::remote_link_unreachable}; detail::sync_request_bouncer srb{exit_reason::remote_link_unreachable};
srb(sender, mid); srb(src, mid);
} }
}, },
// received from some system calls like whereis // received from some system calls like whereis
[=](forward_atom, strong_actor_ptr& sender, [=](forward_atom, strong_actor_ptr& src,
const node_id& receiving_node, atom_value receiver_name, const node_id& dest_node, atom_value dest_name,
const message& msg) -> result<void> { const message& msg) -> result<void> {
CAF_LOG_TRACE(CAF_ARG(sender) CAF_LOG_TRACE(CAF_ARG(src)
<< ", " << CAF_ARG(receiving_node) << ", " << CAF_ARG(dest_node)
<< ", " << CAF_ARG(receiver_name) << ", " << CAF_ARG(dest_name)
<< ", " << CAF_ARG(msg)); << ", " << CAF_ARG(msg));
if (! sender) if (! src)
return sec::cannot_forward_to_invalid_actor; return sec::cannot_forward_to_invalid_actor;
if (system().node() == sender->node()) if (system().node() == src->node())
system().registry().put(sender->id(), sender); system().registry().put(src->id(), src);
auto writer = make_callback([&](serializer& sink) { auto writer = make_callback([&](serializer& sink) {
std::vector<actor_addr> stages; std::vector<actor_addr> stages;
sink << receiver_name << stages << msg; sink << dest_name << stages << msg;
}); });
auto path = this->state.instance.tbl().lookup(receiving_node); auto path = this->state.instance.tbl().lookup(dest_node);
if (! path) { if (! path) {
CAF_LOG_ERROR("no route to receiving node"); CAF_LOG_ERROR("no route to receiving node");
return sec::no_route_to_receiving_node; return sec::no_route_to_receiving_node;
} }
basp::header hdr{basp::message_type::dispatch_message, basp::header hdr{basp::message_type::dispatch_message,
basp::header::named_receiver_flag, basp::header::named_receiver_flag,
0, 0, state.this_node(), receiving_node, 0, 0, state.this_node(), dest_node,
sender->id(), invalid_actor_id}; src->id(), invalid_actor_id};
state.instance.write(context(), path->wr_buf, hdr, &writer); state.instance.write(context(), path->wr_buf, hdr, &writer);
state.instance.flush(*path); state.instance.flush(*path);
return unit; return unit;
......
...@@ -724,10 +724,10 @@ connection_handle default_multiplexer::add_tcp_scribe(abstract_broker* self, ...@@ -724,10 +724,10 @@ connection_handle default_multiplexer::add_tcp_scribe(abstract_broker* self,
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
class impl : public scribe { class impl : public scribe {
public: public:
impl(abstract_broker* ptr, default_multiplexer& ref, native_socket sockfd) impl(abstract_broker* ptr, default_multiplexer& mx, native_socket sockfd)
: scribe(ptr, network::conn_hdl_from_socket(sockfd)), : scribe(ptr, network::conn_hdl_from_socket(sockfd)),
launched_(false), launched_(false),
stream_(ref, sockfd) { stream_(mx, sockfd) {
// nop // nop
} }
void configure_read(receive_policy::config config) override { void configure_read(receive_policy::config config) override {
...@@ -782,9 +782,9 @@ accept_handle default_multiplexer::add_tcp_doorman(abstract_broker* self, ...@@ -782,9 +782,9 @@ accept_handle default_multiplexer::add_tcp_doorman(abstract_broker* self,
CAF_ASSERT(fd != network::invalid_native_socket); CAF_ASSERT(fd != network::invalid_native_socket);
class impl : public doorman { class impl : public doorman {
public: public:
impl(abstract_broker* ptr, default_multiplexer& ref, native_socket sockfd) impl(abstract_broker* ptr, default_multiplexer& mx, native_socket sockfd)
: doorman(ptr, network::accept_hdl_from_socket(sockfd)), : doorman(ptr, network::accept_hdl_from_socket(sockfd)),
acceptor_(ref, sockfd) { acceptor_(mx, sockfd) {
// nop // nop
} }
void new_connection() override { void new_connection() override {
...@@ -998,8 +998,8 @@ void pipe_reader::handle_event(operation op) { ...@@ -998,8 +998,8 @@ void pipe_reader::handle_event(operation op) {
} }
} }
void pipe_reader::init(native_socket fd) { void pipe_reader::init(native_socket sock_fd) {
fd_ = fd; fd_ = sock_fd;
} }
stream::stream(default_multiplexer& backend_ref, native_socket sockfd) stream::stream(default_multiplexer& backend_ref, native_socket sockfd)
......
...@@ -39,9 +39,9 @@ test_multiplexer::~test_multiplexer() { ...@@ -39,9 +39,9 @@ test_multiplexer::~test_multiplexer() {
} }
connection_handle connection_handle
test_multiplexer::new_tcp_scribe(const std::string& host, uint16_t port) { test_multiplexer::new_tcp_scribe(const std::string& host, uint16_t port_hint) {
connection_handle result; connection_handle result;
auto i = scribes_.find(std::make_pair(host, port)); auto i = scribes_.find(std::make_pair(host, port_hint));
if (i != scribes_.end()) { if (i != scribes_.end()) {
result = i->second; result = i->second;
scribes_.erase(i); scribes_.erase(i);
......
...@@ -196,14 +196,12 @@ logger::stream& logger::stream::operator<<(const char* cstr) { ...@@ -196,14 +196,12 @@ logger::stream& logger::stream::operator<<(const char* cstr) {
return *this; return *this;
} }
logger::stream& logger::stream::operator<<(const std::string& str) { logger::stream& logger::stream::operator<<(const std::string& x) {
if (str.empty()) { if (x.empty())
return *this; return *this;
} buf_ << x;
buf_ << str; if (x.back() == '\n')
if (str.back() == '\n') {
flush(); flush();
}
return *this; return *this;
} }
...@@ -212,10 +210,10 @@ std::string logger::stream::str() const { ...@@ -212,10 +210,10 @@ std::string logger::stream::str() const {
} }
void logger::stream::flush() { void logger::stream::flush() {
auto str = buf_.str(); auto x = buf_.str();
buf_.str(""); buf_.str("");
logger_.log(level_, str); logger_.log(level_, x);
str_ += str; str_ += x;
} }
bool logger::init(int lvl_cons, int lvl_file, const std::string& logfile) { bool logger::init(int lvl_cons, int lvl_file, const std::string& logfile) {
......
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