Skip to content

Fix ObjC server-mode premature TCP close and CI linker error#8

Merged
dustturtle merged 3 commits intomainfrom
copilot/fix-gcdasyncsocket-crash
Mar 6, 2026
Merged

Fix ObjC server-mode premature TCP close and CI linker error#8
dustturtle merged 3 commits intomainfrom
copilot/fix-gcdasyncsocket-crash

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

When used as an HTTP server (e.g. KTVHTTPCache), the socket sends a TCP FIN after every writeData: call, killing the connection before the response body is transmitted. Separately, CI fails to link due to missing Security framework.

nw_connection_send premature close

is_complete was true, signaling end-of-stream after each write. HTTP servers that send headers and body in separate writes get the connection torn down between them — client sees -1005 NSURLErrorNetworkConnectionLost.

// Before: closes write side after every send
nw_connection_send(conn, data, ctx, true, ...);

// After: stream stays open for subsequent writes
nw_connection_send(conn, data, ctx, false, ...);

disconnectAfterWriting / disconnectAfterReading were no-ops

Both just called [self disconnect] immediately, cancelling in-flight writes. Now tracks pendingWriteCount and defers teardown until the last send completion fires. Same pattern for reads via flagDisconnectAfterReads.

Missing -framework Security in CI

sec_protocol_options_set_verify_block (TLS verify block) lives in Security.framework. Added to CI build command, main.m build comment, and README.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants