Servd: Disable signal on send failure

master
Kyle Schwarz 2026-06-18 10:21:35 -04:00
parent 44d0e3de64
commit 4dd97f734a
2 changed files with 13 additions and 1 deletions

View File

@ -137,6 +137,9 @@ public:
if (::poll(&pfd, 1, static_cast<int>(timeout.count())) == -1) {
return false;
}
if (pfd.revents & (POLLHUP | POLLERR)) {
return false;
}
in = pfd.revents & POLLIN;
return true;
#endif
@ -155,7 +158,12 @@ public:
}
bool send(const void* buffer, size_t size) {
auto sent = ::send(mFD, (const char*)buffer, (int)size, 0);
#ifdef _WIN32
int flags = 0;
#else
int flags = MSG_NOSIGNAL;
#endif
auto sent = ::send(mFD, (const char*)buffer, (int)size, flags);
if(sent == -1) {
return false;
}

View File

@ -113,6 +113,10 @@ bool Servd::open() {
return false;
}
const auto tokens = split(response);
if(tokens.size() == 1 && tokens[0] == "0") {
EventManager::GetInstance().add(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
return false;
}
if(tokens.size() != 2) {
EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error);
return false;