Skip to content

complete pending uring TCP connects#1375

Open
russellromney wants to merge 2 commits into
QuarkContainer:mainfrom
russellromney:codex/soerror-complete-connect
Open

complete pending uring TCP connects#1375
russellromney wants to merge 2 commits into
QuarkContainer:mainfrom
russellromney:codex/soerror-complete-connect

Conversation

@russellromney

@russellromney russellromney commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Complete pending uring TCP connects from a shared helper before reporting socket readiness, blocking-connect completion, or SO_ERROR.

This handles the case where a nonblocking TCP connect() is still represented in Quark as TCPConnecting with cached -EINPROGRESS, while the host socket has already completed the connection.

This PR is stacked on #1373 because the regression also needs correct select(2) exception-fdset clearing.

What Changed

  • Add UringSocketOperations::CompletePendingConnect().
  • Use it from Readiness() for TCPConnecting sockets.
  • Use it from GetSockOpt(SO_ERROR) before returning cached connect state.
  • Preserve host peer address, make PostConnect() idempotent, and restore TCPInit on completed connect failure.
  • Add test/c/soerror_connect_loop.c, a loopback nonblocking-connect regression that checks successful readiness, getpeername(), and refused-connect SO_ERROR clearing.

Proof / Investigation

Diagnostic proof branch: https://github.com/russellromney/Quark/tree/codex/soerror-connect-proof

Tracking issue with the investigation notes: #1374

The proof branch shows the failure without Postgres, psycopg, or application code. It is just a loopback TCP listener and a nonblocking TCP client checking immediate SO_ERROR, select() readiness, and final SO_ERROR.

Validation

Built a qkernel from this branch on the Quark repro host, rebuilt the C regressions as Linux ELF binaries and ran the standalone C loopback regression under Docker --runtime=quark:

summary bad_immediate=0/20 bad_except=0/20 bad_missing_write=0/20 bad_after=0/20 bad_peer=0/20 child_status=0 refused_status=0

Also reran the select regression from #1373 under the same qkernel:

select rc=1 read=0 write=1 except=0 so_error=0

And reran the minimal Postgres 18 + psycopg check:

socket_summary bad_immediate=0/50 bad_select_except=0/50 bad_missing_write=0/50
psycopg_summary failures=0/20

@russellromney russellromney marked this pull request as ready for review June 15, 2026 20:56
@russellromney russellromney force-pushed the codex/soerror-complete-connect branch from 4b1b78c to 4f889cd Compare June 15, 2026 21:10
@russellromney russellromney force-pushed the codex/soerror-complete-connect branch from 4f889cd to ced4fc3 Compare June 15, 2026 21:13
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.

1 participant