mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-17 23:57:14 +02:00
Update POCO to 1.11.0
This commit is contained in:
11
vendor/POCO/Net/testsuite/src/DNSTest.cpp
vendored
11
vendor/POCO/Net/testsuite/src/DNSTest.cpp
vendored
@ -88,6 +88,17 @@ void DNSTest::testHostByAddress()
|
||||
|
||||
void DNSTest::testResolve()
|
||||
{
|
||||
HostEntry he1 = DNS::hostByName("localhost");
|
||||
|
||||
auto a = he1.addresses();
|
||||
sort(a.begin(), a.end());
|
||||
auto itA = std::unique(a.begin(), a.end());
|
||||
assertTrue (itA == a.end());
|
||||
|
||||
auto b = he1.aliases();
|
||||
sort(b.begin(), b.end());
|
||||
auto itB = std::unique(b.begin(), b.end());
|
||||
assertTrue (itB == b.end());
|
||||
}
|
||||
|
||||
|
||||
|
19
vendor/POCO/Net/testsuite/src/EchoServer.cpp
vendored
19
vendor/POCO/Net/testsuite/src/EchoServer.cpp
vendored
@ -23,7 +23,8 @@ using Poco::Net::SocketAddress;
|
||||
EchoServer::EchoServer():
|
||||
_socket(SocketAddress()),
|
||||
_thread("EchoServer"),
|
||||
_stop(false)
|
||||
_stop(false),
|
||||
_done(false)
|
||||
{
|
||||
_thread.start(*this);
|
||||
_ready.wait();
|
||||
@ -33,7 +34,8 @@ EchoServer::EchoServer():
|
||||
EchoServer::EchoServer(const Poco::Net::SocketAddress& address):
|
||||
_socket(address),
|
||||
_thread("EchoServer"),
|
||||
_stop(false)
|
||||
_stop(false),
|
||||
_done(false)
|
||||
{
|
||||
_thread.start(*this);
|
||||
_ready.wait();
|
||||
@ -78,5 +80,18 @@ void EchoServer::run()
|
||||
}
|
||||
}
|
||||
}
|
||||
_done = true;
|
||||
}
|
||||
|
||||
|
||||
void EchoServer::stop()
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
bool EchoServer::done()
|
||||
{
|
||||
return _done;
|
||||
}
|
||||
|
||||
|
11
vendor/POCO/Net/testsuite/src/EchoServer.h
vendored
11
vendor/POCO/Net/testsuite/src/EchoServer.h
vendored
@ -36,15 +36,22 @@ public:
|
||||
Poco::UInt16 port() const;
|
||||
/// Returns the port the echo server is
|
||||
/// listening on.
|
||||
|
||||
|
||||
void run();
|
||||
/// Does the work.
|
||||
|
||||
|
||||
void stop();
|
||||
/// Sets the stop flag.
|
||||
|
||||
bool done();
|
||||
/// Retruns true if if server is done.
|
||||
|
||||
private:
|
||||
Poco::Net::ServerSocket _socket;
|
||||
Poco::Thread _thread;
|
||||
Poco::Event _ready;
|
||||
bool _stop;
|
||||
bool _done;
|
||||
};
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ void MulticastSocketTest::testMulticast()
|
||||
assertTrue (std::string(buffer, n) == "hello");
|
||||
ms.close();
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
|
@ -75,7 +75,7 @@ void NetworkInterfaceTest::testMap()
|
||||
std::cout << "=============" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -119,7 +119,7 @@ void NetworkInterfaceTest::testList()
|
||||
std::cout << "==============" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -139,7 +139,7 @@ void NetworkInterfaceTest::testForName()
|
||||
assertTrue (ifc.name() == it->second.name());
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -184,7 +184,7 @@ void NetworkInterfaceTest::testForAddress()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -204,7 +204,7 @@ void NetworkInterfaceTest::testForIndex()
|
||||
assertTrue (ifc.index() == it->second.index());
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -231,7 +231,7 @@ void NetworkInterfaceTest::testMapIpOnly()
|
||||
std::cout << "MAC Address:" << mac << std::endl;
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -251,7 +251,7 @@ void NetworkInterfaceTest::testMapUpOnly()
|
||||
assertTrue (it->second.isUp());
|
||||
}
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
@ -298,7 +298,7 @@ void NetworkInterfaceTest::testListMapConformance()
|
||||
|
||||
assertTrue (counter == l.size());
|
||||
}
|
||||
catch (Poco::NotImplementedException e)
|
||||
catch (Poco::NotImplementedException&)
|
||||
{
|
||||
#if POCO_OS != POCO_OS_ANDROID
|
||||
throw;
|
||||
|
77
vendor/POCO/Net/testsuite/src/PollSetTest.cpp
vendored
77
vendor/POCO/Net/testsuite/src/PollSetTest.cpp
vendored
@ -28,6 +28,7 @@ using Poco::Net::ConnectionRefusedException;
|
||||
using Poco::Net::PollSet;
|
||||
using Poco::Timespan;
|
||||
using Poco::Stopwatch;
|
||||
using Poco::Thread;
|
||||
|
||||
|
||||
PollSetTest::PollSetTest(const std::string& name): CppUnit::TestCase(name)
|
||||
@ -76,7 +77,7 @@ void PollSetTest::testPoll()
|
||||
assertTrue (sm.find(ss1) != sm.end());
|
||||
assertTrue (sm.find(ss2) == sm.end());
|
||||
assertTrue (sm.find(ss1)->second == PollSet::POLL_WRITE);
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
assertTrue (sw.elapsed() < 1100000);
|
||||
|
||||
ps.update(ss1, PollSet::POLL_READ);
|
||||
|
||||
@ -87,7 +88,7 @@ void PollSetTest::testPoll()
|
||||
assertTrue (sm.find(ss1) != sm.end());
|
||||
assertTrue (sm.find(ss2) == sm.end());
|
||||
assertTrue (sm.find(ss1)->second == PollSet::POLL_READ);
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
assertTrue (sw.elapsed() < 1100000);
|
||||
|
||||
int n = ss1.receiveBytes(buffer, sizeof(buffer));
|
||||
assertTrue (n == 5);
|
||||
@ -100,7 +101,7 @@ void PollSetTest::testPoll()
|
||||
assertTrue (sm.find(ss1) == sm.end());
|
||||
assertTrue (sm.find(ss2) != sm.end());
|
||||
assertTrue (sm.find(ss2)->second == PollSet::POLL_READ);
|
||||
assertTrue (sw.elapsed() < 100000);
|
||||
assertTrue (sw.elapsed() < 1100000);
|
||||
|
||||
n = ss2.receiveBytes(buffer, sizeof(buffer));
|
||||
assertTrue (n == 5);
|
||||
@ -125,6 +126,74 @@ void PollSetTest::testPoll()
|
||||
}
|
||||
|
||||
|
||||
void PollSetTest::testPollNoServer()
|
||||
{
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS
|
||||
StreamSocket ss1;
|
||||
StreamSocket ss2;
|
||||
|
||||
ss1.connectNB(SocketAddress("127.0.0.1", 0xFEFE));
|
||||
ss2.connectNB(SocketAddress("127.0.0.1", 0xFEFF));
|
||||
PollSet ps;
|
||||
assertTrue(ps.empty());
|
||||
ps.add(ss1, PollSet::POLL_READ);
|
||||
ps.add(ss2, PollSet::POLL_READ);
|
||||
assertTrue(!ps.empty());
|
||||
assertTrue(ps.has(ss1));
|
||||
assertTrue(ps.has(ss2));
|
||||
PollSet::SocketModeMap sm;
|
||||
Stopwatch sw; sw.start();
|
||||
do
|
||||
{
|
||||
sm = ps.poll(Timespan(1000000));
|
||||
if (sw.elapsedSeconds() > 10) fail();
|
||||
} while (sm.size() < 2);
|
||||
assertTrue(sm.size() == 2);
|
||||
for (auto s : sm)
|
||||
assertTrue(0 != (s.second | PollSet::POLL_ERROR));
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
}
|
||||
|
||||
|
||||
void PollSetTest::testPollClosedServer()
|
||||
{
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS
|
||||
EchoServer echoServer1;
|
||||
EchoServer echoServer2;
|
||||
StreamSocket ss1;
|
||||
StreamSocket ss2;
|
||||
|
||||
ss1.connect(SocketAddress("127.0.0.1", echoServer1.port()));
|
||||
ss2.connect(SocketAddress("127.0.0.1", echoServer2.port()));
|
||||
|
||||
PollSet ps;
|
||||
assertTrue(ps.empty());
|
||||
ps.add(ss1, PollSet::POLL_READ);
|
||||
ps.add(ss2, PollSet::POLL_READ);
|
||||
assertTrue(!ps.empty());
|
||||
assertTrue(ps.has(ss1));
|
||||
assertTrue(ps.has(ss2));
|
||||
|
||||
echoServer1.stop();
|
||||
ss1.sendBytes("HELLO", 5);
|
||||
while (!echoServer1.done()) Thread::sleep(10);
|
||||
echoServer2.stop();
|
||||
ss2.sendBytes("HELLO", 5);
|
||||
while (!echoServer2.done()) Thread::sleep(10);
|
||||
PollSet::SocketModeMap sm;
|
||||
Stopwatch sw; sw.start();
|
||||
do
|
||||
{
|
||||
sm = ps.poll(Timespan(1000000));
|
||||
if (sw.elapsedSeconds() > 10) fail();
|
||||
} while (sm.size() < 2);
|
||||
assertTrue(sm.size() == 2);
|
||||
assertTrue(0 == ss1.receiveBytes(0, 0));
|
||||
assertTrue(0 == ss2.receiveBytes(0, 0));
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
}
|
||||
|
||||
|
||||
void PollSetTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -140,6 +209,8 @@ CppUnit::Test* PollSetTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("PollSetTest");
|
||||
|
||||
CppUnit_addTest(pSuite, PollSetTest, testPoll);
|
||||
CppUnit_addTest(pSuite, PollSetTest, testPollNoServer);
|
||||
CppUnit_addTest(pSuite, PollSetTest, testPollClosedServer);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
2
vendor/POCO/Net/testsuite/src/PollSetTest.h
vendored
2
vendor/POCO/Net/testsuite/src/PollSetTest.h
vendored
@ -25,6 +25,8 @@ public:
|
||||
~PollSetTest();
|
||||
|
||||
void testPoll();
|
||||
void testPollNoServer();
|
||||
void testPollClosedServer();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -119,7 +119,7 @@ void SocketAddressTest::testSocketAddress()
|
||||
}
|
||||
|
||||
SocketAddress sa10("www6.pocoproject.org", 80);
|
||||
assertTrue (sa10.host().toString() == "54.93.62.90" || sa10.host().toString() == "[2001:4801:7828:101:be76:4eff:fe10:1455]");
|
||||
assertTrue (sa10.host().toString() == "54.93.62.90" || sa10.host().toString() == "2001:4801:7828:101:be76:4eff:fe10:1455");
|
||||
|
||||
SocketAddress sa11(SocketAddress::IPv4, "www6.pocoproject.org", 80);
|
||||
assertTrue (sa11.host().toString() == "54.93.62.90");
|
||||
|
@ -324,6 +324,7 @@ namespace
|
||||
_data.resize(1);
|
||||
_reactor.addEventHandler(_socket, Observer<DataServiceHandler, ReadableNotification>(*this, &DataServiceHandler::onReadable));
|
||||
_reactor.addEventHandler(_socket, Observer<DataServiceHandler, ShutdownNotification>(*this, &DataServiceHandler::onShutdown));
|
||||
_socket.setBlocking(false);
|
||||
}
|
||||
|
||||
~DataServiceHandler()
|
||||
@ -336,28 +337,32 @@ namespace
|
||||
{
|
||||
pNf->release();
|
||||
char buffer[64];
|
||||
int n = _socket.receiveBytes(&buffer[0], sizeof(buffer));
|
||||
if (n > 0)
|
||||
int n = 0;
|
||||
do
|
||||
{
|
||||
_data[_pos].append(buffer, n);
|
||||
std::size_t pos;
|
||||
pos = _data[_pos].find('\n');
|
||||
if(pos != std::string::npos)
|
||||
n = _socket.receiveBytes(&buffer[0], sizeof(buffer));
|
||||
if (n > 0)
|
||||
{
|
||||
if (pos == _data[_pos].size() - 1)
|
||||
_data[_pos].append(buffer, n);
|
||||
std::size_t pos;
|
||||
pos = _data[_pos].find('\n');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
_data[_pos].erase(pos, 1);
|
||||
_data.push_back(std::string());
|
||||
if (pos == _data[_pos].size() - 1)
|
||||
{
|
||||
_data[_pos].erase(pos, 1);
|
||||
_data.push_back(std::string());
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.push_back(_data[_pos].substr(pos + 1));
|
||||
_data[_pos].erase(pos);
|
||||
}
|
||||
++_pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.push_back(_data[_pos].substr(pos + 1));
|
||||
_data[_pos].erase(pos);
|
||||
}
|
||||
++_pos;
|
||||
}
|
||||
}
|
||||
else return;
|
||||
else break;
|
||||
} while (true);
|
||||
}
|
||||
|
||||
void onShutdown(ShutdownNotification* pNf)
|
||||
@ -500,7 +505,6 @@ void SocketReactorTest::testDataCollection()
|
||||
" \"data\":123"
|
||||
"}\n");
|
||||
sock.sendBytes(data0.data(), static_cast<int>(data0.size()));
|
||||
|
||||
std::string data1("{"
|
||||
" \"src\":\"127.0.0.1\","
|
||||
" \"id\":\"test1\","
|
||||
@ -517,7 +521,6 @@ void SocketReactorTest::testDataCollection()
|
||||
" ]"
|
||||
"}\n");
|
||||
sock.sendBytes(data1.data(), static_cast<int>(data1.size()));
|
||||
|
||||
std::string data2 = "{"
|
||||
" \"src\":\"127.0.0.1\","
|
||||
" \"id\":\"test2\","
|
||||
|
Reference in New Issue
Block a user