21 Commits

Author SHA1 Message Date
HoneyryderChuck
4c9db6f382 added test for #365 2025-11-03 22:53:37 +00:00
HoneyryderChuck
c30197ba7d adding happy eyeballs test for native/https 2025-10-22 10:52:23 +01:00
HoneyryderChuck
3df4602211 removed needless Multi#closed?, removed callbacks from resolvers altogether 2025-10-21 09:28:12 +01:00
HoneyryderChuck
2ae162d48e native: omit name without trailing dot when ndots > 0 2025-10-20 23:46:56 +01:00
HoneyryderChuck
716e05124d fix for connection management on socket error while waiting for dns
while adding a test, several inconsistencies around socket management in
the face of an error happening during socket wait time were uncovered,
that have been fixed:

* resolver-related connections weren't transitioning to "closed" status,
  due to a lack of resetting on handling connecting errors.
* connections waiting for DNS answer weren't pinned to the session; so
  when an error happened, the pool accounting was corrupt, as it was
  still considering a connection in use; the connection is now sent back
  to the pool.
* resolver wasn't cleaning up state well, remaining open after dealing
  with a socket-level error. it now proceeds to the closed state.
* API has been aligned across connections and resolvers for error
  handling.
2025-10-20 23:04:47 +01:00
HoneyryderChuck
e2e35275af adding test to assert correct cleanup of dns candidate names resources 2025-10-20 23:04:47 +01:00
HoneyryderChuck
12d2580890 fix: close only selected connections when an error occurs during tick
this removes the exception handlers on the loop, which was buggy;
besides force-closing connections which shouldn't be closed, it'd also
do it in an unsafe, where the selector selectables would be traversed
and force closed, which mutated the selectables listed being updated
(this could leave selectables hanging there); this becomes more
problematic for persistent connections.

this was fixed by rescuing at the wait/select call level, and traversing
the list of IOs being inspected.

another fix was propagation to resolvers which hold the connections,
which was not happening in the case of forceful termination of
resolvers, which didn't implement #force_reset. This was fixed by moving
to #force_close and implementing it for resolvers, which drops
connections and propagates #force_close.
2025-10-20 23:04:47 +01:00
HoneyryderChuck
4c66f871e2 fix: do not account for coalesced connections in the pool
coalesced connections were still accounted for in counters and other
resources; now, they're forcefully dropped as soon as coalesced.
2025-10-17 18:53:43 +01:00
HoneyryderChuck
9d6b24998c fix: make sure that the native resolver picks up the next timeout of the current hostname being resolved
before, it was evaluating all names in the queue, but that was not accurate due to candidates, so there was always a candidate with a lower timeout; instead, one relies on the preexisting @name, wihch was already point to the currently being resolved name, and use it as proxy to get the correct timeotus list. This also results in performance improvement
2025-10-17 18:53:43 +01:00
HoneyryderChuck
53a3ba7037 moved logic related with supporting the fiber scheduler into its own plugin
this plugin is loaded into the persistent plugin by default, as it's already expected to work across fibers
2025-09-01 11:43:30 +01:00
HoneyryderChuck
1f9dcfb353 implement per-origin connection threshold per pool
defaulting to unbounded, in order to preserve current behaviour; this will cap the number of connections initiated for a given origin for a pool, which if not shared, will be per-origin; this will include connections from separate option profiles

a pool timeout is defined to checkout a connection when limit is reeached
2024-11-19 12:55:44 +00:00
HoneyryderChuck
5223d51475 setting the connection pool locally to the session
allowing it to be plugin extended via pool_class and PoolMethods
2024-11-19 12:55:44 +00:00
HoneyryderChuck
8ffa04d4a8 making pool class a plugin extendable class 2024-11-19 12:55:44 +00:00
HoneyryderChuck
79d5d16c1b moving session with pool test plugin to override on the session and drop pool changes 2024-11-19 12:55:44 +00:00
HoneyryderChuck
8bd4dc1fbd fix timers overhead causing spurious wakeups on the select loop
the change to read/write cancellation-driven timeouts as the default
timeout strategy revealed a performance regression; because these were
built on Timers, which never got unsubscribed, this meant that they were
kept beyond the duration of the request they were created for, and
needlessly got picked up for the next timeout tick.

This was fixed by adding a callback on timer intervals, which
unsubscribes them from the timer group when called; these would then be
activated after the timeout is not needed anymore (request send /
response received), thereby removing the overhead on subsequent
requests.

An additional intervals array is also kept in the connection itself;
timeouts from timers are signalled via socket wait calls, however they
were always resulting in timeouts, even when they shouldn't (ex: expect
timeout and send full response payload as a result), and with the wrong
exception class in some cases. By keeping intervals from its requests
around, and monitoring whether there are relevant request triggers, the
connection can therefore handle a timeout or bail out (so that timers
can fire the correct callback).
2023-10-24 22:53:22 +01:00
HoneyryderChuck
487a747544 allow reuse of previously closed connections within the scope of a session
when closed, connections are now placed in a place called eden_connections; whenever a connection is matched for, after checking the live connections and finding none, a match is looked in eden connections; the match is accepted **if** the IP is considered fresh (the input is validated in the cache, or input was an ip or in /etc/hosts, or it's an external socket) and, if a TLS connection, the stored TLS session did not expire; if these conditions do not match, the connection is dropped from the eden and a new connection will started instead; this will therefore allow reusing ruby objects, reusing TLS sessions, and still respect the DNs cache
2023-09-06 22:09:56 +01:00
HoneyryderChuck
c1281a9074 native resolver: switch from nameserver if dns query fails
a behaviour has been observed behind a vpn, where when one of the
servers is unresponsive, the switch to the next nameserver wasn't
happening. Part of it was a bug in the timeout handling, but the rest
was actually the switch not happening (i.e. it'd fail on the first
server). This fixes it by switching to the next nammeserver on query
error.
2022-09-20 23:11:08 +01:00
HoneyryderChuck
edf7357a5f improved persistent plugin test, in order to test not only the number of connections kept, but the ones actually being used for selecting (connections with no request shouldn't) 2021-09-25 00:44:31 +01:00
HoneyryderChuck
a6176ec01f using session pool for coalescing test, thereby minimizing interference (although it would have been nice to have more entropy) 2021-01-05 10:38:28 +00:00
HoneyryderChuck
e6c9bb4714 fix: http/1.1 recover from connection exhausted
While adding the test, the code to recover from an exhausted HTTP/1.1
connection proved not to be reliable, as it wasn't taking inflight
requests nor update-once keep-alive max requests counters into
account.

This has been fixed by implementing our own test dummy using
webrick.
2020-11-26 20:11:30 +00:00
HoneyryderChuck
2a49fbc78f moved custom plugins used in tests to the support dir 2020-10-31 01:07:26 +00:00