diff --git a/CMakeLists.txt b/CMakeLists.txt index a5ba6bd2..4e5cfd43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) #----------------------------------------------------------------- # The project #----------------------------------------------------------------- -project (SolidFrame VERSION 12.0) +project (SolidFrame VERSION 12.1) message("SolidFrame version: ${PROJECT_VERSION} - ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") #----------------------------------------------------------------- diff --git a/RELEASES.md b/RELEASES.md index a36282e3..7f2feb0e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,8 @@ # SolidFrame Releases +## Version 12.1 +* Coverity fixes + ## Version 12.0 * utility: support pthread_spin_lock when available * utility: ThreadPool improvements and fixes diff --git a/examples/frame/aio_echo/example_echo_auto_client.cpp b/examples/frame/aio_echo/example_echo_auto_client.cpp index 28cf2bfa..062ea9fd 100644 --- a/examples/frame/aio_echo/example_echo_auto_client.cpp +++ b/examples/frame/aio_echo/example_echo_auto_client.cpp @@ -49,16 +49,16 @@ struct Statistics { namespace { struct Params { - uint32_t connection_count; - uint32_t repeat_count; + uint32_t connection_count = 1; + uint32_t repeat_count = 1; string connect_addr_str; string connect_port_str; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; + bool dbg_console = true; + bool dbg_buffered = true; }; mutex mtx; diff --git a/examples/frame/aio_echo/example_echo_server.cpp b/examples/frame/aio_echo/example_echo_server.cpp index 6416518f..3b3d1d22 100644 --- a/examples/frame/aio_echo/example_echo_server.cpp +++ b/examples/frame/aio_echo/example_echo_server.cpp @@ -33,15 +33,15 @@ typedef frame::Scheduler>> AioSchedulerT; //------------------------------------------------------------------ struct Params { - int listener_port; - int talker_port; - int connect_port; + int listener_port = -1; + int talker_port = -1; + int connect_port = -1; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; namespace { diff --git a/examples/frame/aio_echo/example_secure_echo_client.cpp b/examples/frame/aio_echo/example_secure_echo_client.cpp index 7103a95e..069284e9 100644 --- a/examples/frame/aio_echo/example_secure_echo_client.cpp +++ b/examples/frame/aio_echo/example_secure_echo_client.cpp @@ -45,9 +45,9 @@ struct Params { vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; using ConnectStT = std::pair; diff --git a/examples/frame/aio_echo/example_secure_echo_server.cpp b/examples/frame/aio_echo/example_secure_echo_server.cpp index 6e7ed544..b2412dc4 100644 --- a/examples/frame/aio_echo/example_secure_echo_server.cpp +++ b/examples/frame/aio_echo/example_secure_echo_server.cpp @@ -45,13 +45,13 @@ typedef frame::aio::openssl::Context SecureContextT; //------------------------------------------------------------------ struct Params { - int listener_port; + int listener_port = 2000; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; namespace { diff --git a/examples/frame/file_server/example_file_server.cpp b/examples/frame/file_server/example_file_server.cpp index 63b9fbdb..8b514a39 100644 --- a/examples/frame/file_server/example_file_server.cpp +++ b/examples/frame/file_server/example_file_server.cpp @@ -49,13 +49,13 @@ enum Events { //------------------------------------------------------------------ struct Params { - int start_port; + int start_port = -1; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; namespace { diff --git a/examples/frame/mprpc_echo/example_mprpc_echo.cpp b/examples/frame/mprpc_echo/example_mprpc_echo.cpp index 3b303636..4512fc75 100644 --- a/examples/frame/mprpc_echo/example_mprpc_echo.cpp +++ b/examples/frame/mprpc_echo/example_mprpc_echo.cpp @@ -47,13 +47,13 @@ struct Params { vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; + bool dbg_console = true; + bool dbg_buffered = true; std::string baseport; - bool log; + bool log = true; StringVectorT connectstringvec; - bool secure; + bool secure = true; bool prepare(frame::mprpc::Configuration& _rcfg, string& _err); }; @@ -99,15 +99,15 @@ struct FirstMessage : frame::mprpc::Message { FirstMessage(std::string const& _str) : str(_str) { - solid_log(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_log(generic_logger, Info, "CREATE ---------------- " << this); } FirstMessage() { - solid_log(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_log(generic_logger, Info, "CREATE ---------------- " << this); } ~FirstMessage() { - solid_log(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_log(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/examples/frame/relay_server/example_relay_server.cpp b/examples/frame/relay_server/example_relay_server.cpp index 29bcfef1..6d92d926 100644 --- a/examples/frame/relay_server/example_relay_server.cpp +++ b/examples/frame/relay_server/example_relay_server.cpp @@ -50,17 +50,17 @@ enum Events { namespace { struct Params { - int listener_port; - int talker_port; + int listener_port = -1; + int talker_port = -1; string connect_addr_str; string connect_port_str; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; Params params; diff --git a/examples/frame/relay_server/example_relay_server_bi.cpp b/examples/frame/relay_server/example_relay_server_bi.cpp index 268af281..b983f2a4 100644 --- a/examples/frame/relay_server/example_relay_server_bi.cpp +++ b/examples/frame/relay_server/example_relay_server_bi.cpp @@ -40,16 +40,16 @@ using BufferPairT = pair; namespace { struct Params { - int listener_port; + int listener_port = -1; string connect_addr_str; string connect_port_str; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; Params params; diff --git a/examples/frame/relay_server/example_relay_server_bi_cp.cpp b/examples/frame/relay_server/example_relay_server_bi_cp.cpp index b638177d..2e7f9d37 100644 --- a/examples/frame/relay_server/example_relay_server_bi_cp.cpp +++ b/examples/frame/relay_server/example_relay_server_bi_cp.cpp @@ -40,16 +40,16 @@ using BufferPairT = pair; namespace { struct Params { - int listener_port; + int listener_port = -1; string connect_addr_str; string connect_port_str; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; Params params; diff --git a/examples/frame/relay_server/example_relay_server_bi_ex.cpp b/examples/frame/relay_server/example_relay_server_bi_ex.cpp index 2cc7493e..9b732c7d 100644 --- a/examples/frame/relay_server/example_relay_server_bi_ex.cpp +++ b/examples/frame/relay_server/example_relay_server_bi_ex.cpp @@ -39,16 +39,16 @@ using AioSchedulerT = frame::Scheduler>>; namespace { struct Params { - int listener_port; + int listener_port = -1; string connect_addr_str; string connect_port_str; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; Params params; diff --git a/examples/frame/relay_server/example_relay_server_bi_sh.cpp b/examples/frame/relay_server/example_relay_server_bi_sh.cpp index 9cb95f66..12436838 100644 --- a/examples/frame/relay_server/example_relay_server_bi_sh.cpp +++ b/examples/frame/relay_server/example_relay_server_bi_sh.cpp @@ -40,16 +40,16 @@ using BufferPairT = pair; namespace { struct Params { - int listener_port; + int listener_port = -1; string connect_addr_str; string connect_port_str; vector dbg_modules; string dbg_addr; string dbg_port; - bool dbg_console; - bool dbg_buffered; - bool log; + bool dbg_console = true; + bool dbg_buffered = true; + bool log = true; }; Params params; diff --git a/solid/frame/aio/aiocompletion.hpp b/solid/frame/aio/aiocompletion.hpp index 729857cd..03ba9b61 100644 --- a/solid/frame/aio/aiocompletion.hpp +++ b/solid/frame/aio/aiocompletion.hpp @@ -58,7 +58,7 @@ class CompletionHandler : public ForwardCompletionHandler { return pprev != nullptr; } bool activate(Actor const& _ract); - void deactivate(); + void deactivate(const bool _check = true); void unregister(); protected: diff --git a/solid/frame/aio/aiodatagram.hpp b/solid/frame/aio/aiodatagram.hpp index 60b3a204..86ab79a7 100644 --- a/solid/frame/aio/aiodatagram.hpp +++ b/solid/frame/aio/aiodatagram.hpp @@ -285,7 +285,7 @@ class Datagram : public CompletionHandler { ~Datagram() { // MUST call here and not in the ~CompletionHandler - this->deactivate(); + this->deactivate(false); } bool hasPendingRecv() const diff --git a/solid/frame/aio/aiolistener.hpp b/solid/frame/aio/aiolistener.hpp index e9aee6a1..ff613f8b 100644 --- a/solid/frame/aio/aiolistener.hpp +++ b/solid/frame/aio/aiolistener.hpp @@ -43,7 +43,7 @@ class Listener : public CompletionHandler { ~Listener() { // MUST call here and not in the ~CompletionHandler - this->deactivate(); + this->deactivate(false); } SocketDevice reset(ReactorContext& _rctx, SocketDevice&& _rnewdev = std::move(dummy_socket_device())); diff --git a/solid/frame/aio/aioresolver.hpp b/solid/frame/aio/aioresolver.hpp index 030010e6..869ec381 100644 --- a/solid/frame/aio/aioresolver.hpp +++ b/solid/frame/aio/aioresolver.hpp @@ -88,7 +88,7 @@ struct DirectResolveCbk : DirectResolve { int _type, int _proto) : DirectResolve(_host, _srvc, _flags, _family, _type, _proto) - , cbk(_cbk) + , cbk(std::move(_cbk)) { } @@ -144,7 +144,7 @@ class Resolver { int _type = -1, int _proto = -1) { - push_fnc_(DirectResolveCbk(_cbk, _host, _srvc, _flags, _family, _type, _proto)); + push_fnc_(DirectResolveCbk(std::move(_cbk), _host, _srvc, _flags, _family, _type, _proto)); } template diff --git a/solid/frame/aio/aiostream.hpp b/solid/frame/aio/aiostream.hpp index 25460186..56a94a74 100644 --- a/solid/frame/aio/aiostream.hpp +++ b/solid/frame/aio/aiostream.hpp @@ -326,7 +326,7 @@ class Stream : public CompletionHandler { ~Stream() { // MUST call here and not in the ~CompletionHandler - this->deactivate(); + this->deactivate(false); } bool hasPendingRecv() const diff --git a/solid/frame/aio/aiotimer.hpp b/solid/frame/aio/aiotimer.hpp index 291996c2..e815b726 100644 --- a/solid/frame/aio/aiotimer.hpp +++ b/solid/frame/aio/aiotimer.hpp @@ -71,7 +71,7 @@ class SteadyTimer : public CompletionHandler { ~SteadyTimer() { // MUST call here and not in the ~CompletionHandler - this->deactivate(); + this->deactivate(false); } const NanoTime& expiry() const diff --git a/solid/frame/aio/openssl/src/aiosecuresocket.cpp b/solid/frame/aio/openssl/src/aiosecuresocket.cpp index c7ee7e60..e05c7faf 100644 --- a/solid/frame/aio/openssl/src/aiosecuresocket.cpp +++ b/solid/frame/aio/openssl/src/aiosecuresocket.cpp @@ -524,7 +524,7 @@ ReactorEventE Socket::filterReactorEvents( // solid_log(logger, Info, "EventRecvSend "<unregisterCompletionHandler(*this); idxreactor = InvalidIndex(); } - if (isActive()) { - solid_throw_log(generic_logger, "FATAL: CompletionHandler deleted/deactivated outside actor's reactor!"); + if (_check) { + solid_check_log(!isActive(), generic_logger, "FATAL: CompletionHandler deleted/deactivated outside actor's reactor!"); } } diff --git a/solid/frame/aio/test/CMakeLists.txt b/solid/frame/aio/test/CMakeLists.txt index edbfaf7f..2495bed4 100644 --- a/solid/frame/aio/test/CMakeLists.txt +++ b/solid/frame/aio/test/CMakeLists.txt @@ -89,7 +89,62 @@ if(OPENSSL_FOUND) add_test(NAME TestAioEchoTcpStress4rs COMMAND test_aio test_echo_tcp_stress 4 r s) add_test(NAME TestAioEchoTcpStress8rs COMMAND test_aio test_echo_tcp_stress 8 r s) add_test(NAME TestAioEchoTcpStress16rs COMMAND test_aio test_echo_tcp_stress 16 r s) + + set_tests_properties( + TestAioEventStress100_100 + TestEventStressWP00_100_100 + TestAioEventStress100_1000 + TestEventStressWP00_100_1000 + TestAioEventStress20_10000 + TestEventStressWP02_20_10000 + TestEventStressWP04_20_10000 + TestEventStressWP08_20_10000 + TestEventStressWP10_20_10000 + TestAioEchoTcpStress1 + TestAioEchoTcpStress2 + TestAioEchoTcpStress4 + TestAioEchoTcpStress8 + TestAioEchoTcpStress16 + TestAioEchoTcpStress1r + TestAioEchoTcpStress2r + TestAioEchoTcpStress4r + TestAioEchoTcpStress8r + TestAioEchoTcpStress16r + TestAioEchoTcpStress1s + TestAioEchoTcpStress2s + TestAioEchoTcpStress4s + TestAioEchoTcpStress8s + TestAioEchoTcpStress16s + TestAioEchoTcpStress1rs + TestAioEchoTcpStress2rs + TestAioEchoTcpStress4rs + TestAioEchoTcpStress8rs + TestAioEchoTcpStress16rs + PROPERTIES LABELS "aio stress" + ) + set_tests_properties( + TestAioEventStress100_100 + TestEventStressWP00_100_100 + TestAioEventStress100_1000 + TestEventStressWP00_100_1000 + TestAioEventStress20_10000 + TestEventStressWP02_20_10000 + TestEventStressWP04_20_10000 + TestEventStressWP08_20_10000 + TestEventStressWP10_20_10000 + PROPERTIES LABELS "aio stress event" + ) + + set_tests_properties( + TestEventStressWP00_100_100 + TestEventStressWP00_100_1000 + TestEventStressWP02_20_10000 + TestEventStressWP04_20_10000 + TestEventStressWP08_20_10000 + TestEventStressWP10_20_10000 + PROPERTIES LABELS "aio stress event threadpool" + ) #============================================================================== @@ -121,10 +176,27 @@ if(OPENSSL_FOUND) ) endif() - add_test(NAME TestPerfActorAio COMMAND test_perf test_perf_actor_aio) - add_test(NAME TestPerfTimeStore COMMAND test_perf test_perf_timestore) - add_test(NAME TestPerfActorFrame COMMAND test_perf test_perf_actor_frame) + add_test(NAME TestPerfActorAio COMMAND test_perf test_perf_actor_aio) + add_test(NAME TestPerfTimeStore COMMAND test_perf test_perf_timestore) + add_test(NAME TestPerfActorFrame COMMAND test_perf test_perf_actor_frame) add_test(NAME TestPerfThreadPoolLockFree COMMAND test_perf test_perf_threadpool_lockfree) add_test(NAME TestPerfThreadPoolSynchCtx COMMAND test_perf test_perf_threadpool_synch_context) + + set_tests_properties( + TestPerfActorAio + TestPerfTimeStore + TestPerfActorFrame + TestPerfThreadPoolLockFree + TestPerfThreadPoolSynchCtx + PROPERTIES LABELS "aio perf" + ) + + set_tests_properties( + TestPerfThreadPoolLockFree + TestPerfThreadPoolSynchCtx + PROPERTIES LABELS "aio perf threadpool" + ) + + endif(OPENSSL_FOUND) diff --git a/solid/frame/aio/test/test_echo_tcp_stress.cpp b/solid/frame/aio/test/test_echo_tcp_stress.cpp index 78de3829..4bb35974 100644 --- a/solid/frame/aio/test/test_echo_tcp_stress.cpp +++ b/solid/frame/aio/test/test_echo_tcp_stress.cpp @@ -97,11 +97,7 @@ class Connection : public frame::aio::Actor { virtual bool recvSome(frame::aio::ReactorContext& _rctx, size_t& _rsz) = 0; protected: - Connection() - : recvcnt(0) - , sendcnt(0) - { - } + Connection() = default; ~Connection() override { solid_dbg(generic_logger, Error, this << " server " << recvcnt << " " << sendcnt); @@ -114,9 +110,9 @@ class Connection : public frame::aio::Actor { enum { BufferCapacity = 1024 * 2 }; char buf[BufferCapacity]; - uint64_t recvcnt; - uint64_t sendcnt; - size_t sendcrt; + uint64_t recvcnt = 0; + uint64_t sendcnt = 0; + size_t sendcrt = 0; }; class PlainConnection final : public Connection { @@ -415,6 +411,7 @@ class Connection final : public frame::aio::Actor { , sock2(this->proxy()) , recvcnt(0) , sendcnt(0) + , sendcrt(0) , crtid(-1) { } @@ -603,9 +600,14 @@ int test_echo_tcp_stress(int argc, char* argv[]) // actptr.reset(new client::PlainConnection(i)); actptr = make_shared(i); } - ++concnt; + { + lock_guard lock(mtx); + ++concnt; + } actuid = clt_sch.startActor(std::move(actptr), clt_svc, make_event(GenericEventE::Start), err); + if (actuid.isInvalid()) { + lock_guard lock(mtx); --concnt; } solid_log(generic_logger, Info, "Started Connection Actor: " << actuid.index << ',' << actuid.unique); @@ -721,7 +723,7 @@ void Listener::onAccept(frame::aio::ReactorContext& _rctx, SocketDevice& _rsd) /*static*/ void Connection::onRecv(frame::aio::ReactorContext& _rctx, size_t _sz) { - unsigned repeatcnt = 1; + unsigned repeatcnt = 2; Connection& rthis = static_cast(_rctx.actor()); solid_dbg(generic_logger, Info, &rthis << " " << _sz); do { @@ -862,9 +864,8 @@ void Connection::onEvent(frame::aio::ReactorContext& _rctx, EventBase&& _revent) solid_dbg(generic_logger, Info, "event = " << _revent); if (_revent == generic_event) { // we must resolve the address then connect - solid_dbg(generic_logger, Info, "async_resolve = " - << "127.0.0.1" - << " " << srv_port_str); + solid_dbg(generic_logger, Info, "async_resolve = " << "127.0.0.1" + << " " << srv_port_str); async_resolver().requestResolve( ResolvFunc(_rctx.service().manager(), _rctx.service().manager().id(*this)), "127.0.0.1", use_relay ? rly_port_str.c_str() : srv_port_str.c_str(), 0, SocketInfo::Inet4, SocketInfo::Stream); @@ -1042,9 +1043,8 @@ struct ResolvFunc { solid_dbg(generic_logger, Error, this << " " << _revent); if (generic_event == _revent) { // we must resolve the address then connect - solid_dbg(generic_logger, Info, "async_resolve = " - << "127.0.0.1" - << " " << srv_port_str); + solid_dbg(generic_logger, Info, "async_resolve = " << "127.0.0.1" + << " " << srv_port_str); async_resolver().requestResolve( ResolvFunc(_rctx.manager(), _rctx.manager().id(*this)), "127.0.0.1", srv_port_str.c_str(), 0, SocketInfo::Inet4, SocketInfo::Stream); diff --git a/solid/frame/aio/test/test_perf_timestore.cpp b/solid/frame/aio/test/test_perf_timestore.cpp index f9316a6d..3ea87a5d 100644 --- a/solid/frame/aio/test/test_perf_timestore.cpp +++ b/solid/frame/aio/test/test_perf_timestore.cpp @@ -97,6 +97,8 @@ int test_perf_timestore(int argc, char* argv[]) } cout << "max duration: " << max_duration << endl; - cout << "avg duration: " << total_duration / count << endl; + if (count) { + cout << "avg duration: " << total_duration / count << endl; + } return 0; } \ No newline at end of file diff --git a/solid/frame/completion.hpp b/solid/frame/completion.hpp index 46c81cb5..00fd1253 100644 --- a/solid/frame/completion.hpp +++ b/solid/frame/completion.hpp @@ -58,7 +58,7 @@ class CompletionHandler : public ForwardCompletionHandler { return pprev != nullptr; } bool activate(Actor const& _ract); - void deactivate(); + void deactivate(const bool _check = true); void unregister(); protected: diff --git a/solid/frame/file/filestore.hpp b/solid/frame/file/filestore.hpp index 4bf983cb..a1bdd6fe 100644 --- a/solid/frame/file/filestore.hpp +++ b/solid/frame/file/filestore.hpp @@ -272,9 +272,9 @@ struct Utf8Controller { }; struct Utf8PathStub { - size_t storeidx; + size_t storeidx = InvalidIndex{}; std::string path; - size_t idx; + size_t idx = InvalidIndex{}; }; struct Utf8OpenCommandBase { diff --git a/solid/frame/file/src/filestore.cpp b/solid/frame/file/src/filestore.cpp index 3cb8b27b..c03f0038 100644 --- a/solid/frame/file/src/filestore.cpp +++ b/solid/frame/file/src/filestore.cpp @@ -136,7 +136,7 @@ struct Utf8ConfigurationImpl { } std::string globalprefix; std::string localprefix; - size_t globalsize; + size_t globalsize = 0; }; Utf8ConfigurationImpl() {} @@ -233,8 +233,8 @@ struct Utf8Controller::Data { Utf8ConfigurationImpl filecfg; // NOTE: it is accessed without lock in openFile TempConfigurationImpl tempcfg; - size_t minglobalprefixsz; - size_t maxglobalprefixsz; + size_t minglobalprefixsz = InvalidIndex(); + size_t maxglobalprefixsz = 0; SizePairVectorT hashvec; std::string tmp; PathDequeT pathdq; diff --git a/solid/frame/manager.hpp b/solid/frame/manager.hpp index 2cd92cf6..9e7d7bb2 100644 --- a/solid/frame/manager.hpp +++ b/solid/frame/manager.hpp @@ -168,7 +168,7 @@ class Manager final : NonCopyable { template size_t forEachServiceActor(const Service& _rservice, F _f); - void stopService(Service& _rservice, bool _wait); + void stopService(Service& _rservice, const bool _wait, const bool _check = true); template void startService(Service& _rservice, OnLockedStartF&& _on_locked_fnc); diff --git a/solid/frame/mprpc/src/mprpcconnection.cpp b/solid/frame/mprpc/src/mprpcconnection.cpp index 1e13cf1d..f8f53503 100644 --- a/solid/frame/mprpc/src/mprpcconnection.cpp +++ b/solid/frame/mprpc/src/mprpcconnection.cpp @@ -445,7 +445,7 @@ void Connection::doStop(frame::aio::ReactorContext& _rctx, const ErrorConditionT solid_log(logger, Info, this << ' ' << this->id() << " wait for " << wait_duration.count()); timer_.waitFor(_rctx, wait_duration, - [event](frame::aio::ReactorContext& _rctx) { + [event = std::move(event)](frame::aio::ReactorContext& _rctx) { Connection& rthis = static_cast(_rctx.actor()); rthis.doContinueStopping(_rctx, event); }); diff --git a/solid/frame/mprpc/src/mprpcmessagewriter.cpp b/solid/frame/mprpc/src/mprpcmessagewriter.cpp index b465ba55..48d8f6d1 100644 --- a/solid/frame/mprpc/src/mprpcmessagewriter.cpp +++ b/solid/frame/mprpc/src/mprpcmessagewriter.cpp @@ -141,7 +141,7 @@ bool MessageWriter::enqueue( order_inner_list_.pushBack(idx); doWriteQueuePushBack(idx, __LINE__); - solid_log(logger, Verbose, "messgeptr = " << rmsgstub.msgbundle_.message_ptr.get() << " is_relayed = " << Message::is_relayed(rmsgstub.msgbundle_.message_ptr->flags()) << ' ' << MessageWriterPrintPairT(*this, PrintInnerListsE) << " relay " << rmsgstub.msgbundle_.message_relay_header_ << " " << _rmsgbundle.message_relay_header_); + solid_log(logger, Verbose, "messgeptr = " << rmsgstub.msgbundle_.message_ptr.get() << " is_relayed = " << Message::is_relayed(rmsgstub.msgbundle_.message_ptr->flags()) << ' ' << MessageWriterPrintPairT(*this, PrintInnerListsE) << " relay " << rmsgstub.msgbundle_.message_relay_header_ << " " << rmsgstub.msgbundle_.message_relay_header_); return true; } diff --git a/solid/frame/mprpc/src/mprpcservice.cpp b/solid/frame/mprpc/src/mprpcservice.cpp index de2407a6..0d77dcc8 100644 --- a/solid/frame/mprpc/src/mprpcservice.cpp +++ b/solid/frame/mprpc/src/mprpcservice.cpp @@ -859,7 +859,7 @@ void Service::doFinalizeStart(ServiceStartStatus& _status, Configuration&& _ucfg _lock.unlock(); // temporary unlock the mutex so we can create the listener Actor ErrorConditionT error; - ActorIdT conuid = _ucfg.actor_create_fnc(make_shared(_usd), *this, make_event(GenericEventE::Start), error); + ActorIdT conuid = configuration().actor_create_fnc(make_shared(_usd), *this, make_event(GenericEventE::Start), error); (void)conuid; _lock.lock(); @@ -1179,8 +1179,6 @@ ErrorConditionT Service::doSendMessage( solid_assert(pool_lock.owns_lock()); return locked_pimpl->doSendMessageToPool(*this, pool_id, _rmsgptr, _rcomplete_fnc, msg_type_idx, _recipient_url.relay_, _precipient_id_out, _pmsgid_out, _flags); - - return {}; } //----------------------------------------------------------------------------- @@ -1219,7 +1217,7 @@ ErrorConditionT Service::Data::doSendMessageToConnection( return error_service_unknown_connection; } { - unique_lock pool_lock(poolMutex(pool_index)); + unique_lock pool_lock{poolMutex(pool_index)}; ConnectionPoolStub& rpool = pool_dq_[pool_index]; const bool is_server_side_pool = rpool.isServerSide(); // unnamed pool has a single connection @@ -2049,7 +2047,6 @@ bool Service::Data::Data::doNonMainConnectionStopping( --rpool.active_connection_count_; } else { solid_assert_log(!_rcon.isServer(), logger); - solid_assert_log(rpool.pending_connection_count_ >= 0, logger); --rpool.pending_connection_count_; } @@ -2131,10 +2128,12 @@ bool Service::Data::doMainConnectionStoppingCleanOneShot( } if (rmsgstub.message_bundle_.message_ptr && Message::is_one_shot(rmsgstub.message_bundle_.message_flags)) { + solid_assert_log(_pmsg_bundle, logger, "_pmsg_bundle must not be null"); *_pmsg_bundle = std::move(rmsgstub.message_bundle_); _rmsg_id = MessageId(crtmsgidx, rmsgstub.unique_); rpool.clearPopAndCacheMessage(crtmsgidx); } else if (!rmsgstub.message_bundle_.message_ptr && rpool.message_order_inner_list_.size() == 1) { + solid_assert_log(_pmsg_bundle, logger, "_pmsg_bundle must not be null"); *_pmsg_bundle = std::move(rmsgstub.message_bundle_); _rmsg_id = MessageId(crtmsgidx, rmsgstub.unique_); rpool.clearPopAndCacheMessage(crtmsgidx); @@ -2173,7 +2172,7 @@ bool Service::Data::doMainConnectionStoppingCleanAll( if (!rpool.message_order_inner_list_.empty()) { const size_t msgidx = rpool.message_order_inner_list_.frontIndex(); - { + if (_pmsg_bundle) { MessageStub& rmsgstub = rpool.message_order_inner_list_.front(); *_pmsg_bundle = std::move(rmsgstub.message_bundle_); _rmsg_id = MessageId(msgidx, rmsgstub.unique_); @@ -2185,7 +2184,6 @@ bool Service::Data::doMainConnectionStoppingCleanAll( if (_rcon.isActiveState()) { --rpool.active_connection_count_; } else { - solid_assert_log(rpool.pending_connection_count_ >= 0, logger); --rpool.pending_connection_count_; } @@ -2237,7 +2235,6 @@ bool Service::Data::doMainConnectionStoppingPrepareCleanOneShot( if (_rcon.isActiveState()) { --rpool.active_connection_count_; } else { - solid_assert_log(rpool.pending_connection_count_ >= 0, logger); --rpool.pending_connection_count_; } @@ -2305,7 +2302,6 @@ bool Service::Data::doMainConnectionRestarting( if (_rcon.isActiveState()) { --rpool.active_connection_count_; } else { - solid_assert_log(rpool.pending_connection_count_ >= 0, logger); --rpool.pending_connection_count_; } @@ -2748,7 +2744,7 @@ void InternetResolverF::operator()(const std::string& _name, ResolveCompleteFunc fnc.cbk = std::move(_cbk); - rresolver_.requestResolve(fnc, hst_name, svc_name, 0, this->family_, SocketInfo::Stream); + rresolver_.requestResolve(std::move(fnc), hst_name, svc_name, 0, this->family_, SocketInfo::Stream); } //============================================================================= diff --git a/solid/frame/mprpc/test/CMakeLists.txt b/solid/frame/mprpc/test/CMakeLists.txt index f418a151..9948da86 100644 --- a/solid/frame/mprpc/test/CMakeLists.txt +++ b/solid/frame/mprpc/test/CMakeLists.txt @@ -152,7 +152,52 @@ if(OPENSSL_FOUND) add_test(NAME TestClientServerTimeoutSecureP COMMAND test_mprpc_clientserver test_clientserver_timeout_secure 10 p) add_test(NAME TestClientServerTimeoutSecureA COMMAND test_mprpc_clientserver test_clientserver_timeout_secure 10 a) - + set_tests_properties( + TestClientServerBasic_1 + TestClientServerBasic_2 + TestClientServerBasic_4 + TestClientServerBasic_8 + TestClientServerBasic_8_C + TestClientServerBasic_1S + TestClientServerBasic_2S + TestClientServerBasic_4S + TestClientServerBasic_8S + TestClientServerBasic_8SC + TestClientServerBasic_1C + TestClientServerBasic_2C + TestClientServerBasic_4C + TestClientServerBasic_8C + TestClientServerBasic_8CC + TestClientServerBasic_1B + TestClientServerBasic_2B + TestClientServerBasic_4B + TestClientServerBasic_8B + TestClientServerBasic_8BC + TestClientServerVersioning + TestClientServerTopic + TestClientServerSendRequest + TestClientServerSendRequestS + TestClientServerCancelServer + TestClientServerCancelServerS + TestClientServerCancelClient + TestClientServerCancelClientS + TestClientServerNoServer + TestClientServerNoServerS + TestClientServerOneShot + TestClientServerOneShotS + TestClientServerDelayed + TestClientServerDelayedS + TestClientServerIdempontent + TestClientServerIdempontentS + TestClientServerSplit1 + TestClientServerUpload + TestClientServerUploadSingle + TestClientServerDownload + TestClientServerTimeoutSecureS + TestClientServerTimeoutSecureP + TestClientServerTimeoutSecureA + PROPERTIES LABELS "mprpc clientserver" + ) #============================================================================== set( mprpcKeepAliveTestSuite @@ -180,7 +225,13 @@ if(OPENSSL_FOUND) add_test(NAME TestKeepAliveFail1 COMMAND test_mprpc_keepalive test_keepalive_fail "0") add_test(NAME TestKeepAliveFail2 COMMAND test_mprpc_keepalive test_keepalive_fail "1") add_test(NAME TestKeepAliveSuccess1 COMMAND test_mprpc_keepalive test_keepalive_success "0") - + + set_tests_properties( + TestKeepAliveFail1 + TestKeepAliveFail2 + TestKeepAliveSuccess1 + PROPERTIES LABELS "mprpc keepalive" + ) #============================================================================== @@ -207,6 +258,11 @@ if(OPENSSL_FOUND) add_test(NAME TestConnectionClose COMMAND test_mprpc_connection test_connection_close) + set_tests_properties( + TestConnectionClose + PROPERTIES LABELS "mprpc connection" + ) + #============================================================================== set( mprpcPoolTestSuite @@ -243,6 +299,17 @@ if(OPENSSL_FOUND) add_test(NAME TestPoolDelayClose2 COMMAND test_mprpc_pool test_pool_delay_close 2) add_test(NAME TestPoolDelayClose4 COMMAND test_mprpc_pool test_pool_delay_close 4) + set_tests_properties( + TestPoolBasic1 + TestPoolForceClose1 + TestPoolForceClose2 + TestPoolForceClose4 + TestPoolDelayClose1 + TestPoolDelayClose2 + TestPoolDelayClose4 + PROPERTIES LABELS "mprpc pool" + ) + #============================================================================== add_subdirectory(multiprotocol_basic) @@ -276,6 +343,11 @@ if(OPENSSL_FOUND) add_test(NAME TestMultiProtocolBasic COMMAND test_mprpc_multiprotocol test_multiprotocol_basic) + set_tests_properties( + TestMultiProtocolBasic + PROPERTIES LABELS "mprpc multiprotocol" + ) + #============================================================================== set( mprpcRawTestSuite @@ -303,6 +375,11 @@ if(OPENSSL_FOUND) add_test(NAME TestRawBasic COMMAND test_mprpc_raw test_raw_basic) #add_test(NAME TestRawProxy COMMAND test_mprpc_raw test_raw_proxy) + set_tests_properties( + TestRawBasic + PROPERTIES LABELS "mprpc raw" + ) + #============================================================================== set( mprpcRelayTestSuite @@ -344,7 +421,18 @@ if(OPENSSL_FOUND) add_test(NAME TestRelayDetectClose COMMAND test_mprpc_relay test_relay_detect_close) add_test(NAME TestRelayDetectCloseWhileResponse COMMAND test_mprpc_relay test_relay_detect_close_while_response) - + set_tests_properties( + TestRelayDisabled1 + TestRelayBasic1 + TestRelayCancelRequest1 + TestRelayCancelResponse1 + TestRelayCloseRequest1 + TestRelayCloseResponse1 + TestRelaySplit1 + TestRelayDetectClose + TestRelayDetectCloseWhileResponse + PROPERTIES LABELS "mprpc relay" + ) #============================================================================== set( mprpcRelayEngineTestSuite @@ -368,6 +456,11 @@ if(OPENSSL_FOUND) ) add_test(NAME TestRelayEngineBasic COMMAND test_mprpc_relay_engine test_relay_engine_basic) + + set_tests_properties( + TestRelayEngineBasic + PROPERTIES LABELS "mprpc relayengine" + ) #============================================================================== @@ -395,6 +488,12 @@ if(OPENSSL_FOUND) add_test(NAME TestClientFrontBackUpload COMMAND test_mprpc_clientfrontback test_clientfrontback_upload) add_test(NAME TestClientFrontBackDownload COMMAND test_mprpc_clientfrontback test_clientfrontback_download) + + set_tests_properties( + TestClientFrontBackUpload + TestClientFrontBackDownload + PROPERTIES LABELS "mprpc clientfrontback" + ) #============================================================================== endif(OPENSSL_FOUND) diff --git a/solid/frame/mprpc/test/multiprotocol_basic/alpha/alphamessages.hpp b/solid/frame/mprpc/test/multiprotocol_basic/alpha/alphamessages.hpp index 2cb40004..e64ffc41 100644 --- a/solid/frame/mprpc/test/multiprotocol_basic/alpha/alphamessages.hpp +++ b/solid/frame/mprpc/test/multiprotocol_basic/alpha/alphamessages.hpp @@ -9,7 +9,7 @@ namespace alpha_protocol { struct FirstMessage : solid::frame::mprpc::Message { - uint32_t v; + uint32_t v = -1; std::string str; FirstMessage() {} @@ -26,7 +26,7 @@ struct FirstMessage : solid::frame::mprpc::Message { }; struct SecondMessage : solid::frame::mprpc::Message { - uint64_t v; + uint64_t v = -1; std::string str; SecondMessage() {} @@ -43,7 +43,7 @@ struct SecondMessage : solid::frame::mprpc::Message { }; struct ThirdMessage : solid::frame::mprpc::Message { - uint16_t v; + uint16_t v = -1; std::string str; ThirdMessage() {} diff --git a/solid/frame/mprpc/test/multiprotocol_basic/beta/betamessages.hpp b/solid/frame/mprpc/test/multiprotocol_basic/beta/betamessages.hpp index 6fa16963..0ede19bc 100644 --- a/solid/frame/mprpc/test/multiprotocol_basic/beta/betamessages.hpp +++ b/solid/frame/mprpc/test/multiprotocol_basic/beta/betamessages.hpp @@ -8,7 +8,7 @@ namespace beta_protocol { struct ThirdMessage : solid::frame::mprpc::Message { - uint16_t v; + uint16_t v = -1; std::string str; ThirdMessage() {} @@ -25,7 +25,7 @@ struct ThirdMessage : solid::frame::mprpc::Message { }; struct FirstMessage : solid::frame::mprpc::Message { - uint32_t v; + uint32_t v = -1; std::string str; FirstMessage() {} @@ -50,7 +50,7 @@ struct FirstMessage : solid::frame::mprpc::Message { }; struct SecondMessage : solid::frame::mprpc::Message { - uint64_t v; + uint64_t v = -1; std::string str; SecondMessage() {} diff --git a/solid/frame/mprpc/test/multiprotocol_basic/gamma/gammamessages.hpp b/solid/frame/mprpc/test/multiprotocol_basic/gamma/gammamessages.hpp index 747f1b4f..e77bc68a 100644 --- a/solid/frame/mprpc/test/multiprotocol_basic/gamma/gammamessages.hpp +++ b/solid/frame/mprpc/test/multiprotocol_basic/gamma/gammamessages.hpp @@ -8,7 +8,7 @@ namespace gamma_protocol { struct FirstMessage : solid::frame::mprpc::Message { - uint32_t v; + uint32_t v = -1; std::string str; FirstMessage() {} @@ -25,7 +25,7 @@ struct FirstMessage : solid::frame::mprpc::Message { }; struct SecondMessage : solid::frame::mprpc::Message { - uint64_t v; + uint64_t v = -1; std::string str; SecondMessage() {} @@ -42,7 +42,7 @@ struct SecondMessage : solid::frame::mprpc::Message { }; struct ThirdMessage : solid::frame::mprpc::Message { - uint16_t v; + uint16_t v = -1; std::string str; ThirdMessage() {} diff --git a/solid/frame/mprpc/test/test_clientfrontback_download.cpp b/solid/frame/mprpc/test/test_clientfrontback_download.cpp index d4b53eb7..425d9e9f 100644 --- a/solid/frame/mprpc/test/test_clientfrontback_download.cpp +++ b/solid/frame/mprpc/test/test_clientfrontback_download.cpp @@ -55,7 +55,7 @@ struct Response; struct Request : frame::mprpc::Message { string name_; ofstream ofs_; - bool send_request_; + bool send_request_ = false; Request() { @@ -80,7 +80,7 @@ struct Request : frame::mprpc::Message { }; struct Response : frame::mprpc::Message { - uint32_t error_; + uint32_t error_ = -1; ostringstream oss_; mutable istringstream iss_; frame::mprpc::MessagePointerT req_ptr_; @@ -181,7 +181,7 @@ struct Request : frame::mprpc::Message { string name_; frame::mprpc::MessagePointerT res_ptr_; frame::mprpc::RecipientId recipient_id_; - bool await_response_; + bool await_response_ = false; Request() { @@ -200,7 +200,7 @@ struct Request : frame::mprpc::Message { }; struct Response : frame::mprpc::Message { - uint32_t error_; + uint32_t error_ = -1; ostringstream oss_; mutable ifstream ifs_; diff --git a/solid/frame/mprpc/test/test_clientfrontback_upload.cpp b/solid/frame/mprpc/test/test_clientfrontback_upload.cpp index 112876ea..040da66c 100644 --- a/solid/frame/mprpc/test/test_clientfrontback_upload.cpp +++ b/solid/frame/mprpc/test/test_clientfrontback_upload.cpp @@ -93,7 +93,7 @@ struct Request : frame::mprpc::Message { }; struct Response : frame::mprpc::Message { - uint32_t error_; + uint32_t error_ = -1; frame::mprpc::RecipientId recipient_id_; frame::mprpc::MessagePointerT req_ptr_; @@ -209,9 +209,9 @@ struct Request : frame::mprpc::Message { using RequestPointerT = solid::frame::mprpc::MessagePointerT; struct Response : frame::mprpc::Message { - uint32_t error_; + uint32_t error_ = -1; RequestPointerT req_ptr_; - bool send_response_; + bool send_response_ = false; Response() { diff --git a/solid/frame/mprpc/test/test_clientserver_basic.cpp b/solid/frame/mprpc/test/test_clientserver_basic.cpp index 962f9292..2cde9458 100644 --- a/solid/frame/mprpc/test/test_clientserver_basic.cpp +++ b/solid/frame/mprpc/test/test_clientserver_basic.cpp @@ -91,17 +91,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } diff --git a/solid/frame/mprpc/test/test_clientserver_cancel_client.cpp b/solid/frame/mprpc/test/test_clientserver_cancel_client.cpp index 4c15651a..5e1be5a2 100644 --- a/solid/frame/mprpc/test/test_clientserver_cancel_client.cpp +++ b/solid/frame/mprpc/test/test_clientserver_cancel_client.cpp @@ -107,17 +107,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_s, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_clientserver_cancel_server.cpp b/solid/frame/mprpc/test/test_clientserver_cancel_server.cpp index b2dcc782..76a52cd0 100644 --- a/solid/frame/mprpc/test/test_clientserver_cancel_server.cpp +++ b/solid/frame/mprpc/test/test_clientserver_cancel_server.cpp @@ -94,7 +94,7 @@ size_t real_size(size_t _sz) } struct Message : frame::mprpc::Message { - uint32_t idx; + uint32_t idx = -1; std::string str; mutable bool serialized; @@ -102,17 +102,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_clientserver_delayed.cpp b/solid/frame/mprpc/test/test_clientserver_delayed.cpp index 1c82a97e..736c2c33 100644 --- a/solid/frame/mprpc/test/test_clientserver_delayed.cpp +++ b/solid/frame/mprpc/test/test_clientserver_delayed.cpp @@ -89,17 +89,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender() || (idx == 1)); } diff --git a/solid/frame/mprpc/test/test_clientserver_idempotent.cpp b/solid/frame/mprpc/test/test_clientserver_idempotent.cpp index 84acbcfa..1f17c871 100644 --- a/solid/frame/mprpc/test/test_clientserver_idempotent.cpp +++ b/solid/frame/mprpc/test/test_clientserver_idempotent.cpp @@ -81,17 +81,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this << " idx = " << idx << " str.size = " << str.size()); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this << " idx = " << idx << " str.size = " << str.size()); // if(!serialized && !this->isBackOnSender() && idx != 0){ // solid_throw("Message not serialized."); // } diff --git a/solid/frame/mprpc/test/test_clientserver_noserver.cpp b/solid/frame/mprpc/test/test_clientserver_noserver.cpp index 30424232..7d9a6d8c 100644 --- a/solid/frame/mprpc/test/test_clientserver_noserver.cpp +++ b/solid/frame/mprpc/test/test_clientserver_noserver.cpp @@ -76,17 +76,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(!serialized); } diff --git a/solid/frame/mprpc/test/test_clientserver_oneshot.cpp b/solid/frame/mprpc/test/test_clientserver_oneshot.cpp index c16569fb..cc4e3291 100644 --- a/solid/frame/mprpc/test/test_clientserver_oneshot.cpp +++ b/solid/frame/mprpc/test/test_clientserver_oneshot.cpp @@ -75,17 +75,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(!serialized); } @@ -141,6 +141,7 @@ using MessagePointerT = solid::frame::mprpc::MessagePointerT; void client_connection_stop(frame::mprpc::ConnectionContext& _rctx) { solid_dbg(generic_logger, Info, _rctx.recipientId() << " error: " << _rctx.error().message()); + lock_guard lock(mtx); if (!running) { ++connection_count; } @@ -298,7 +299,7 @@ int test_clientserver_oneshot(int argc, char* argv[]) } // exiting - + lock_guard lock(mtx); std::cout << "Transfered size = " << (transfered_size * 2) / 1024 << "KB" << endl; std::cout << "Transfered count = " << transfered_count << endl; std::cout << "Connection count = " << connection_count << endl; diff --git a/solid/frame/mprpc/test/test_clientserver_sendrequest.cpp b/solid/frame/mprpc/test/test_clientserver_sendrequest.cpp index 387a74f5..c3e5b6ed 100644 --- a/solid/frame/mprpc/test/test_clientserver_sendrequest.cpp +++ b/solid/frame/mprpc/test/test_clientserver_sendrequest.cpp @@ -81,22 +81,22 @@ size_t real_size(size_t _sz) } struct Request : frame::mprpc::Message { - uint32_t idx; + uint32_t idx = -1; std::string str; Request(uint32_t _idx) : idx(_idx) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Request() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Request() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) @@ -140,7 +140,7 @@ struct Request : frame::mprpc::Message { }; struct Response : frame::mprpc::Message { - uint32_t idx; + uint32_t idx = -1; std::string str; Response(const Request& _rreq) @@ -148,17 +148,17 @@ struct Response : frame::mprpc::Message { , idx(_rreq.idx) , str(_rreq.str) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } Response() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Response() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_clientserver_split.cpp b/solid/frame/mprpc/test/test_clientserver_split.cpp index 15085570..64e59bc0 100644 --- a/solid/frame/mprpc/test/test_clientserver_split.cpp +++ b/solid/frame/mprpc/test/test_clientserver_split.cpp @@ -91,14 +91,14 @@ struct Message : frame::mprpc::Message { , serialized(false) , response_count(0) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) , response_count(0) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } Message( @@ -113,7 +113,7 @@ struct Message : frame::mprpc::Message { ~Message() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } diff --git a/solid/frame/mprpc/test/test_clientserver_timeout_secure.cpp b/solid/frame/mprpc/test/test_clientserver_timeout_secure.cpp index 274102f8..10307fbb 100644 --- a/solid/frame/mprpc/test/test_clientserver_timeout_secure.cpp +++ b/solid/frame/mprpc/test/test_clientserver_timeout_secure.cpp @@ -50,7 +50,7 @@ frame::aio::Resolver& async_resolver(frame::aio::Resolver* _pres = nullptr) } struct Activate : frame::mprpc::Message { - uint32_t idx; + uint32_t idx = -1; std::string str; mutable bool serialized; @@ -58,17 +58,17 @@ struct Activate : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); } Activate() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Activate() override { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } @@ -129,9 +129,8 @@ class Connection : public frame::aio::Actor { solid_dbg(generic_logger, Info, "event = " << _revent); if (_revent == generic_event) { // we must resolve the address then connect - solid_dbg(generic_logger, Info, "async_resolve = " - << "127.0.0.1" - << " " << server_port); + solid_dbg(generic_logger, Info, "async_resolve = " << "127.0.0.1" + << " " << server_port); async_resolver().requestResolve( [&rm = _rctx.service().manager(), actor_id = _rctx.service().manager().id(*this), this](ResolveData& _rrd, ErrorCodeT const& /*_rerr*/) { solid_dbg(generic_logger, Info, this << " send resolv_message"); diff --git a/solid/frame/mprpc/test/test_clientserver_topic.cpp b/solid/frame/mprpc/test/test_clientserver_topic.cpp index 69d90f7e..c29bb8bf 100644 --- a/solid/frame/mprpc/test/test_clientserver_topic.cpp +++ b/solid/frame/mprpc/test/test_clientserver_topic.cpp @@ -675,7 +675,7 @@ void server_complete_request( reply_ptr->receive_time_point_ = microseconds_since_epoch(); reply_ptr->header(_rrecv_msg_ptr->header()); - cacheable_cache(std::move(_rrecv_msg_ptr)); + // cacheable_cache(std::move(_rrecv_msg_ptr)); auto lambda = [topic_ptr, _rrecv_msg_ptr = std::move(_rrecv_msg_ptr), &service = _rctx.service(), recipient_id = _rctx.recipientId(), reply_ptr = std::move(reply_ptr)]() { diff --git a/solid/frame/mprpc/test/test_clientserver_upload.cpp b/solid/frame/mprpc/test/test_clientserver_upload.cpp index b1be9b1d..e41f5aa7 100644 --- a/solid/frame/mprpc/test/test_clientserver_upload.cpp +++ b/solid/frame/mprpc/test/test_clientserver_upload.cpp @@ -85,9 +85,9 @@ struct Request : frame::mprpc::Message { using RequestPointerT = solid::frame::mprpc::MessagePointerT; struct Response : frame::mprpc::Message { - uint32_t error_; + uint32_t error_ = -1; RequestPointerT req_ptr_; - bool send_response_; + bool send_response_ = false; Response() { diff --git a/solid/frame/mprpc/test/test_clientserver_upload_single.cpp b/solid/frame/mprpc/test/test_clientserver_upload_single.cpp index e7ae6864..ba62ed5a 100644 --- a/solid/frame/mprpc/test/test_clientserver_upload_single.cpp +++ b/solid/frame/mprpc/test/test_clientserver_upload_single.cpp @@ -90,9 +90,9 @@ struct Request : frame::mprpc::Message { using RequestPointerT = solid::frame::mprpc::MessagePointerT; struct Response : frame::mprpc::Message { - uint32_t error_; + uint32_t error_ = -1; RequestPointerT req_ptr_; - bool send_response_; + bool send_response_ = false; Response() { diff --git a/solid/frame/mprpc/test/test_connection_close.cpp b/solid/frame/mprpc/test/test_connection_close.cpp index c2b2e8f7..28c2eeb5 100644 --- a/solid/frame/mprpc/test/test_connection_close.cpp +++ b/solid/frame/mprpc/test/test_connection_close.cpp @@ -71,17 +71,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } diff --git a/solid/frame/mprpc/test/test_keepalive_fail.cpp b/solid/frame/mprpc/test/test_keepalive_fail.cpp index f34d6bb1..96d66056 100644 --- a/solid/frame/mprpc/test/test_keepalive_fail.cpp +++ b/solid/frame/mprpc/test/test_keepalive_fail.cpp @@ -97,16 +97,16 @@ struct Message : frame::mprpc::Message { Message(uint32_t _idx) : idx(_idx) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_keepalive_success.cpp b/solid/frame/mprpc/test/test_keepalive_success.cpp index 791ffd16..d610dc06 100644 --- a/solid/frame/mprpc/test/test_keepalive_success.cpp +++ b/solid/frame/mprpc/test/test_keepalive_success.cpp @@ -96,16 +96,16 @@ struct Message : frame::mprpc::Message { Message(uint32_t _idx) : idx(_idx) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_pool_basic.cpp b/solid/frame/mprpc/test/test_pool_basic.cpp index 63c0d3a0..1034b0eb 100644 --- a/solid/frame/mprpc/test/test_pool_basic.cpp +++ b/solid/frame/mprpc/test/test_pool_basic.cpp @@ -90,17 +90,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } diff --git a/solid/frame/mprpc/test/test_pool_delay_close.cpp b/solid/frame/mprpc/test/test_pool_delay_close.cpp index 70853c55..638eed8a 100644 --- a/solid/frame/mprpc/test/test_pool_delay_close.cpp +++ b/solid/frame/mprpc/test/test_pool_delay_close.cpp @@ -79,17 +79,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); // if(!serialized && !this->isBackOnSender()){ // solid_throw("Message not serialized."); // } diff --git a/solid/frame/mprpc/test/test_pool_force_close.cpp b/solid/frame/mprpc/test/test_pool_force_close.cpp index f189d77f..733b02d1 100644 --- a/solid/frame/mprpc/test/test_pool_force_close.cpp +++ b/solid/frame/mprpc/test/test_pool_force_close.cpp @@ -88,17 +88,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); // if(!serialized && !this->isBackOnSender()){ // solid_throw("Message not serialized."); // } diff --git a/solid/frame/mprpc/test/test_protocol_basic.cpp b/solid/frame/mprpc/test/test_protocol_basic.cpp index f151c37e..210c6deb 100644 --- a/solid/frame/mprpc/test/test_protocol_basic.cpp +++ b/solid/frame/mprpc/test/test_protocol_basic.cpp @@ -59,22 +59,22 @@ size_t real_size(size_t _sz) } struct Message : frame::mprpc::Message { - uint32_t idx; + uint32_t idx = -1; std::string str; Message(uint32_t _idx) : idx(_idx) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_protocol_cancel.cpp b/solid/frame/mprpc/test/test_protocol_cancel.cpp index b698d267..2b95d01d 100644 --- a/solid/frame/mprpc/test/test_protocol_cancel.cpp +++ b/solid/frame/mprpc/test/test_protocol_cancel.cpp @@ -55,16 +55,16 @@ struct Message : frame::mprpc::Message { Message(uint32_t _idx) : idx(_idx) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_protocol_synchronous.cpp b/solid/frame/mprpc/test/test_protocol_synchronous.cpp index ba27bcfd..7729e699 100644 --- a/solid/frame/mprpc/test/test_protocol_synchronous.cpp +++ b/solid/frame/mprpc/test/test_protocol_synchronous.cpp @@ -49,16 +49,16 @@ struct Message : frame::mprpc::Message { Message(uint32_t _idx) : idx(_idx) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); } SOLID_REFLECT_V1(_rr, _rthis, _rctx) diff --git a/solid/frame/mprpc/test/test_raw_basic.cpp b/solid/frame/mprpc/test/test_raw_basic.cpp index b3b2270b..150fde3a 100644 --- a/solid/frame/mprpc/test/test_raw_basic.cpp +++ b/solid/frame/mprpc/test/test_raw_basic.cpp @@ -102,17 +102,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } diff --git a/solid/frame/mprpc/test/test_raw_proxy.cpp b/solid/frame/mprpc/test/test_raw_proxy.cpp index f9229ef7..956a8594 100644 --- a/solid/frame/mprpc/test/test_raw_proxy.cpp +++ b/solid/frame/mprpc/test/test_raw_proxy.cpp @@ -101,17 +101,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } @@ -159,6 +159,7 @@ using MessagePointerT = solid::frame::mprpc::MessagePointerT; void client_connection_stop(frame::mprpc::ConnectionContext& _rctx) { solid_dbg(generic_logger, Info, _rctx.recipientId() << " error: " << _rctx.error().message()); + lock_guard lock(mtx); if (!running) { ++connection_count; } @@ -445,7 +446,7 @@ int test_raw_proxy(int argc, char* argv[]) } // exiting - + lock_guard lock(mtx); std::cout << "Transfered size = " << (transfered_size * 2) / 1024 << "KB" << endl; std::cout << "Transfered count = " << transfered_count << endl; std::cout << "Connection count = " << connection_count << endl; diff --git a/solid/frame/mprpc/test/test_relay_cancel_request.cpp b/solid/frame/mprpc/test/test_relay_cancel_request.cpp index 030f197c..c0c48f6a 100644 --- a/solid/frame/mprpc/test/test_relay_cancel_request.cpp +++ b/solid/frame/mprpc/test/test_relay_cancel_request.cpp @@ -147,7 +147,7 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); ++created_count; if (cancelable()) { @@ -158,11 +158,11 @@ struct Message : frame::mprpc::Message { : serialized(false) { ++created_count; - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this << " idx = " << idx); if (cancelable()) { ++cancelable_deleted_count; diff --git a/solid/frame/mprpc/test/test_relay_cancel_response.cpp b/solid/frame/mprpc/test/test_relay_cancel_response.cpp index 1667c344..d61feaa7 100644 --- a/solid/frame/mprpc/test/test_relay_cancel_response.cpp +++ b/solid/frame/mprpc/test/test_relay_cancel_response.cpp @@ -148,7 +148,7 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); ++created_count; if (cancelable()) { @@ -159,11 +159,11 @@ struct Message : frame::mprpc::Message { : serialized(false) { ++created_count; - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); if (cancelable()) { ++cancelable_deleted_count; diff --git a/solid/frame/mprpc/test/test_relay_close_request.cpp b/solid/frame/mprpc/test/test_relay_close_request.cpp index 8f21c6e3..505363aa 100644 --- a/solid/frame/mprpc/test/test_relay_close_request.cpp +++ b/solid/frame/mprpc/test/test_relay_close_request.cpp @@ -131,7 +131,7 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); ++created_count; } @@ -139,11 +139,11 @@ struct Message : frame::mprpc::Message { : serialized(false) { ++created_count; - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this << " idx = " << idx); ++deleted_count; try_stop(); @@ -160,6 +160,7 @@ struct Message : frame::mprpc::Message { if constexpr (!Reflector::is_const_reflector) { _rr.add([&_rthis](Reflector& _rr, frame::mprpc::ConnectionContext& _rctx) { if (_rthis.cancelable()) { + lock_guard lock(mtx); solid_dbg(generic_logger, Error, "Close connection: " << _rthis.idx << " " << msgid_vec[_rthis.idx].first); // we're on the peerb, // we now cancel the message on peer a diff --git a/solid/frame/mprpc/test/test_relay_close_response.cpp b/solid/frame/mprpc/test/test_relay_close_response.cpp index a7df6bec..84db8c9a 100644 --- a/solid/frame/mprpc/test/test_relay_close_response.cpp +++ b/solid/frame/mprpc/test/test_relay_close_response.cpp @@ -134,7 +134,7 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); ++created_count; } @@ -142,11 +142,11 @@ struct Message : frame::mprpc::Message { : serialized(false) { ++created_count; - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); ++deleted_count; try_stop(); @@ -160,6 +160,7 @@ struct Message : frame::mprpc::Message { ++back_on_sender_count; solid_assert(back_on_sender_count <= writecount); if (back_on_sender_count == writecount) { + lock_guard lock(mtx); solid_dbg(generic_logger, Info, "Close connection: " << _rthis.idx << " " << msgid_vec[_rthis.idx].first); // we're on the peerb, // we now cancel the message on peer a diff --git a/solid/frame/mprpc/test/test_relay_disabled.cpp b/solid/frame/mprpc/test/test_relay_disabled.cpp index fba6eb06..88c53b01 100644 --- a/solid/frame/mprpc/test/test_relay_disabled.cpp +++ b/solid/frame/mprpc/test/test_relay_disabled.cpp @@ -124,17 +124,17 @@ struct Message : frame::mprpc::Message { : idx(_idx) , serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); // solid_assert(serialized || this->isBackOnSender()); } @@ -200,6 +200,7 @@ void peera_connection_start(frame::mprpc::ConnectionContext& _rctx) void peera_connection_stop(frame::mprpc::ConnectionContext& _rctx) { solid_dbg(generic_logger, Info, _rctx.recipientId() << " error: " << _rctx.error().message()); + lock_guard lock(mtx); if (!running) { ++connection_count; } @@ -528,7 +529,7 @@ int test_relay_disabled(int argc, char* argv[]) } // exiting - + lock_guard lock(mtx); std::cout << "Transfered size = " << (transfered_size * 2) / 1024 << "KB" << endl; std::cout << "Transfered count = " << transfered_count << endl; std::cout << "Connection count = " << connection_count << endl; diff --git a/solid/frame/mprpc/test/test_relay_split.cpp b/solid/frame/mprpc/test/test_relay_split.cpp index a5fbd7eb..b08b143b 100644 --- a/solid/frame/mprpc/test/test_relay_split.cpp +++ b/solid/frame/mprpc/test/test_relay_split.cpp @@ -126,14 +126,14 @@ struct Message : frame::mprpc::Message { , serialized(false) , response_count(0) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this << " idx = " << idx); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this << " idx = " << idx); init(); } Message() : serialized(false) , response_count(0) { - solid_dbg(generic_logger, Info, "CREATE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "CREATE ---------------- " << this); } Message( @@ -148,7 +148,7 @@ struct Message : frame::mprpc::Message { ~Message() { - solid_dbg(generic_logger, Info, "DELETE ---------------- " << (void*)this); + solid_dbg(generic_logger, Info, "DELETE ---------------- " << this); solid_assert(serialized || this->isBackOnSender()); } diff --git a/solid/frame/scheduler.hpp b/solid/frame/scheduler.hpp index 1a571886..dd684986 100644 --- a/solid/frame/scheduler.hpp +++ b/solid/frame/scheduler.hpp @@ -163,20 +163,22 @@ class Scheduler : private SchedulerBase { ActorPointerT&& _ractptr, Service& _rsvc, EventBase&& _revt, ErrorConditionT& _rerr) { + auto& ractor = *_ractptr; ScheduleCommand cmd(std::move(_ractptr), _rsvc, std::move(_revt)); ScheduleFunctionT fct([&cmd](ReactorBase& _rreactor) { return cmd(_rreactor); }); - return doStartActor(*_ractptr, _rsvc, fct, _rerr); + return doStartActor(ractor, _rsvc, fct, _rerr); } ActorIdT startActor( ActorPointerT&& _ractptr, Service& _rsvc, const size_t _worker_index, EventBase&& _revt, ErrorConditionT& _rerr) { + auto& ractor = *_ractptr; ScheduleCommand cmd(std::move(_ractptr), _rsvc, std::move(_revt)); ScheduleFunctionT fct([&cmd](ReactorBase& _rreactor) { return cmd(_rreactor); }); - return doStartActor(*_ractptr, _rsvc, _worker_index, fct, _rerr); + return doStartActor(ractor, _rsvc, _worker_index, fct, _rerr); } }; diff --git a/solid/frame/service.hpp b/solid/frame/service.hpp index 08cfb97e..6e79ef9e 100644 --- a/solid/frame/service.hpp +++ b/solid/frame/service.hpp @@ -81,7 +81,7 @@ class Service : NonCopyable { template bool forEach(F& _rf); - void stop(const bool _wait = true); + void stop(const bool _wait = true, const bool _check = true); Manager& manager(); @@ -147,7 +147,7 @@ inline Service::Service( inline Service::~Service() { - stop(true); + stop(true, false); rm_.unregisterService(*this); } @@ -211,9 +211,9 @@ inline void Service::doStartWithoutAny(F&& _on_locked_start) *this, [&_on_locked_start](std::unique_lock& _lock) { _on_locked_start(_lock); }); } -inline void Service::stop(const bool _wait) +inline void Service::stop(const bool _wait, const bool _check) { - rm_.stopService(*this, _wait); + rm_.stopService(*this, _wait, _check); } inline Service::ActorMutexT& Service::mutex(const ActorBase& _ract) const @@ -272,7 +272,7 @@ class ServiceShell final : public S { ~ServiceShell() { - Service::stop(true); + Service::stop(true, false); } template diff --git a/solid/frame/src/completion.cpp b/solid/frame/src/completion.cpp index 5608633f..cf8928c4 100644 --- a/solid/frame/src/completion.cpp +++ b/solid/frame/src/completion.cpp @@ -97,7 +97,7 @@ void CompletionHandler::unregister() } } -void CompletionHandler::deactivate() +void CompletionHandler::deactivate(const bool _check) { impl::Reactor* preactor = nullptr; if (isActive() && (preactor = impl::Reactor::safeSpecific()) != nullptr) { @@ -105,8 +105,8 @@ void CompletionHandler::deactivate() preactor->unregisterCompletionHandler(*this); idxreactor = InvalidIndex(); } - if (isActive()) { - solid_throw_log(generic_logger, "FATAL: CompletionHandler deleted/deactivated outside actor's reactor!"); + if (_check) { + solid_check_log(!isActive(), generic_logger, "FATAL: CompletionHandler deleted/deactivated outside actor's reactor!"); } } diff --git a/solid/frame/src/manager.cpp b/solid/frame/src/manager.cpp index 046e57fd..df57df94 100644 --- a/solid/frame/src/manager.cpp +++ b/solid/frame/src/manager.cpp @@ -986,10 +986,11 @@ void Manager::doStartService(Service& _rservice, const OnLockedStartFunctionT& _ } } -void Manager::stopService(Service& _rservice, const bool _wait) +void Manager::stopService(Service& _rservice, const bool _wait, const bool _check) { - solid_check_log(_rservice.registered(), frame_logger, "Service not registered"); - + if (_check) { + solid_check_log(_rservice.registered(), frame_logger, "Service not registered"); + } doStopService(_rservice.index(), _wait); } diff --git a/solid/frame/timer.hpp b/solid/frame/timer.hpp index 147ebed7..caa6c628 100644 --- a/solid/frame/timer.hpp +++ b/solid/frame/timer.hpp @@ -68,7 +68,7 @@ class SteadyTimer : public CompletionHandler { ~SteadyTimer() { // MUST call here and not in the ~CompletionHandler - this->deactivate(); + this->deactivate(false); } bool hasPending() const diff --git a/solid/frame/timestore.hpp b/solid/frame/timestore.hpp index 676703b5..5f79a6f7 100644 --- a/solid/frame/timestore.hpp +++ b/solid/frame/timestore.hpp @@ -265,12 +265,13 @@ size_t TimeStore::doPop(const time_store_impl::IntervalE _iv, const NanoTime& _n solid_assert(rnode.internal_index_ == i); rval = rinterval.values_.back(); - rinterval.values_.pop_back(); proxy_nodes_[rval.proxy_index_].internal_index_ = i; rnode.clear(); proxy_free_list_.pushBack(proxy_index); + rinterval.values_.pop_back(); + _fnc(value, expiry, proxy_index); ++count; } diff --git a/solid/serialization/v3/binarydeserializer.hpp b/solid/serialization/v3/binarydeserializer.hpp index 3f4afdb4..6ce837fd 100644 --- a/solid/serialization/v3/binarydeserializer.hpp +++ b/solid/serialization/v3/binarydeserializer.hpp @@ -961,7 +961,7 @@ class DeserializerBase : public Base { template class Deserializer : public DeserializerBase { - TypeId type_id_; + TypeId type_id_ = InvalidIndex{}; const MetadataFactory& rmetadata_factory_; public: diff --git a/solid/serialization/v3/binaryserializer.hpp b/solid/serialization/v3/binaryserializer.hpp index c42f9ee9..82a4e20b 100644 --- a/solid/serialization/v3/binaryserializer.hpp +++ b/solid/serialization/v3/binaryserializer.hpp @@ -795,7 +795,7 @@ class SerializerBase : public Base { template class Serializer : public SerializerBase { const MetadataFactory& rmetadata_factory_; - TypeId type_id_; + TypeId type_id_ = InvalidIndex{}; public: using ContextT = Context; diff --git a/solid/serialization/v3/test/test_binary.cpp b/solid/serialization/v3/test/test_binary.cpp index ee7a78b9..58d3ad63 100644 --- a/solid/serialization/v3/test/test_binary.cpp +++ b/solid/serialization/v3/test/test_binary.cpp @@ -53,7 +53,7 @@ class Test { static constexpr size_t BlobCapacity = 40 * 1024; string p; - bool b; + bool b = false; vector v; deque d; map m; @@ -67,12 +67,12 @@ class Test { array a1; array a2; array a3; - uint16_t a2_sz; - uint32_t blob_sz; + uint16_t a2_sz = 0; + uint32_t blob_sz = 0; char blob[BlobCapacity]; - uint32_t blob32_sz; + uint32_t blob32_sz = 0; char blob32[sizeof(uint32_t)]; - uint32_t blob64_sz; + uint32_t blob64_sz = 0; char blob64[sizeof(uint64_t)]; std::ostringstream oss; @@ -83,6 +83,7 @@ class Test { b = _b; a.a = 540554784UL; a.b = 2321664020290347053ULL; + a.c = 1234567890123456789ULL; serialization::binary::store(blob32, static_cast(a.a)); { uint32_t v; @@ -119,6 +120,7 @@ class Test { A a; a.a = static_cast(i); a.b = 10 - i; + a.c = 10 + i; a.s = to_string(a.a) + ' ' + to_string(a.b); blb += a.s; s.insert(a.s); diff --git a/solid/serialization/v3/test/test_container.cpp b/solid/serialization/v3/test/test_container.cpp index 8e18384e..e2f67a8c 100644 --- a/solid/serialization/v3/test/test_container.cpp +++ b/solid/serialization/v3/test/test_container.cpp @@ -42,7 +42,7 @@ struct Test { KeyValueVectorT kv_vec; MapT kv_map; MapBoolT kb_map; - uint32_t v32; + uint32_t v32 = -1; deque bool_deq; bitset<5> bs5; bitset<10> bs10; diff --git a/solid/serialization/v3/test/test_polymorphic.cpp b/solid/serialization/v3/test/test_polymorphic.cpp index f5a00a84..15578a04 100644 --- a/solid/serialization/v3/test/test_polymorphic.cpp +++ b/solid/serialization/v3/test/test_polymorphic.cpp @@ -77,7 +77,7 @@ struct OrVecKey : Key { }; struct IntKey : Key { - int v; + int v = -1; IntKey() {} IntKey(int _v) diff --git a/solid/system/chunkedstream.hpp b/solid/system/chunkedstream.hpp index d67e56c9..782407f4 100644 --- a/solid/system/chunkedstream.hpp +++ b/solid/system/chunkedstream.hpp @@ -82,6 +82,7 @@ class ChunkedBufferBase : public std::streambuf { , pend_(nullptr) , size_(0) , pinode_(nullptr) + , isize_(0) { } diff --git a/solid/system/socketaddress.hpp b/solid/system/socketaddress.hpp index c369b093..ce515cba 100644 --- a/solid/system/socketaddress.hpp +++ b/solid/system/socketaddress.hpp @@ -84,9 +84,10 @@ struct DirectResoveInfo { struct ResolveData { typedef ResolveIterator const_iterator; - ResolveData(); + ResolveData() = default; ResolveData(addrinfo* _pai); ResolveData(const ResolveData& _rai); + ResolveData(ResolveData&& _rai); ~ResolveData(); //! Get an iterator to he first resolved ip address @@ -96,6 +97,7 @@ struct ResolveData { bool empty() const; void clear(); ResolveData& operator=(const ResolveData& _rrd); + ResolveData& operator=(ResolveData&& _rrd); private: static void delete_addrinfo(void* _pv); @@ -188,8 +190,8 @@ struct SocketAddressStub { const sockaddr* sockAddr() const; private: - const sockaddr* addr; - socklen_t sz; + const sockaddr* addr = nullptr; + socklen_t sz = 0; }; //================================================================== //! Holds a generic socket address @@ -492,7 +494,7 @@ struct SocketAddressLocal { operator sockaddr*(); sockaddr* sockAddr(); AddrUnion d; - socklen_t sz; + socklen_t sz = 0; }; #endif //================================================================== diff --git a/solid/system/socketaddress.ipp b/solid/system/socketaddress.ipp index 18c294b5..ed19587d 100644 --- a/solid/system/socketaddress.ipp +++ b/solid/system/socketaddress.ipp @@ -64,9 +64,6 @@ inline ResolveIterator::ResolveIterator(addrinfo* _pa) //----------------------------------------------------------------------- // ResolveData //----------------------------------------------------------------------- -inline ResolveData::ResolveData() -{ -} inline ResolveData::ResolveData(addrinfo* _pai) : aiptr(_pai, &delete_addrinfo) { @@ -75,6 +72,10 @@ inline ResolveData::ResolveData(const ResolveData& _rai) : aiptr(_rai.aiptr) { } +inline ResolveData::ResolveData(ResolveData&& _rai) + : aiptr(std::move(_rai.aiptr)) +{ +} inline ResolveData::~ResolveData() { } @@ -104,6 +105,11 @@ inline ResolveData& ResolveData::operator=(const ResolveData& _rrd) aiptr = _rrd.aiptr; return *this; } +inline ResolveData& ResolveData::operator=(ResolveData&& _rrd) +{ + aiptr = std::move(_rrd.aiptr); + return *this; +} //----------------------------------------------------------------------- // SocketAddressStub @@ -202,7 +208,7 @@ inline SocketAddressStub::operator const sockaddr*() const } inline void SocketAddressStub::clear() { - addr = NULL; + addr = nullptr; sz = 0; } inline SocketInfo::Family SocketAddressStub::family() const diff --git a/solid/system/src/device.cpp b/solid/system/src/device.cpp index 8e7fa744..e6e8961b 100644 --- a/solid/system/src/device.cpp +++ b/solid/system/src/device.cpp @@ -647,13 +647,16 @@ ErrorCodeT SocketDevice::makeBlocking() } return ErrorCodeT(); #else - int flg = fcntl(descriptor(), F_GETFL); - if (flg == -1) { + int rv = fcntl(descriptor(), F_GETFL); + if (rv < 0) { return last_socket_error(); } - flg &= ~O_NONBLOCK; - /*int rv = */ fcntl(descriptor(), F_SETFL, flg); - return last_socket_error(); + rv &= ~O_NONBLOCK; + rv = fcntl(descriptor(), F_SETFL, rv); + if (rv < 0) { + return last_socket_error(); + } + return ErrorCodeT(); #endif } diff --git a/solid/system/src/log.cpp b/solid/system/src/log.cpp index d7467468..1e2ecb5c 100644 --- a/solid/system/src/log.cpp +++ b/solid/system/src/log.cpp @@ -502,7 +502,7 @@ struct FileRecorder : LogRecorder { filePath(from_path, 0, path_, name_); filePath(to_path, lastpos, path_, name_); Directory::renameFile(from_path.c_str(), to_path.c_str()); - fname = from_path; + fname = std::move(from_path); } if (!fd.create(fname.c_str(), FileDevice::WriteOnlyE)) { diff --git a/solid/system/src/memory.cpp b/solid/system/src/memory.cpp index b4111efa..b746d983 100644 --- a/solid/system/src/memory.cpp +++ b/solid/system/src/memory.cpp @@ -146,7 +146,9 @@ size_t getMemorySize() #elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) /* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */ - return static_cast(sysconf(_SC_PHYS_PAGES)) * static_cast(sysconf(_SC_PAGESIZE)); + const auto pc = sysconf(_SC_PHYS_PAGES); + const auto ps = sysconf(_SC_PAGESIZE); + return static_cast(pc > 0 ? pc : 0) * static_cast(ps > 0 ? ps : 0); #elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE) /* Legacy. -------------------------------------------------- */ diff --git a/solid/utility/any.hpp b/solid/utility/any.hpp index aad5ff58..6eb02c89 100644 --- a/solid/utility/any.hpp +++ b/solid/utility/any.hpp @@ -97,7 +97,9 @@ struct SmallRTTI { { static_cast(_what)->~T(); } - + static void dummy_destroy(void* const _what) noexcept + { + } DestroyFncT* pdestroy_fnc_; CopyFncT* pcopy_fnc_; MoveFncT* pmove_fnc_; @@ -136,6 +138,30 @@ template inline constexpr SmallRTTI small_rtti = { &SmallRTTI::destroy, &do_copy, &do_move, &do_get_if, std::is_copy_constructible_v, std::is_move_constructible_v, is_specialization_v}; +inline RepresentationE do_dummy_copy( + const void* _pfrom, + void* _pto_small, const size_t _small_cap, const SmallRTTI*& _rpsmall_rtti, + void*& _rpto_big, const BigRTTI*& _rpbig_rtti) +{ + return RepresentationE::None; +} + +inline RepresentationE do_dummy_move( + void* _pfrom, + void* _pto_small, const size_t _small_cap, const SmallRTTI*& _rpsmall_rtti, + void*& _rpto_big, const BigRTTI*& _rpbig_rtti) +{ + return RepresentationE::None; +} + +inline const void* do_dummy_get_if(const std::type_index& _type_index, const void* _pdata) +{ + return nullptr; +} + +inline constexpr SmallRTTI dummy_small_rtti = { + &SmallRTTI::dummy_destroy, &do_dummy_copy, &do_dummy_move, &do_dummy_get_if, false, false, false}; + template RepresentationE do_copy( const void* _pfrom, diff --git a/solid/utility/event.hpp b/solid/utility/event.hpp index 9d998caf..eddf6e8e 100644 --- a/solid/utility/event.hpp +++ b/solid/utility/event.hpp @@ -47,7 +47,7 @@ class EventBase { const any_impl::SmallRTTI* psmall_; const any_impl::BigRTTI* pbig_; } rtti_; - void* pdata_; + void* pdata_ = nullptr; public: std::ostream& print(std::ostream& _ros) const; @@ -171,13 +171,16 @@ class EventBase { const uintptr_t _id) : pcategory_(&_rcategory) , id_(_id) + { + rtti_.psmall_ = &any_impl::dummy_small_rtti; } EventBase(const EventBase& _other) : pcategory_(_other.pcategory_) , id_(_other.id_) { + rtti_.psmall_ = _other.rtti_.psmall_; } ~EventBase() diff --git a/solid/utility/ioformat.hpp b/solid/utility/ioformat.hpp index 1387a88b..46294456 100644 --- a/solid/utility/ioformat.hpp +++ b/solid/utility/ioformat.hpp @@ -45,7 +45,7 @@ inline TrimString trim_str(const char* _pcstr, size_t _strlen, size_t _beglen, s } std::ostream& operator<<(std::ostream& _ros, TrimString const&); - +#if 1 template struct Format; @@ -87,4 +87,6 @@ std::ostream& operator<<(std::ostream& _ros, Format const& _rfmt) return _ros; } +#endif + } // namespace solid diff --git a/solid/utility/sharedbuffer.hpp b/solid/utility/sharedbuffer.hpp index aedaf44f..7d4df75d 100644 --- a/solid/utility/sharedbuffer.hpp +++ b/solid/utility/sharedbuffer.hpp @@ -16,7 +16,7 @@ class SharedBuffer { Data* pnext_ = nullptr; std::size_t size_ = 0; std::size_t capacity_ = 0; - char* buffer_; + char* buffer_ = nullptr; char data_[8]; Data() diff --git a/solid/utility/src/memoryfile.cpp b/solid/utility/src/memoryfile.cpp index c378c0ac..e6dd1219 100644 --- a/solid/utility/src/memoryfile.cpp +++ b/solid/utility/src/memoryfile.cpp @@ -126,9 +126,7 @@ ssize_t MemoryFile::read(char* _pb, size_t _bl, int64_t _off) ++buffidx; } } - if (_bl != 0 && rd == 0) { - return -1; - } + return rd; } diff --git a/solid/utility/src/utility.cpp b/solid/utility/src/utility.cpp index 1fd43b44..1253f051 100644 --- a/solid/utility/src/utility.cpp +++ b/solid/utility/src/utility.cpp @@ -129,9 +129,7 @@ uint64_t make_number(std::string _str) } _str.pop_back(); } - std::istringstream iss{_str}; - uint64_t n; - iss >> n; + const uint64_t n = std::stoull(_str); return n * mul; } diff --git a/solid/utility/test/CMakeLists.txt b/solid/utility/test/CMakeLists.txt index 835317c1..4ea4dd4e 100644 --- a/solid/utility/test/CMakeLists.txt +++ b/solid/utility/test/CMakeLists.txt @@ -71,18 +71,44 @@ add_test(NAME TestUtilityFunction COMMAND test_utility te add_test(NAME TestUtilityTemplateFunction COMMAND test_utility test_template_function) add_test(NAME TestUtilityFunctionAnySpeedFullSolid COMMAND test_utility test_function_any_speed_full_solid) add_test(NAME TestUtilityFunctionAnySpeedFullStl COMMAND test_utility test_function_any_speed_full_stl) -add_test(NAME TestUtilityThreadpoolMulticastBasic COMMAND test_utility test_threadpool_multicast_basic) -add_test(NAME TestUtilityThreadpoolMulticastSleep COMMAND test_utility test_threadpool_multicast_sleep) -add_test(NAME TestUtilityCallPoolMulticastBasic COMMAND test_utility test_callpool_multicast_basic) -add_test(NAME TestUtilityCallPoolMulticastPattern COMMAND test_utility test_callpool_multicast_pattern) -add_test(NAME TestUtilityCallPoolMulticastSynchCtxBasic COMMAND test_utility test_threadpool_multicast_synchronization_context_basic) -add_test(NAME TestUtilityFunctionPerf_s_2_10000_1000 COMMAND test_utility test_function_perf s 2 10000 1000) -add_test(NAME TestUtilityFunctionPerf_S_2_10000_1000 COMMAND test_utility test_function_perf S 2 10000 1000) add_test(NAME TestUtilitySharedBuffer COMMAND test_utility test_shared_buffer) add_test(NAME TestCollapse_B COMMAND test_utility test_collapse B) add_test(NAME TestCollapse_p COMMAND test_utility test_collapse p 10 4) add_test(NAME TestCollapse_b COMMAND test_utility test_collapse b 10 4) add_test(NAME TestIntrusivePtr COMMAND test_utility test_intrusiveptr) +add_test(NAME TestUtilityFunctionPerf_s_2_10000_1000 COMMAND test_utility test_function_perf s 2 10000 1000) +add_test(NAME TestUtilityFunctionPerf_S_2_10000_1000 COMMAND test_utility test_function_perf S 2 10000 1000) + +set_tests_properties( + TestUtilityIoFormat + TestUtilityInvalidIndex + TestUtilityInnerList + TestUtilityAny + TestUtilityAnyTuple + TestUtilityQueue + TestUtilityEvent + TestUtilityMemoryFile + TestUtilityMemoryFile2M + TestUtilityMemoryFile3M + TestUtilityMemoryFile5M + TestUtilityFunction + TestUtilityTemplateFunction + TestUtilityFunctionAnySpeedFullSolid + TestUtilityFunctionAnySpeedFullStl + TestUtilitySharedBuffer + TestCollapse_B + TestCollapse_p + TestCollapse_b + TestIntrusivePtr + TestUtilityFunctionPerf_s_2_10000_1000 + TestUtilityFunctionPerf_S_2_10000_1000 + PROPERTIES LABELS "utility basic" +) +add_test(NAME TestUtilityThreadpoolMulticastBasic COMMAND test_utility test_threadpool_multicast_basic) +add_test(NAME TestUtilityThreadpoolMulticastSleep COMMAND test_utility test_threadpool_multicast_sleep) +add_test(NAME TestUtilityCallPoolMulticastBasic COMMAND test_utility test_callpool_multicast_basic) +add_test(NAME TestUtilityCallPoolMulticastPattern COMMAND test_utility test_callpool_multicast_pattern) +add_test(NAME TestUtilityCallPoolMulticastSynchCtxBasic COMMAND test_utility test_threadpool_multicast_synchronization_context_basic) add_test(NAME TestThreadPoolThreadContext COMMAND test_threadpool test_threadpool_thread_context) add_test(NAME TestThreadPoolContext COMMAND test_threadpool test_threadpool_context) add_test(NAME TestThreadPoolPattern COMMAND test_threadpool test_threadpool_pattern) @@ -106,4 +132,34 @@ add_test(NAME TestThreadPool_2_4 COMMAND test_threadpool add_test(NAME TestThreadPool_3_4 COMMAND test_threadpool test_threadpool 10 10 0 4 4 0 100) add_test(NAME TestThreadPool_4_4 COMMAND test_threadpool test_threadpool 1 10 0 4 4 100 100) +set_tests_properties( + TestUtilityThreadpoolMulticastBasic TestUtilityThreadpoolMulticastSleep + TestUtilityCallPoolMulticastBasic + TestUtilityCallPoolMulticastPattern + TestUtilityCallPoolMulticastSynchCtxBasic + TestThreadPoolThreadContext + TestThreadPoolContext + TestThreadPoolPattern + TestThreadPoolBasic + TestThreadPoolChain2 + TestThreadPoolChain4 + TestThreadPoolChain8 + TestThreadPoolChain10 + TestThreadPool + TestThreadPool_0 + TestThreadPool_1 + TestThreadPool_2 + TestThreadPool_3 + TestThreadPool_4 + TestThreadPool_1_2 + TestThreadPool_2_2 + TestThreadPool_3_2 + TestThreadPool_4_2 + TestThreadPool_1_4 + TestThreadPool_2_4 + TestThreadPool_3_4 + TestThreadPool_4_4 + PROPERTIES LABELS "utility threadpool" +) + #============================================================================== diff --git a/solid/utility/test/test_threadpool.cpp b/solid/utility/test/test_threadpool.cpp index bd77d838..0f04497f 100644 --- a/solid/utility/test/test_threadpool.cpp +++ b/solid/utility/test/test_threadpool.cpp @@ -90,10 +90,11 @@ int test_threadpool(int argc, char* argv[]) } // 1000 10 0 0 1 0 0 auto lambda = [&]() { + Context ctx(gdq, gmtx); ThreadPoolT wp{ - {consumer_count, queue_size, 0}, [](size_t, Context&&) {}, [](size_t, Context&&) {}, + {consumer_count, queue_size, 0}, [](size_t, Context&) {}, [](size_t, Context&) {}, - [job_sleep_msecs](size_t _v, Context&& _rctx) { + [job_sleep_msecs](size_t _v, Context& _rctx) { // solid_check(_rs == "this is a string", "failed string check"); val += _v; if (job_sleep_msecs != 0) { @@ -103,8 +104,8 @@ int test_threadpool(int argc, char* argv[]) _rctx.ldq_.emplace_back(_v); #endif }, - [](size_t, Context&&) {}, - Context(gdq, gmtx)}; + [](size_t, const Context&) {}, + ref(ctx)}; pwp = ℘ diff --git a/solid/utility/test/test_threadpool_thread_context.cpp b/solid/utility/test/test_threadpool_thread_context.cpp index cfebf41d..2fab3be1 100644 --- a/solid/utility/test/test_threadpool_thread_context.cpp +++ b/solid/utility/test/test_threadpool_thread_context.cpp @@ -36,7 +36,7 @@ struct Context { } }; -using CallPoolT = ThreadPool, Function>; +using CallPoolT = ThreadPool, Function>; } // namespace @@ -69,15 +69,16 @@ int test_threadpool_thread_context(int argc, char* argv[]) for (int i = 0; i < loop_cnt; ++i) { auto start = chrono::steady_clock::now(); { + Context ctx("simple text", 0UL); CallPoolT wp{ - {2, 1000, 0}, [](const size_t, Context&&) {}, [](const size_t, Context&&) {}, - Context("simple text", 0UL)}; + {2, 1000, 0}, [](const size_t, Context&) {}, [](const size_t, Context&) {}, + std::ref(ctx)}; solid_log(logger, Verbose, "wp started"); pwp = ℘ start = chrono::steady_clock::now(); for (size_t i = 0; i < cnt; ++i) { - auto l = [i, &val](Context&& _rctx) { + auto l = [i, &val](Context& _rctx) { ++_rctx.count_; val += i; }; diff --git a/solid/utility/threadpool.hpp b/solid/utility/threadpool.hpp index dcde0033..4f2d8d72 100644 --- a/solid/utility/threadpool.hpp +++ b/solid/utility/threadpool.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #if !defined(__cpp_lib_atomic_wait) #include "solid/utility/atomic_wait" @@ -286,6 +287,12 @@ class SynchronizationContext { namespace tpimpl { +template +typename std::decay::type decay_copy(T&& v) +{ + return std::forward(v); +} + template class alignas(hardware_destructive_interference_size) TaskData { std::aligned_storage_t data_; @@ -529,7 +536,7 @@ class ThreadPool : NonCopyable { const auto cnt = consume_count_.load(); if (cnt == _count) { return static_cast(event_); - } else if (!_try_consume_an_all_fnc(&consume_count_, _count, _all_fnc, std::forward(_args)...) && _spin_count && !spin--) { + } else if (!_try_consume_an_all_fnc(&consume_count_, _count, _all_fnc, _args...) && _spin_count && !spin--) { // std::atomic_wait_explicit(&consume_count_, cnt, std::memory_order_relaxed); std::atomic_wait(&consume_count_, cnt); @@ -900,12 +907,12 @@ class ThreadPool, Function(_args)...); + [](OneFunctionT& _rfnc, ArgsB&&... _argsb) { + _rfnc(_argsb...); _rfnc.reset(); }, - [](AllFunctionT& _rfnc, Args&&... _args) { - _rfnc(std::forward(_args)...); + [](AllFunctionT& _rfnc, ArgsB&&... _argsb) { + _rfnc(_argsb...); }, std::forward(_args)...); } @@ -914,18 +921,19 @@ class ThreadPool, Function void start(const ThreadPoolConfiguration& _config, StartFnc _start_fnc, - StopFnc _stop_fnc, Args... _args) + StopFnc _stop_fnc, + Args... _args) { impl_.doStart( _config, _start_fnc, _stop_fnc, - [](OneFunctionT& _rfnc, Args&&... _args) { - _rfnc(std::forward(_args)...); + [](OneFunctionT& _rfnc, ArgsB&&... _argsb) { + _rfnc(_argsb...); _rfnc.reset(); }, - [](AllFunctionT& _rfnc, Args&&... _args) { - _rfnc(std::forward(_args)...); + [](AllFunctionT& _rfnc, ArgsB&&... _argsb) { + _rfnc(_argsb...); }, std::forward(_args)...); } @@ -1040,12 +1048,12 @@ void ThreadPool::doStart( for (size_t i = 0; i < thread_count; ++i) { threads_.emplace_back( std::thread{ - [this, i, start_fnc = std::move(_start_fnc), stop_fnc = std::move(_stop_fnc), one_fnc = std::move(_one_fnc), all_fnc = std::move(_all_fnc)](Args&&... _args) mutable { - start_fnc(i, std::forward(_args)...); - doRun(i, one_fnc, all_fnc, std::forward(_args)...); - stop_fnc(i, std::forward(_args)...); + [this, i, start_fnc = _start_fnc, stop_fnc = _stop_fnc, one_fnc = _one_fnc, all_fnc = _all_fnc](Args&&... _args) mutable { + start_fnc(i, _args...); + doRun(i, one_fnc, all_fnc, _args...); + stop_fnc(i, _args...); }, - std::forward(_args)...}); + _args...}); } } //----------------------------------------------------------------------------- @@ -1101,10 +1109,10 @@ void ThreadPool::doRun( Args&&... _args) { // we need to make sure that, after processing an all_task, no new one_task can have // the all_id less than the all task that we have just processed. - return tryConsumeAnAllTask(_pcounter, _count, local_context, _all_fnc, std::forward(_args)...); + return tryConsumeAnAllTask(_pcounter, _count, local_context, _all_fnc, _args...); }, _all_fnc, - std::forward(_args)...); + _args...); if (event == EventE::Fill) { auto context_produce_id = rstub.context_produce_id_; @@ -1118,16 +1126,16 @@ void ThreadPool::doRun( rstub.notifyWhilePop(); if (pctx == nullptr) { - consumeAll(local_context, all_id, _all_fnc, std::forward(_args)...); + consumeAll(local_context, all_id, _all_fnc, _args...); - _one_fnc(task, std::forward(_args)...); + _one_fnc(task, _args...); ++local_context.one_free_count_; statistic_.runOneFreeCount(local_context.one_free_count_); continue; } else if (context_produce_id == pctx->consume_id_.load(std::memory_order_relaxed)) { - consumeAll(local_context, all_id, _all_fnc, std::forward(_args)...); + consumeAll(local_context, all_id, _all_fnc, _args...); - _one_fnc(task, std::forward(_args)...); + _one_fnc(task, _args...); ++local_one_context_count; } else { pctx->spin_.lock(); @@ -1140,9 +1148,9 @@ void ThreadPool::doRun( } else { pctx->spin_.unlock(); - consumeAll(local_context, all_id, _all_fnc, std::forward(_args)...); + consumeAll(local_context, all_id, _all_fnc, _args...); - _one_fnc(task, std::forward(_args)...); + _one_fnc(task, _args...); ++local_one_context_count; } } @@ -1160,9 +1168,9 @@ void ThreadPool::doRun( } } - consumeAll(local_context, all_id, _all_fnc, std::forward(_args)...); + consumeAll(local_context, all_id, _all_fnc, _args...); - _one_fnc(task_data.task(), std::forward(_args)...); + _one_fnc(task_data.task(), _args...); task_data.destroy(); @@ -1180,7 +1188,7 @@ void ThreadPool::doRun( statistic_.runOneContextCount(local_one_context_count, local_context.one_context_count_); } else if (event == EventE::Wake) { const auto all_id = rstub.all_id_; - consumeAll(local_context, all_id, _all_fnc, std::forward(_args)...); + consumeAll(local_context, all_id, _all_fnc, _args...); ++local_context.wake_count_; statistic_.runWakeCount(local_context.wake_count_); @@ -1228,7 +1236,7 @@ bool ThreadPool::tryConsumeAnAllTask(AtomicCounterT* _p should_retry = all_.pending_count_.fetch_sub(1) != 1; } - _all_fnc(task, std::forward(_args)...); + _all_fnc(task, _args...); ++_rlocal_context.next_all_id_; ++_rlocal_context.all_count_; @@ -1248,7 +1256,7 @@ void ThreadPool::consumeAll(LocalContext& _rlocal_conte { size_t repeat_count = 0; while (overflow_safe_less(_rlocal_context.next_all_id_, _all_id) || _rlocal_context.next_all_id_ == _all_id) { - tryConsumeAnAllTask(nullptr, 0, _rlocal_context, _all_fnc, std::forward(_args)...); + tryConsumeAnAllTask(nullptr, 0, _rlocal_context, _all_fnc, _args...); ++repeat_count; } statistic_.consumeAll(repeat_count); diff --git a/tutorials/mprpc_echo_relay/mprpc_echo_relay_client.cpp b/tutorials/mprpc_echo_relay/mprpc_echo_relay_client.cpp index 05924f1c..e30a8c04 100644 --- a/tutorials/mprpc_echo_relay/mprpc_echo_relay_client.cpp +++ b/tutorials/mprpc_echo_relay/mprpc_echo_relay_client.cpp @@ -33,7 +33,7 @@ struct Parameters { }; struct Message : solid::frame::mprpc::Message { - uint32_t group_id_; + uint32_t group_id_ = -1; std::string data; Message() {} diff --git a/tutorials/mprpc_file/mprpc_file_messages.hpp b/tutorials/mprpc_file/mprpc_file_messages.hpp index 1a01b6f7..c15d9184 100644 --- a/tutorials/mprpc_file/mprpc_file_messages.hpp +++ b/tutorials/mprpc_file/mprpc_file_messages.hpp @@ -64,7 +64,7 @@ struct FileRequest : solid::frame::mprpc::Message { struct FileResponse : solid::frame::mprpc::Message { std::string remote_path; - mutable int64_t remote_file_size; + mutable int64_t remote_file_size = 0; mutable std::ifstream ifs; std::ofstream ofs;