Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions arras4_log/lib/arras4_athena/UdpSyslog_boost.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
namespace arras4 {
namespace log {

const int MAX_SENDTO_RETRIES = 5;

void UdpSyslog::sendMessage(int priority,
const tm* timeStamp,
const std::string& ident,
Expand Down Expand Up @@ -45,21 +43,14 @@ void UdpSyslog::sendMessage(int priority,

std::string packet = ss.str();

// send_to can on rare occassons throw system_error because the underlying
// system call sendto() can randomly return EPERM. Just retry and in the
// extremely unlikely case of not working on retries then just drop it
for (int i = 0; i < MAX_SENDTO_RETRIES; i++) {
try {
mSocket.send_to(boost::asio::buffer(packet.data(), packet.size()), mTarget);

// if it succeeds then break out of the loop
break;
} catch (const boost::system::system_error& e) {
if (e.code() != boost::asio::error::basic_errors::no_permission) {
throw;
}
}
}
// The socket is non-blocking because this path is called inline from Arras
// message delivery. Drop telemetry when the UDP target is unavailable or
// its send buffer is full; logging must not delay or abort rendering.
boost::system::error_code error;
mSocket.send_to(boost::asio::buffer(packet.data(), packet.size()),
mTarget,
0,
error);
}

}
Expand Down
6 changes: 6 additions & 0 deletions arras4_log/lib/arras4_athena/UdpSyslog_boost.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class UdpSyslog
boost::asio::ip::udp::endpoint anyAddress;
mSocket.bind(anyAddress);

// Athena logging is best-effort telemetry and must never stall the
// caller. This logger is used directly from latency-sensitive Arras
// message paths, so a blocking UDP send can otherwise stop scene
// updates when no local syslog daemon is draining port 514.
mSocket.non_blocking(true);

// resolve hostname to target endpoint
boost::asio::ip::udp::resolver hostNameResolver(mService);
auto results = hostNameResolver.resolve(boost::asio::ip::udp::v4(), addr, std::to_string(port));
Expand Down