mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-12 10:55:46 +02:00
fix: data race during Publish in PubSub
The issue happens when SendMsgVecAsync is called with PubMessage that has string_view objects referencing objects in stack. We replace string_view with either string or shared_ptr<string> Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
7975848c36
commit
2ec3d48534
6 changed files with 56 additions and 53 deletions
|
@ -19,14 +19,14 @@ using namespace facade;
|
|||
|
||||
class TestConnection : public facade::Connection {
|
||||
public:
|
||||
TestConnection(Protocol protocol);
|
||||
TestConnection(Protocol protocol, io::StringSink* sink);
|
||||
|
||||
void SendMsgVecAsync(const PubMessage& pmsg) final;
|
||||
void SendMsgVecAsync(PubMessage pmsg) final;
|
||||
|
||||
std::vector<PubMessage> messages;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<std::string>> backing_str_;
|
||||
io::StringSink* sink_;
|
||||
};
|
||||
|
||||
class BaseFamilyTest : public ::testing::Test {
|
||||
|
@ -87,9 +87,8 @@ class BaseFamilyTest : public ::testing::Test {
|
|||
std::string GetId() const;
|
||||
size_t SubscriberMessagesLen(std::string_view conn_id) const;
|
||||
|
||||
// Returns message parts as returned by RESP:
|
||||
// pmessage, pattern, channel, message
|
||||
facade::Connection::PubMessage GetPublishedMessage(std::string_view conn_id, size_t index) const;
|
||||
const facade::Connection::PubMessage& GetPublishedMessage(std::string_view conn_id,
|
||||
size_t index) const;
|
||||
|
||||
std::unique_ptr<util::ProactorPool> pp_;
|
||||
std::unique_ptr<Service> service_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue