Commit 254e0852 authored by Pavel Vainerman's avatar Pavel Vainerman

(UNet): подправил тесты, исправил ошибку инициализации

parent 1bf3a239
...@@ -38,10 +38,11 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs, ...@@ -38,10 +38,11 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs,
} }
*/ */
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection ): UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t _port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection ):
shm(smi), shm(smi),
recvpause(10), recvpause(10),
updatepause(100), updatepause(100),
port(_port),
recvTimeout(5000), recvTimeout(5000),
prepareTime(2000), prepareTime(2000),
lostTimeout(200), /* 2*updatepause */ lostTimeout(200), /* 2*updatepause */
......
...@@ -25,14 +25,15 @@ using namespace std; ...@@ -25,14 +25,15 @@ using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UNetSender::UNetSender(const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, UNetSender::UNetSender(const std::string& _host, const ost::tpport_t _port, const std::shared_ptr<SMInterface>& smi,
bool nocheckConnection, const std::string& s_f, const std::string& s_val, bool nocheckConnection, const std::string& s_f, const std::string& s_val,
const std::string& s_prefix, size_t maxDCount, size_t maxACount ): const std::string& s_prefix, size_t maxDCount, size_t maxACount ):
s_field(s_f), s_field(s_f),
s_fvalue(s_val), s_fvalue(s_val),
prefix(s_prefix), prefix(s_prefix),
shm(smi), shm(smi),
s_host(s_host), port(_port),
s_host(_host),
sendpause(150), sendpause(150),
packsendpause(5), packsendpause(5),
activated(false), activated(false),
...@@ -56,9 +57,6 @@ UNetSender::UNetSender(const std::string& s_host, const ost::tpport_t port, cons ...@@ -56,9 +57,6 @@ UNetSender::UNetSender(const std::string& s_host, const ost::tpport_t port, cons
auto conf = uniset_conf(); auto conf = uniset_conf();
conf->initLogStream(unetlog, myname); conf->initLogStream(unetlog, myname);
// определяем фильтр
// s_field = conf->getArgParam("--udp-filter-field");
// s_fvalue = conf->getArgParam("--udp-filter-value");
unetinfo << myname << "(init): read filter-field='" << s_field unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
...@@ -280,7 +278,7 @@ void UNetSender::send() ...@@ -280,7 +278,7 @@ void UNetSender::send()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// #define UNETUDP_DISABLE_OPTIMIZATION_N1 // #define UNETUDP_DISABLE_OPTIMIZATION_N1
void UNetSender::real_send(UniSetUDP::UDPMessage& mypack) void UNetSender::real_send( UniSetUDP::UDPMessage& mypack )
{ {
UniSetTypes::uniset_rwmutex_rlock l(pack_mutex); UniSetTypes::uniset_rwmutex_rlock l(pack_mutex);
#ifdef UNETUDP_DISABLE_OPTIMIZATION_N1 #ifdef UNETUDP_DISABLE_OPTIMIZATION_N1
......
...@@ -171,7 +171,7 @@ class UNetSender ...@@ -171,7 +171,7 @@ class UNetSender
private: private:
UNetSender(); UNetSender();
std::shared_ptr<ost::UDPBroadcast> udp; std::shared_ptr<ost::UDPBroadcast> udp = { nullptr };
ost::IPV4Address addr; ost::IPV4Address addr;
ost::tpport_t port = { 0 }; ost::tpport_t port = { 0 };
std::string s_host = { "" }; std::string s_host = { "" };
......
#include <catch.hpp> #include <catch.hpp>
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <memory>
#include <cc++/socket.h> #include <cc++/socket.h>
#include "UniSetTypes.h" #include "UniSetTypes.h"
#include "UInterface.h" #include "UInterface.h"
...@@ -15,10 +16,10 @@ using namespace UniSetTypes; ...@@ -15,10 +16,10 @@ using namespace UniSetTypes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
static int port = 3000; static int port = 3000;
static ost::IPV4Host host("127.255.255.255"); static ost::IPV4Host host("127.255.255.255");
static UInterface* ui = nullptr; static shared_ptr<UInterface> ui = nullptr;
static ObjectId aid = 2; static ObjectId aid = 2;
static ost::UDPDuplex* udp_r = nullptr; static std::shared_ptr<UDPReceiveU> udp_r = nullptr;
static ost::UDPBroadcast* udp_s = nullptr; static shared_ptr<ost::UDPBroadcast> udp_s = nullptr;
static int s_port = 3003; // Node2 static int s_port = 3003; // Node2
static int s_nodeID = 3003; static int s_nodeID = 3003;
static int s_procID = 123; static int s_procID = 123;
...@@ -36,7 +37,7 @@ void InitTest() ...@@ -36,7 +37,7 @@ void InitTest()
if( ui == nullptr ) if( ui == nullptr )
{ {
ui = new UInterface(); ui = make_shared<UInterface>();
// UI понадобиться для проверки записанных в SM значений. // UI понадобиться для проверки записанных в SM значений.
CHECK( ui->getObjectIndex() != nullptr ); CHECK( ui->getObjectIndex() != nullptr );
CHECK( ui->getConf() == conf ); CHECK( ui->getConf() == conf );
...@@ -44,10 +45,10 @@ void InitTest() ...@@ -44,10 +45,10 @@ void InitTest()
} }
if( udp_r == nullptr ) if( udp_r == nullptr )
udp_r = new ost::UDPDuplex(host, port); udp_r = make_shared<UDPReceiveU>(host, port);
if( udp_s == nullptr ) if( udp_s == nullptr )
udp_s = new ost::UDPBroadcast(host, s_port); udp_s = make_shared<ost::UDPBroadcast>(host, s_port);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// pnum - минималный номер ожидаемого пакета ( 0 - любой пришедщий ) // pnum - минималный номер ожидаемого пакета ( 0 - любой пришедщий )
......
...@@ -11,3 +11,4 @@ cd - ...@@ -11,3 +11,4 @@ cd -
./uniset2-start.sh -f ./tests-with-sm $* -- --confile unetudp-test-configure.xml --e-startup-pause 10 \ ./uniset2-start.sh -f ./tests-with-sm $* -- --confile unetudp-test-configure.xml --e-startup-pause 10 \
--unet-name UNetExchange --unet-filter-field unet --unet-filter-value 1 --unet-maxdifferense 5 \ --unet-name UNetExchange --unet-filter-field unet --unet-filter-value 1 --unet-maxdifferense 5 \
--unet-recv-timeout 1000 --unet-sendpause 500 --unet-recv-timeout 1000 --unet-sendpause 500
#--unet-log-add-levels any
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <cc++/socket.h> #include <cc++/socket.h>
#include "UDPPacket.h" #include "UDPPacket.h"
#include "PassiveTimer.h" #include "PassiveTimer.h"
#include "UDPCore.h"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
static struct option longopts[] = static struct option longopts[] =
{ {
...@@ -201,7 +202,7 @@ int main(int argc, char* argv[]) ...@@ -201,7 +202,7 @@ int main(int argc, char* argv[])
{ {
case cmdReceive: case cmdReceive:
{ {
ost::UDPDuplex udp(host, port); UDPReceiveU udp(host, port);
// char buf[UniSetUDP::MaxDataLen]; // char buf[UniSetUDP::MaxDataLen];
UniSetUDP::UDPMessage pack; UniSetUDP::UDPMessage pack;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment