mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-11-27 00:03:01 -05:00
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.
70 lines
1.7 KiB
Plaintext
70 lines
1.7 KiB
Plaintext
module HTTPX
|
|
interface _Selectable
|
|
def state: () -> Symbol
|
|
|
|
def to_io: () -> IO
|
|
|
|
def call: () -> void
|
|
|
|
def interests: () -> io_interests?
|
|
|
|
def timeout: () -> Numeric?
|
|
|
|
def handle_socket_timeout: (Numeric interval) -> void
|
|
|
|
def on_error: (StandardError) -> void
|
|
end
|
|
|
|
class Selector
|
|
type selectable = Resolver::Resolver | Connection | (Object & _Selectable)
|
|
|
|
type io_select_selectable = (selectable | Array[selectable])?
|
|
|
|
include _Each[selectable]
|
|
|
|
extend Forwardable
|
|
|
|
READABLE: Array[io_interests]
|
|
WRITABLE: Array[io_interests]
|
|
|
|
@timers: Timers
|
|
|
|
@selectables: Array[selectable]
|
|
@is_timer_interval: bool
|
|
|
|
def next_tick: () -> void
|
|
|
|
def terminate: () -> void
|
|
|
|
def find_resolver: (Options options) -> Resolver::Resolver?
|
|
|
|
def find_connection: (http_uri request_uri, Options options) -> Connection?
|
|
|
|
def each_connection: () { (Connection) -> void} -> void
|
|
| () -> Enumerable[Connection]
|
|
|
|
def find_mergeable_connection: (Connection connection) -> Connection?
|
|
|
|
def empty?: () -> bool
|
|
|
|
def register: (selectable io) -> void
|
|
|
|
def deregister: (selectable io) -> selectable?
|
|
|
|
private
|
|
|
|
def initialize: () -> void
|
|
|
|
def select: (Numeric? interval) { (selectable) -> void } -> void
|
|
|
|
def select_many: (io_select_selectable r, io_select_selectable w, Numeric? interval) { (selectable) -> void } -> void
|
|
|
|
def select_one: (selectable io, io_interests interests, Numeric? interval) { (selectable) -> void } -> void
|
|
|
|
def next_timeout: () -> Numeric?
|
|
|
|
def rw_wait: (io_select_selectable IO, Numeric? interval) -> untyped?
|
|
end
|
|
|
|
type io_interests = :r | :w | :rw
|
|
end |