Fix #747: Prevent double-close of accepted socket in HttpServer - #750
Open
NITIN9181 wants to merge 1 commit into
Open
Fix #747: Prevent double-close of accepted socket in HttpServer#750NITIN9181 wants to merge 1 commit into
NITIN9181 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #747.
Description of the fix:
This PR fixes an issue where
HttpServerwould double-close an accepted socket file descriptor. Previously, when an HTTP request finished,HttpConnection::disconnect()would close the socket, and thenSocketMonitor::drop(s)would close it again. This could result in a severe "FD theft" bug if the OS reassigned the file descriptor to a different thread in between the two closures.Changes made:
m_closedboolean flag toHttpConnectionto accurately track the connection's logical state without relying on OS-level socket closures.socket_close(m_socket)call insideHttpConnection::disconnect(). This leaves the socket open so thatSocketMonitor::drop(s)can safely close the FD exactly once.HttpConnection::read()fromreturn true;toreturn !m_closed;. This ensures the read loop gracefully terminates ifdisconnect()is called during request processing, handing control back toHttpServer::onConnect.All local tests pass, and the changes conform to the QuickFIX coding guidelines.