Separate Connection and Request lifetimes

This commit is contained in:
2025-09-14 15:04:37 -04:00
parent cf0c1b7cc2
commit 16c7ee0408
14 changed files with 519 additions and 381 deletions

View File

@@ -297,7 +297,7 @@ struct Connection {
}
}
bool writeBytes() {
bool write_bytes() {
for (;;) {
assert(!request.empty());
int w = send(fd, request.data(), request.size(), MSG_NOSIGNAL);
@@ -672,7 +672,7 @@ int main(int argc, char *argv[]) {
continue; // Let unique_ptr destructor clean up
}
if (events[i].events & EPOLLOUT) {
bool finished = conn->writeBytes();
bool finished = conn->write_bytes();
if (conn->error) {
continue;
}
@@ -748,14 +748,14 @@ int main(int argc, char *argv[]) {
// Try to write once in the connect thread before handing off to network
// threads
assert(conn->has_messages());
bool writeFinished = conn->writeBytes();
bool write_finished = conn->write_bytes();
if (conn->error) {
continue; // Connection failed, destructor will clean up
}
// Determine the appropriate epoll events based on write result
struct epoll_event event{};
if (writeFinished) {
if (write_finished) {
// All data was written, wait for response
int shutdown_result = shutdown(conn->fd, SHUT_WR);
if (shutdown_result == -1) {