A better with_timeout
feature?
#3029
Closed
niekbouman
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Can you show how it's intended to be used? |
Beta Was this translation helpful? Give feedback.
1 reply
-
The way it's done now is to set up a timer and trigger the abort_source or socket shutdowns from the timer. Then co_await the computation you want, and immediately cancel the timer. Seems simpler, no? timer<> timeout_timer([&] {
stream->shutdown_input(); // this should trigger an exception
stream->shutdown_output(); // in the TLS handshake
});
timeout_timer.arm(5s);
auto cert_chain = co_await seastar::tls::get_peer_certificate_chain(stream->socket), &abort_source);
timeout_timer.cancel(); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A problem with Seastar's current
with_timeout
API is that the future becomes orphaned upon timeout.An alternative implementation, which also features optional abort, is the following.
@avikivity Would this code be welcomed as a PR?
Beta Was this translation helpful? Give feedback.
All reactions