Skip to content

fix(conn): remove a connection from the pool when it is reused - #574

Merged
Mzack9999 merged 1 commit into
projectdiscovery:mainfrom
hakarrr:fix/dialer-pool-pop
Dec 2, 2026
Merged

Mzack9999 merged 1 commit into
projectdiscovery:mainfrom
hakarrr:fix/dialer-pool-pop

Conversation

@hakarrr

@hakarrr hakarrr commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #573

Proposed changes

dialer.dialTimeout took a pooled connection with c[0] and overwrote it with the last entry but never shrank the slice in d.conns[addr]. The connection stayed in the pool, so later Dial calls to the same address got the same Conn again, and with several pooled connections one was duplicated and the rest lost.

The last pooled connection is now popped and the slice is shortened, so a connection is only handed out to one caller until Release returns it. Adds TestDialerReusesPooledConnOnce in conn_pool_test.go, which fails without the change (the pool still holds both connections after two dials) and passes with it. go test . passes.

Fixes projectdiscovery#573

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
@Mzack9999
Mzack9999 merged commit 0257721 into projectdiscovery:main Dec 2, 2026
8 checks passed
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.

Connection pool hands out the same connection repeatedly and never removes it

2 participants