Skip to content

Commit

Permalink
Fixed invalid BOOST_ASSET.
Browse files Browse the repository at this point in the history
When client want to restore serialized messages,
endpoint might keep the message that has the same packet_id.
In this case, overwrite store_.
  • Loading branch information
redboltz committed May 8, 2019
1 parent 58d6681 commit ff9a294
Showing 1 changed file with 65 additions and 6 deletions.
71 changes: 65 additions & 6 deletions include/mqtt/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7476,7 +7476,23 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
std::move(msg),
std::move(life_keeper)
);
BOOST_ASSERT(ret.second);
// When client want to restore serialized messages,
// endpoint might keep the message that has the same packet_id.
// In this case, overwrite store_.
if (!ret.second) {
store_.modify(
ret.first,
[&] (auto& e) {
e = store(
packet_id,
qos == qos::at_least_once ? control_packet_type::puback
: control_packet_type::pubrec,
std::move(msg),
std::move(life_keeper)
);
}
);
}
}
}

Expand All @@ -7494,7 +7510,21 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
control_packet_type::pubcomp,
std::move(msg)
);
BOOST_ASSERT(ret.second);
// When client want to restore serialized messages,
// endpoint might keep the message that has the same packet_id.
// In this case, overwrite store_.
if (!ret.second) {
store_.modify(
ret.first,
[&] (auto& e) {
e = store(
packet_id,
control_packet_type::pubcomp,
std::move(msg)
);
}
);
}
}
}

Expand Down Expand Up @@ -7544,7 +7574,23 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
std::move(msg),
std::move(life_keeper)
);
BOOST_ASSERT(ret.second);
// When client want to restore serialized messages,
// endpoint might keep the message that has the same packet_id.
// In this case, overwrite store_.
if (!ret.second) {
store_.modify(
ret.first,
[&] (auto& e) {
e = store(
packet_id,
qos == qos::at_least_once ? control_packet_type::puback
: control_packet_type::pubrec,
std::move(msg),
std::move(life_keeper)
);
}
);
}
}
}

Expand All @@ -7560,10 +7606,23 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
auto ret = store_.emplace(
packet_id,
control_packet_type::pubcomp,
std::move(msg),
[]{}
std::move(msg)
);
BOOST_ASSERT(ret.second);
// When client want to restore serialized messages,
// endpoint might keep the message that has the same packet_id.
// In this case, overwrite store_.
if (!ret.second) {
store_.modify(
ret.first,
[&] (auto& e) {
e = store(
packet_id,
control_packet_type::pubcomp,
std::move(msg)
);
}
);
}
}
}

Expand Down

0 comments on commit ff9a294

Please sign in to comment.