[ox/logconn] Add exception handling for logger thread
All checks were successful
Build / build (push) Successful in 1m18s
All checks were successful
Build / build (push) Successful in 1m18s
This commit is contained in:
31
deps/ox/src/ox/logconn/logconn.cpp
vendored
31
deps/ox/src/ox/logconn/logconn.cpp
vendored
@ -91,23 +91,28 @@ ox::Error LoggerConn::sendInit(const InitTraceMsg &msg) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoggerConn::msgSend() noexcept {
|
void LoggerConn::msgSend() noexcept {
|
||||||
while (true) {
|
try {
|
||||||
std::unique_lock lk(m_waitMut);
|
|
||||||
m_waitCond.wait(lk);
|
|
||||||
if (!m_running) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
std::lock_guard const buffLk(m_buffMut);
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Array<char, units::KB> tmp;
|
std::unique_lock lk(m_waitMut);
|
||||||
const auto read = m_buff.read(tmp.data(), tmp.size());
|
m_waitCond.wait(lk);
|
||||||
if (!read) {
|
if (!m_running) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
oxAssert(read <= tmp.size(), "logger trying to read too much data");
|
std::lock_guard const buffLk(m_buffMut);
|
||||||
//std::printf("LoggerConn: sending %lu bytes\n", read);
|
while (true) {
|
||||||
std::ignore = send(tmp.data(), read);
|
Array<char, units::KB> tmp;
|
||||||
|
const auto read = m_buff.read(tmp.data(), tmp.size());
|
||||||
|
if (!read) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
oxAssert(read <= tmp.size(), "logger trying to read too much data");
|
||||||
|
//std::printf("LoggerConn: sending %lu bytes\n", read);
|
||||||
|
std::ignore = send(tmp.data(), read);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (std::exception const &e) {
|
||||||
|
oxErrf("Exception in logger thread: {}\n", e.what());
|
||||||
|
oxAssert(false, "logger thread exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user