Skip to content

Commit

Permalink
fix(SocketReactorTest): deadlock test intermittently hangs #4400
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Jan 17, 2024
1 parent f13d492 commit 8b29c36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Net/src/SocketReactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Poco {
namespace Net {


SocketReactor::SocketReactor():
SocketReactor::SocketReactor(): _threadAffinity(-1),
_stop(false),
_pReadableNotification(new ReadableNotification(this)),
_pWritableNotification(new WritableNotification(this)),
Expand Down Expand Up @@ -86,6 +86,7 @@ void SocketReactor::run()
if (hasSocketHandlers())
{
sm = _pollSet.poll(_params.pollTimeout);
if (_stop) break;
for (const auto& s : sm)
{
try
Expand Down Expand Up @@ -167,7 +168,6 @@ void SocketReactor::stop()

void SocketReactor::wakeUp()
{
if (_stop) return;
_pollSet.wakeUp();
_event.set();
}
Expand Down
12 changes: 7 additions & 5 deletions Net/testsuite/src/SocketReactorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,14 @@ namespace
void onReadable(ReadableNotification* pNf)
{
pNf->release();
char buffer[64];
do
std::vector<char> buffer;
int n = 0;
while ((n = _socket.available()))
{
if (0 == _socket.receiveBytes(&buffer[0], sizeof(buffer)))
break;
} while (true);
if (n > buffer.size()) buffer.resize(n);
n = _socket.receiveBytes(&buffer[0], buffer.size());
if (0 == n) break;
}
}

void onShutdown(ShutdownNotification* pNf)
Expand Down
3 changes: 1 addition & 2 deletions cppignore.win
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CppUnit::TestCaller<class RawSocketTest>.testEchoIPv4Move
class CppUnit::TestCaller<class ICMPClientTest>.testPing
class CppUnit::TestCaller<class ICMPClientTest>.testBigPing
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy
class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
class CppUnit::TestCaller<class TCPServerTest>.testReuseSocket
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testInterop
class CppUnit::TestCaller<class PathTest>.testFind
Expand All @@ -21,4 +21,3 @@ class CppUnit::TestCaller<class WinServiceTest>.testServiceReturnsTrueIfStopped
class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom
class CppUnit::TestCaller<class ICMPSocketTest>.testMTU
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testCachedSession
class CppUnit::TestCaller<class PollSetTest>.testPollClosedServer

0 comments on commit 8b29c36

Please sign in to comment.