Etan Kissling dedd7cb1d0
Guarantee exclusive use of HttpClientConnection. (#273)
When calling the HTTP `send` / `open` functions, `acquireConnection` is
called to obtain a connection in state `Ready`. In the next code block,
the connection state is advanced to `RequestHeadersSending`. However,
returning from chronos `async` procs yields control, similar to `await`.
This means that a connection may be added to the pool in `Ready` state,
and then a different `acquireConnection` call may obtain a second ref.
Introducing a new `Acquired` state ensures consistency in this case.

No tests added due to this being scheduler dependent; ran manual tests
by adding a `doAssert item.state != HttpClientConnectionState.Acquired`
between `if not(isNil(conn)):` and `return conn`. Eventually, the assert
got hit after several hours of repeated tests, confirming the edge case
to be solved by applying this fix.

Not sure if it is by design that returning from an `async` proc yields.
Even if it's not, this should solve current HTTP issues in nimbus-eth2.
2022-05-13 02:54:34 +03:00
..
2022-01-04 23:14:30 +01:00
2021-03-24 10:08:33 +01:00
2021-12-10 11:19:14 +01:00
2021-11-20 01:30:23 +01:00
2022-01-04 18:00:17 +01:00
2022-01-04 18:00:17 +01:00
2021-09-15 16:55:15 +03:00
2021-03-24 10:08:33 +01:00
2021-03-24 10:08:33 +01:00