-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Expected behavior
Deadlock occurs when the SocketConnector object is destructed
Steps to reproduce the problem
Please allow me to post my code and stack diagram. To protect privacy, allow me to use ip and port instead of real data.
class ClientServiceHandler
{
public:
ClientServiceHandler(Poco::Net::StreamSocket& socket, Poco::Net::SocketReactor& reactor)
{
Poco::Thread::sleep(500); //Just to better reproduce the problem
}
};
...
//test main
while (1)
{
Poco::Net::SocketReactor reactor;
auto sc = new Poco::Net::SocketConnector<ClientServiceHandler>(Poco::Net::SocketAddress(ip, port), reactor);
Poco::Thread thread;
thread.startFunc([&reactor]() {reactor.run(); });
Poco::Thread::sleep(50);
delete sc;
poco_information(Poco::Logger::root(), "finish!");
}
As shown in the figure above, there are two threads. The thread above executes the destructor, and the thread below is the onWriteable after the connection is successful.
Boxes of the same color compete for the same lock. A sequence number indicates the sequence in which the program runs
POCO version
1.9.1
Compiler and version
VS2017
Operating system and version
Windows 10
Could it be a problem with my usage? It's important to me to be grateful that someone pointed out my mistake or fixed this bug.
Reactions are currently unavailable
