Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swarm/one_shot: Initialize handler with KeepAlive::Until (#1698)
* swarm/one_shot: Add test for not keeping alive idle connection A `OneShotHandler` without any ongoing requests should not keep the underlying connection alive indefinitely. * swarm/one_shot: Initialize handler with KeepAlive::Until The `OneShotHandler` `keep_alive` property is altered on incoming and outgoing reqeusts. By default it is initialized in `KeepAlive::Yes`. In case there are no incoming or outgoing requests happening, this state is never changed and thus the handler keeps the underlying connection alive indefinitely. With this commit the handler is initialized with `KeepAlive::Until`. As before the `keep_alive` timer is updated on incoming requests and set to `KeepAlive::Yes` on outgoing requests. * swarm/one_shot: Move KeepAlive logic to poll A `ProtocolsHandler` can be created before the underlying connection is established. Thus setting a keep alive timeout might be problematic. Instead set `keep_alive` to `Yes` at construction and alter it within `ProtocolsHandler::poll`. * swarm/CHANGELOG: Add entry for OneShotHandler keep-alive
- Loading branch information