Skip to content

Commit

Permalink
Misc(actor): tiny bind preparation fixes.
Browse files Browse the repository at this point in the history
 - Actor endpoint now is saved for further usage (logging) before
   binding.
 - More verbose error logging - now it's possible to see what endpoint
   failed to be bound.
  • Loading branch information
3Hren committed Sep 14, 2015
1 parent a059c57 commit ac20125
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,21 @@ actor_t::prototype() const {
void
actor_t::run() {
m_acceptor.apply([this](std::unique_ptr<tcp::acceptor>& ptr) {
tcp::endpoint endpoint;

try {
ptr = std::make_unique<tcp::acceptor>(*m_asio, tcp::endpoint {
endpoint = tcp::endpoint {
m_context.config.network.endpoint,
m_context.mapper.assign(m_prototype->name())
});
};

ptr = std::make_unique<tcp::acceptor>(*m_asio, endpoint);
} catch(const std::system_error& e) {
COCAINE_LOG_ERROR(m_log, "unable to bind local endpoint for service: %s",
error::to_string(e));
COCAINE_LOG_ERROR(m_log, "unable to bind local endpoint %s for service: %s",
endpoint, error::to_string(e));
throw;
}

std::error_code ec;
const auto endpoint = ptr->local_endpoint(ec);

COCAINE_LOG_INFO(m_log, "exposing service on local endpoint %s", endpoint);
});

Expand Down

0 comments on commit ac20125

Please sign in to comment.