Net: consume read/write/send results in the HTTP server (VL-NET-W01)
This commit is contained in:
1 parent
08a40ad5fc
commit
2c8d853af0
1 file changed
+14
-4
+14
-4
@@ -2516,7 +2516,11 @@ namespace Void::Net
|
||||
}
|
||||
if ((pfds[1].revents & POLLIN) != 0) {
|
||||
std::uint64_t val = 0;
|
||||
(void)::read(wake_fd, &val, sizeof(val));
|
||||
// Best effort: the eventfd is only a wakeup hint and the
|
||||
// stopping flag is authoritative, but consume the result so
|
||||
// fortified headers do not raise -Wunused-result.
|
||||
[[maybe_unused]] const ssize_t drained =
|
||||
::read(wake_fd, &val, sizeof(val));
|
||||
}
|
||||
if (stopping.load(std::memory_order_acquire)) {
|
||||
break;
|
||||
@@ -2555,8 +2559,11 @@ namespace Void::Net
|
||||
"Content-Length: 19\r\n"
|
||||
"Connection: close\r\n\r\n"
|
||||
"Service Unavailable";
|
||||
(void)::send(client_fd, busy.data(), busy.size(),
|
||||
MSG_NOSIGNAL);
|
||||
// The connection is closed regardless of whether the
|
||||
// 503 could be delivered; consume the result explicitly.
|
||||
[[maybe_unused]] const ssize_t sent =
|
||||
::send(client_fd, busy.data(), busy.size(),
|
||||
MSG_NOSIGNAL);
|
||||
(void)::close(client_fd);
|
||||
continue;
|
||||
}
|
||||
@@ -2590,7 +2597,10 @@ namespace Void::Net
|
||||
stopping.store(true, std::memory_order_release);
|
||||
if (wake_fd >= 0) {
|
||||
const std::uint64_t one = 1;
|
||||
(void)::write(wake_fd, &one, sizeof(one));
|
||||
// Best effort wakeup: the accept loop also polls with a
|
||||
// timeout, so a full eventfd cannot delay shutdown.
|
||||
[[maybe_unused]] const ssize_t signalled =
|
||||
::write(wake_fd, &one, sizeof(one));
|
||||
}
|
||||
if (accept_thread.joinable()) {
|
||||
accept_thread.join();
|
||||
|
||||
Reference in new issue
Block a user