Shmem: track number of message objects, throw if non-zero at reset

This commit is contained in:
Alexey Rybalchenko
2019-12-19 15:06:14 +01:00
committed by Dennis Klein
parent 5b5fecc994
commit 684e711b8b
5 changed files with 63 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ TransportFactory::TransportFactory(const string& id, const ProgOptions* config)
, fManager(nullptr)
, fHeartbeatThread()
, fSendHeartbeats(true)
, fMsgCounter(0)
{
int major, minor, patch;
zmq_version(&major, &minor, &patch);
@@ -168,6 +169,15 @@ Transport TransportFactory::GetType() const
return fTransportType;
}
void TransportFactory::Reset()
{
if (fMsgCounter.load() != 0) {
LOG(error) << "Message counter during Reset expected to be 0, found: " << fMsgCounter.load();
throw MessageError(tools::ToString("Message counter during Reset expected to be 0, found: ", fMsgCounter.load()));
}
}
TransportFactory::~TransportFactory()
{
LOG(debug) << "Destroying Shared Memory transport...";