fix(SocketReactorTest): deadlock test intermittently hangs #4400 (#4401)

This commit is contained in:
Aleksandar Fabijanic 2024-01-17 09:20:20 +01:00 committed by GitHub
parent 9f4b1b7df4
commit b0dc9c5a82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 9 deletions

View File

@ -27,7 +27,7 @@ namespace Poco {
namespace Net { namespace Net {
SocketReactor::SocketReactor(): SocketReactor::SocketReactor(): _threadAffinity(-1),
_stop(false), _stop(false),
_pReadableNotification(new ReadableNotification(this)), _pReadableNotification(new ReadableNotification(this)),
_pWritableNotification(new WritableNotification(this)), _pWritableNotification(new WritableNotification(this)),
@ -86,6 +86,7 @@ void SocketReactor::run()
if (hasSocketHandlers()) if (hasSocketHandlers())
{ {
sm = _pollSet.poll(_params.pollTimeout); sm = _pollSet.poll(_params.pollTimeout);
if (_stop) break;
for (const auto& s : sm) for (const auto& s : sm)
{ {
try try
@ -167,7 +168,6 @@ void SocketReactor::stop()
void SocketReactor::wakeUp() void SocketReactor::wakeUp()
{ {
if (_stop) return;
_pollSet.wakeUp(); _pollSet.wakeUp();
_event.set(); _event.set();
} }

View File

@ -416,12 +416,14 @@ namespace
void onReadable(ReadableNotification* pNf) void onReadable(ReadableNotification* pNf)
{ {
pNf->release(); pNf->release();
char buffer[64]; std::vector<char> buffer;
do int n = 0;
while ((n = _socket.available()))
{ {
if (0 == _socket.receiveBytes(&buffer[0], sizeof(buffer))) if (n > buffer.size()) buffer.resize(n);
break; n = _socket.receiveBytes(&buffer[0], buffer.size());
} while (true); if (0 == n) break;
}
} }
void onShutdown(ShutdownNotification* pNf) void onShutdown(ShutdownNotification* pNf)

View File

@ -6,7 +6,7 @@ class CppUnit::TestCaller<class RawSocketTest>.testEchoIPv4Move
class CppUnit::TestCaller<class ICMPClientTest>.testPing class CppUnit::TestCaller<class ICMPClientTest>.testPing
class CppUnit::TestCaller<class ICMPClientTest>.testBigPing class CppUnit::TestCaller<class ICMPClientTest>.testBigPing
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy 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 TCPServerTest>.testReuseSocket
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testInterop class CppUnit::TestCaller<class HTTPSClientSessionTest>.testInterop
class CppUnit::TestCaller<class PathTest>.testFind class CppUnit::TestCaller<class PathTest>.testFind
@ -21,4 +21,3 @@ class CppUnit::TestCaller<class WinServiceTest>.testServiceReturnsTrueIfStopped
class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom
class CppUnit::TestCaller<class ICMPSocketTest>.testMTU class CppUnit::TestCaller<class ICMPSocketTest>.testMTU
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testCachedSession class CppUnit::TestCaller<class HTTPSClientSessionTest>.testCachedSession
class CppUnit::TestCaller<class PollSetTest>.testPollClosedServer