Simplify process_connection_writes condition

And comment explaining that we there's something more precise but more
complex available.
This commit is contained in:
2025-09-10 16:45:04 -04:00
parent f56ed2bfbe
commit 962a010724
3 changed files with 16 additions and 15 deletions

View File

@@ -248,7 +248,7 @@ struct Connection {
}
// Match server's connection state management
bool hasMessages() const { return !request.empty(); }
bool has_messages() const { return !request.empty(); }
bool error = false;
~Connection() {
@@ -698,7 +698,7 @@ int main(int argc, char *argv[]) {
// Transfer back to epoll instance. This thread or another thread
// will wake when fd is ready
if (conn->hasMessages()) {
if (conn->has_messages()) {
events[i].events = EPOLLOUT | EPOLLONESHOT;
} else {
events[i].events = EPOLLIN | EPOLLONESHOT;
@@ -748,7 +748,7 @@ int main(int argc, char *argv[]) {
// Try to write once in the connect thread before handing off to network
// threads
assert(conn->hasMessages());
assert(conn->has_messages());
bool writeFinished = conn->writeBytes();
if (conn->error) {
continue; // Connection failed, destructor will clean up
@@ -766,7 +766,7 @@ int main(int argc, char *argv[]) {
event.events = EPOLLIN | EPOLLONESHOT;
} else {
event.events =
(conn->hasMessages() ? EPOLLOUT : EPOLLIN) | EPOLLONESHOT;
(conn->has_messages() ? EPOLLOUT : EPOLLIN) | EPOLLONESHOT;
}
// Add to a round-robin selected epoll instance to distribute load