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

后端 未结 1 1757
不思量自难忘°
不思量自难忘° 2021-01-14 23:30

I have a simple client /server application the code of which is mentioned below. Please run the server in one shell and the client in another shell in linux. First start t

相关标签:
1条回答
  • 2021-01-15 00:14

    @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

    0 讨论(0)
提交回复
热议问题