Fix `Connection_cache.call` hanging on unreachable server
* What
The `Connection_cache.call` function could hang indefinitely when
attempting to establish a connection to an unreachable server. This
change resolves that issue by ensuring that the connection creation
process is asynchronous and non-blocking.
* Why
Previously, the `Connection.create` function returns before the
connection is established. When the returned connection is binded,
something in the code of `get_connection` prevents the correct handling
of the `ECONNREFUSED` Unix error.
* How
The `create` helper function now uses `Connection.connect` (which
returns an Lwt promise) and binds its result using `>>=`. This
transforms the `create` function itself into an Lwt promise.
Consequently, the `Connection_cache.call` function no longer blocks on
connection establishment but rather awaits the connection promise.
4e3d3f
-
-
Jun 17 18:26 +00:00