forked from boostorg/beast
Add asio_handler_invoke overloads for stream algorithms:
fix #1012 This fixes a bug where asynchronous stream alogrithms do not work correctly with the legacy `io_service::strand` implementation.
This commit is contained in:
1 parent
2543dbe5b9
commit
726118468b
27 files changed
+483
-5
No files matched your search
@@ -22,6 +22,8 @@
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -857,6 +859,49 @@ public:
|
||||
ioc.run();
|
||||
}
|
||||
|
||||
struct copyable_handler
|
||||
{
|
||||
template<class... Args>
|
||||
void
|
||||
operator()(Args&&...) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
testAsioHandlerInvoke()
|
||||
{
|
||||
// make sure things compile, also can set a
|
||||
// breakpoint in asio_handler_invoke to make sure
|
||||
// it is instantiated.
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::io_service::strand s{ioc};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<empty_body> m;
|
||||
request_serializer<empty_body, fields> sr{m};
|
||||
async_write_some(ts, sr, s.wrap(copyable_handler{}));
|
||||
}
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::io_service::strand s{ioc};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<empty_body> m;
|
||||
request_serializer<empty_body, fields> sr{m};
|
||||
async_write(ts, sr, s.wrap(copyable_handler{}));
|
||||
}
|
||||
{
|
||||
boost::asio::io_context ioc;
|
||||
boost::asio::io_service::strand s{ioc};
|
||||
test::stream ts{ioc};
|
||||
flat_buffer b;
|
||||
request<empty_body> m;
|
||||
async_write(ts, m, s.wrap(copyable_handler{}));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -878,6 +923,7 @@ public:
|
||||
testWriteStream<test_body< true, false>>(yield);
|
||||
testWriteStream<test_body< true, true>>(yield);
|
||||
});
|
||||
testAsioHandlerInvoke();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user