Crash : terminate called after throwing an instance of 'std::system_error' what(): Resource deadlock avoided

跟風遠走 提交于 2019-12-01 12:30:41

@sehe .. can you run the code and let me know how to overcome the crash that I mentioned ? – Nishant Sharma

Actually, no I won't. The problem has already been analyzed: you can't join the current thread (it would deadlock).

But I can do something better:

Grabbing my crystal ball, I can guess you got this example from a particular book, named Boost.Asio C++ Network Programming Cookbook¹, around page 139.

I recognized it after a while when I added up all the code smells (delete this and m_stop.load() tipped me over the edge).

The good news is, I reviewed that code before:

ASIO example code closing socket before it should

You can probably profit from the particular comments I made there.

¹ from packtpub: https://www.packtpub.com/application-development/boostasio-c-network-programming-cookbook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!