asio
asio copied to clipboard
In multithreading and high concurrency environment, async_accept`s callback handler does not release smart pointer
Test 4 clients, each 100 threads, transmission 10000 files,finally, more than ten files were lost.
Add trace log for each connect, found that:
in multithreading and high concurrency environment, the lost error, async_accepts callback handlers had not been called, and the smart pointer cant be released.
void FtpSession::receiveFile(std::shared_ptr<IoFile> file)
{
auto data_socket = std::make_sharedasio::ip::tcp::socket(io_service_);
auto me = shared_from_this();
// 没有释放的文件很有可能卡在这里面了:
data_acceptor_.async_accept(*data_socket
, [data_socket, file, me](auto ec)
{ // trace log }; }