-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after async_read resulting in a timeout, calling async_write causes a read access violation when using a strand #2952
Comments
You need to update the internal timeout after the fist expiration by calling |
Thanks @ashtum that seems to work. I must have missed that when reading the docs. Can you point me to it? |
|
According to the above, when a timeout occurs while
What does that mean exactly? Does that mean that I should be able to call In the example above the behavior is different when using a strand and not using one. I did not expect a access violation when initiating a read or write after a timeout but instead just a timeout error as is the case if I don't use the strand. |
Sorry, I mistakenly assumed you were checking
When you set an expiration time, it applies to all async operations initiated after that, not just one. To extend the timeout, you need to set a new expiration time before each operation.
It seems you're encountering this issue: #2925. It's already fixed and will be included in the next Boost release (Boost 1.87). |
I was attempting to return nice error responses for certain errors. For example i'd like to return a 408 when a timeout occurs. However it seems to also close the socket.
While testing this out I ran into a access violation in
boost::asio::detail::strand_executor_service::enqueue
while acquiring a mutex lock and it seems the strand is already destructed (impl
isnullptr
). When not using a strand the nextasync_write
simply also returns the same error. I've tried different completion tokens but that doesn't change the result. It looks like the strand is cleaned up together with the socket so I guess I either need to:stream.expires_after
so it keeps the socket aliveIs this a bug in either beast or asio or am I using the strands wrong. I used https://www.boost.org/doc/libs/1_86_0/libs/beast/example/advanced/server-flex-awaitable/advanced_server_flex_awaitable.cpp for inspiration.
The text was updated successfully, but these errors were encountered: