Asio SSL client timeout/error-handling patch. Make POSIX signal-friendly interface.#356
Asio SSL client timeout/error-handling patch. Make POSIX signal-friendly interface.#356officer-34762 wants to merge 2 commits into
Conversation
reo7sp
left a comment
There was a problem hiding this comment.
There are several blocking correctness issues in the current implementation:
- The minimum supported Boost 1.65.1 build does not compile.
- DNS resolution is still synchronous and outside the timeout/cancellation path.
launch_once()does not make its timeout effective at the HTTP transport layer.
The public API shown in the PR description also cannot be called with the provided initializer-list example. Please address these points and add coverage for the minimum Boost version and timeout paths.
| boost::asio::steady_timer timer(io_context_); | ||
| timer.expires_from_now(dur); | ||
|
|
||
| bool timed_out = false; |
There was a problem hiding this comment.
dur is undefined, so the Boost 1.65.1 build fails. Did you mean timeout?
Replacing with shorter, line-specific comments.
| boost::asio::steady_timer timer(io_context_); | ||
| timer.expires_from_now(dur); | ||
|
|
||
| bool timed_out = false; |
There was a problem hiding this comment.
dur is undefined. This does not compile with Boost < 1.66. Use timeout here.
| // confirm handled updates | ||
| _updates = _api->getUpdates(_lastUpdateId, limit, timeout, allowUpdates); | ||
| } | ||
|
|
There was a problem hiding this comment.
timeout is passed to Telegram, but the HTTP client still uses the timeout set in the constructor. Update _httpClient._timeout here too, otherwise launch_once(..., 50, ...) can still fail after the old timeout.
| void start(); | ||
| void launch_once(std::int32_t limit, std::int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowUpdates); | ||
|
|
||
| private: |
There was a problem hiding this comment.
The example from the PR description cannot call this with {"inline_query", "callback_query"}. Consider accepting std::vector<std::string> or provide an overload.
Hi. First of all, I updated ssl client using boost asio to handle timeout of read-write/connect more carefully also throwing detailed errors. Second,
launch_oncefunction was created to customize limit/timeout values and allowed notify types array without new object creation. Instead of creatingTgLongPollobject every time so as to change values of argumentsstartfunction in an every cycle of a loop i can make launch_once call with another values.Next you got like this in your samples:
I have to get special processing on signal fired so i can't just do what i would want and call
exit(0)because it's recommended to use async thread safe only functions in such handlers. And more,long_poll.start()might freeze if i get unstable network connection and an application receive a signal. This is my walkthrough of how I achieved this:I tried to save support of Asio library from Boost 1.65.1 version. Though i didn't check working it!