Closed qicosmos closed 7 months ago
I have compiled and installed io_uring(https://github.com/axboe/liburing/releases/tag/liburing-2.3) on ubuntu20.04, and test stream_file according asio unit tests, but always failed.
cmake setting:
add_definitions(-DASIO_HAS_FILE) add_definitions(-DASIO_HAS_IO_URING) #... target_link_libraries(test_asio_uring uring)
code:
#include <asio/io_context.hpp> #include <asio/random_access_file.hpp> #include <asio/stream_file.hpp> #include <iostream> #include <string> using namespace asio; void test_async_read() { asio::io_context ioc; try { stream_file file(ioc, "/tmp/test.txt", stream_file::read_only); // the file exists and has contents. char data[128]= {}; file.async_read_some(buffer(data), [data](asio::error_code ec, size_t size) { std::cout << ec.message() << " " << size << "\n"; }); ioc.run(); } catch (std::exception &e) { std::cout << e.what() << "\n"; } } int main(int, char **) { test_async_read(); }
Am i missed something? Anyone else meet the problem?
I know what's the problem, ubuntu20.04 default kernel version is 5.4, don't support io_uring. upgrade kernel version(5.10 above) , the test code pass.
I have compiled and installed io_uring(https://github.com/axboe/liburing/releases/tag/liburing-2.3) on ubuntu20.04, and test stream_file according asio unit tests, but always failed.
cmake setting:
code:
Am i missed something? Anyone else meet the problem?