http_client: don't arm the websocket timeout after a failed connect #204
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:http-ws-stray-timer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Follow-up to #184.
start_ws_connection()armed its timer afterresolve_and_connect()even when the connection had already failed inside it (connect()refused at once,socket()or TLS setup failing) and its callback had run. Nothing cleared that timer. When it fired, it closed whatever the client was doing then and failed the client's next request with "Websocket connection timed out".The etcd watcher reaches this path: when a live watch disconnects, its callback opens the next websocket on the same client at once, from inside the failed open.
The timer is now armed only while the connection is in flight, as
send_request()does since #184: the client still holds the callback, and no other timer is armed.Tested:
test_http_clientnow runs its check in three cases: a failed request, a failed request whose callback sends the next one, and a failed websocket open. It also ends the second request early and checks that only the third request's own timeout ends it, which catches a second timer armed for one request. Against current master the websocket case fails; with the fix all three pass. The second case covers thetimeout_id < 0clause from #184, which the old test didn't exercise.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA