Fixed destruction/copying of TransferReceiver

This commit is contained in:
Pavel Kirienko 2014-02-11 19:18:43 +04:00
parent 4c1a4a32c7
commit 8a007c8522
3 changed files with 3 additions and 28 deletions

View File

@ -37,8 +37,6 @@ private:
bool isInitialized() const { return iface_index_ != IFACE_INDEX_NOTSET; }
void cleanup();
TidRelation getTidRelation(const RxFrame& frame) const;
void updateTransferTimings();
@ -74,23 +72,6 @@ public:
assert(bufmgr_key.getNodeID() != NODE_ID_BROADCAST);
}
~TransferReceiver() { cleanup(); }
TransferReceiver& operator=(const TransferReceiver& rhs)
{
cleanup();
prev_transfer_ts_monotonic_ = rhs.prev_transfer_ts_monotonic_;
this_transfer_ts_monotonic_ = rhs.this_transfer_ts_monotonic_;
first_frame_ts_utc_ = rhs.first_frame_ts_utc_;
transfer_interval_ = rhs.transfer_interval_;
bufmgr_ = rhs.bufmgr_;
tid_ = rhs.tid_;
bufmgr_key_ = rhs.bufmgr_key_;
iface_index_ = rhs.iface_index_;
next_frame_index_ = rhs.next_frame_index_;
return *this;
}
bool isTimedOut(uint64_t ts_monotonic) const;
ResultCode addFrame(const RxFrame& frame);

View File

@ -16,12 +16,6 @@ const uint32_t TransferReceiver::DEFAULT_TRANSFER_INTERVAL;
const uint32_t TransferReceiver::MIN_TRANSFER_INTERVAL;
const uint32_t TransferReceiver::MAX_TRANSFER_INTERVAL;
void TransferReceiver::cleanup()
{
if (bufmgr_ != NULL && !bufmgr_key_.isEmpty())
bufmgr_->remove(bufmgr_key_);
}
TransferReceiver::TidRelation TransferReceiver::getTidRelation(const RxFrame& frame) const
{
const int distance = tid_.forwardDistance(frame.transfer_id);

View File

@ -206,11 +206,11 @@ TEST(TransferReceiver, Basic)
ASSERT_TRUE(matchBufferContent(bufmgr.access(gen.bufmgr_key), "12345678qwe"));
/*
* Buffer cleanup
* Destruction
*/
ASSERT_TRUE(bufmgr.access(gen.bufmgr_key));
context.receiver = TransferReceiver();
ASSERT_FALSE(bufmgr.access(gen.bufmgr_key));
context.receiver.~TransferReceiver(); // TransferReceiver does not own the buffer, it must not be released!
ASSERT_TRUE(bufmgr.access(gen.bufmgr_key)); // Making sure that the buffer is still there
}