Skip to content

Commit

Permalink
Replaced BOOST_ASSERT with overwrite.
Browse files Browse the repository at this point in the history
It is corner case but BOOST_ASSERT is too strong.
Overwrite is better solution.
  • Loading branch information
redboltz committed May 7, 2019
1 parent a29da19 commit e54f2e4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion include/mqtt/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10172,7 +10172,24 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
control_packet_type::pubcomp,
msg
);
BOOST_ASSERT(ret.second);
// publish store is erased when pubrec is received.
// pubrel store is erased when pubcomp is received.
// If invalid client send pubrec twice with the same packet id,
// then send corresponding pubrel twice is a possible client/server
// implementation.
// In this case, overwrite store_.
if (!ret.second) {
store_.modify(
ret.first,
[&] (auto& e) {
e = store(
packet_id,
control_packet_type::pubcomp,
msg
);
}
);
}
}

if (serialize) {
Expand Down

0 comments on commit e54f2e4

Please sign in to comment.