Skip to content

Commit b79a99d

Browse files
committed
Fixed move logic.
1 parent 1d9531c commit b79a99d

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

include/mqtt/endpoint.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10547,7 +10547,8 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
1054710547
async_handler_t func
1054810548
) {
1054910549
auto do_async_send_publish =
10550-
[&](auto msg, auto&& serialize_publish, auto&& receive_maximum_proc) {
10550+
[&, func = force_move(func)]
10551+
(auto msg, auto&& serialize_publish, auto&& receive_maximum_proc) mutable {
1055110552
auto msg_lk = apply_topic_alias(msg, life_keeper);
1055210553
if (maximum_packet_size_send_ < size<PacketIdBytes>(std::get<0>(msg_lk))) {
1055310554
if (packet_id != 0) {
@@ -10565,7 +10566,13 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
1056510566
msg,
1056610567
life_keeper,
1056710568
std::forward<decltype(serialize_publish)>(serialize_publish),
10568-
std::forward<decltype(receive_maximum_proc)>(receive_maximum_proc)
10569+
[
10570+
&func,
10571+
receive_maximum_proc = std::forward<decltype(receive_maximum_proc)>(receive_maximum_proc)
10572+
]
10573+
(auto&& msg) mutable {
10574+
return receive_maximum_proc(force_move(msg), func);
10575+
}
1056910576
)
1057010577
) {
1057110578
do_async_write(
@@ -10587,7 +10594,7 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
1058710594
pubopts
1058810595
),
1058910596
&endpoint::on_serialize_publish_message,
10590-
[] (auto&&) { return true; }
10597+
[] (auto&&, async_handler_t&) { return true; }
1059110598
);
1059210599
break;
1059310600
case protocol_version::v5:
@@ -10600,7 +10607,7 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
1060010607
force_move(props)
1060110608
),
1060210609
&endpoint::on_serialize_v5_publish_message,
10603-
[this, func = force_move(func)] (v5::basic_publish_message<PacketIdBytes>&& msg) mutable {
10610+
[this] (v5::basic_publish_message<PacketIdBytes>&& msg, async_handler_t& func) mutable {
1060410611
if (publish_send_count_.load() == publish_send_max_) {
1060510612
{
1060610613
LockGuard<Mutex> lck (publish_send_queue_mtx_);

test/system/st_offline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,12 @@ BOOST_AUTO_TEST_CASE( async_publish_qos1 ) {
545545
"topic1",
546546
"topic1_contents",
547547
MQTT_NS::qos::at_least_once | MQTT_NS::retain::no,
548-
[&chk](MQTT_NS::error_code ec){
548+
[&](MQTT_NS::error_code ec){
549549
BOOST_TEST( ! ec);
550550
MQTT_CHK("h_pub_finish");
551+
async_connect_no_clean(c);
551552
}
552553
);
553-
async_connect_no_clean(c);
554554
},
555555
[&] {
556556
MQTT_CHK("h_close2");

0 commit comments

Comments
 (0)