Skip to content

Commit 74e19df

Browse files
committed
Restore read interest after an asynchronous 100 Continue
addSocket() replaces the reactor interest set rather than adding to it, so the would-block path added in this PR leaves a socket registered for writability only. Every other sending state either keeps sending or re-registers Readable once it finishes, but Sending100Continue moved to ReceivingBody without doing so and then returned to wait for a request body it could no longer be woken for. On Linux that is a busy loop on a level-triggered EPOLLOUT with the body never read: an epoll probe registering only EPOLLOUT reports EPOLLOUT on every wait and never EPOLLIN, even with readable bytes already pending. On Windows there is no further FD_WRITE, so the request stalls. The trigger is narrow because it needs a 25 byte interim response to block on a fresh connection, but the interest set is now restored explicitly rather than by luck. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent b48b268 commit 74e19df

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎ext/include/opentelemetry/ext/http/server/http_server.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,13 @@ class HttpServer : private SocketTools::Reactor::SocketCallback
506506
return;
507507
}
508508

509+
// addSocket() replaces the interest set rather than adding to it, so a would-block
510+
// while sending the interim response leaves the socket registered for writability
511+
// only. Restore read interest before going back to waiting for the request body:
512+
// this is the one transition from a sending state to a receiving one, and the
513+
// keep-alive path at the end of SendingBody already does the same thing.
514+
m_reactor.addSocket(conn.socket,
515+
SocketTools::Reactor::Readable | SocketTools::Reactor::Closed);
509516
conn.state = Connection::ReceivingBody;
510517
LOG_TRACE("HttpServer: [%s] receiving body", conn.request.client.c_str());
511518
}

0 commit comments

Comments
 (0)