Skip to content

Commit 5953c2d

Browse files
committed
search: combine callbacks in case of multiple equivalent puts
1 parent be0b115 commit 5953c2d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/search.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -641,18 +641,20 @@ struct Dht::Search {
641641
n->acked[value->id].req.reset();
642642
n->probe_query.reset();
643643
}
644+
} else {
645+
a_sr->callback = [
646+
cb1 = std::move(a_sr->callback),
647+
cb2 = std::move(callback)
648+
](bool success, const std::vector<std::shared_ptr<Node>>& nodes){
649+
if (cb1) cb1(success, nodes);
650+
if (cb2) cb2(success, nodes);
651+
};
644652
}
645653
if (isAnnounced(value->id)) {
646654
if (a_sr->callback)
647655
a_sr->callback(true, {});
648656
a_sr->callback = {};
649-
if (callback)
650-
callback(true, {});
651657
return;
652-
} else {
653-
if (a_sr->callback)
654-
a_sr->callback(false, {});
655-
a_sr->callback = callback;
656658
}
657659
}
658660
}

0 commit comments

Comments
 (0)