Resolve IRC client hostnames off the accept loop (closes #156) #172

Merged
clawbot merged 1 commits from issue-156-resolve-off-accept into next 2026-10-21 03:31:28 +02:00
Collaborator

Moves the reverse DNS lookup for an IRC client out of newConn, which acceptLoop called before it could accept the next connection, to the start of serve, which runs on the connection's own goroutine. A client whose address has no answering reverse DNS now holds up only its own registration, not every other IRC connect. Fixes #156.

newConn no longer takes a context; the lookup was its only use. The server holds the lookup function in a field, set to resolveHost by New, the same way it holds the ping times, and passes it to serve. NewTestServer takes it as a parameter, and the new test helper newTestEnvWithResolver passes one through.

The new test, TestRegistrationWhileAnotherLookupIsPending, gives the server a lookup that blocks for the first client until the server stops, then checks that a second client registers and that its welcome carries the hostname its own lookup returned.

  • Judgement call: the lookup is at the top of serve, not in completeRegistration, so it runs once per connection even when a nick is refused and the client tries again; a reply to an unregistered client waits for that client's own lookup, as it did before.
  • Judgement call: the test sets the lookup before the server starts, through NewTestServer, because a field changed after Start would race with the accept loop.
  • Not reproduced against a real reverse DNS server that does not answer; the test stands in for it with a lookup that blocks.

Model: opus-5-5

Moves the reverse DNS lookup for an IRC client out of `newConn`, which `acceptLoop` called before it could accept the next connection, to the start of `serve`, which runs on the connection's own goroutine. A client whose address has no answering reverse DNS now holds up only its own registration, not every other IRC connect. Fixes https://git.eeqj.de/sneak/neoirc/issues/156. `newConn` no longer takes a context; the lookup was its only use. The server holds the lookup function in a field, set to `resolveHost` by `New`, the same way it holds the ping times, and passes it to `serve`. `NewTestServer` takes it as a parameter, and the new test helper `newTestEnvWithResolver` passes one through. The new test, `TestRegistrationWhileAnotherLookupIsPending`, gives the server a lookup that blocks for the first client until the server stops, then checks that a second client registers and that its welcome carries the hostname its own lookup returned. - Judgement call: the lookup is at the top of `serve`, not in `completeRegistration`, so it runs once per connection even when a nick is refused and the client tries again; a reply to an unregistered client waits for that client's own lookup, as it did before. - Judgement call: the test sets the lookup before the server starts, through `NewTestServer`, because a field changed after `Start` would race with the accept loop. - Not reproduced against a real reverse DNS server that does not answer; the test stands in for it with a lookup that blocks. Model: opus-5-5
clawbot added the needs-review label 2026-10-21 03:05:37 +02:00
clawbot self-assigned this 2026-10-21 03:05:37 +02:00
clawbot added 1 commit 2026-10-21 03:05:37 +02:00
acceptLoop called newConn, which did the reverse DNS lookup, with its
three-second timeout, before the loop could accept the next
connection, so one client whose address had no answering reverse DNS
held up every other IRC connect. serve now does the lookup at its
start, on the connection's own goroutine, and the accept loop only
accepts.

The server keeps the lookup function in a field, as it does the ping
times, so that a test can give it one that blocks. The new test
checks that a second client registers while the first one's lookup
has not returned.

Model: opus-5-5
Author
Collaborator

PASS

Model: opus-5-5

**PASS** Model: opus-5-5
clawbot removed the needs-review label 2026-10-21 03:29:01 +02:00
clawbot merged commit e7e408c93e into next 2026-10-21 03:31:28 +02:00
clawbot deleted branch issue-156-resolve-off-accept 2026-10-21 03:31:28 +02:00
Sign in to join this conversation.