Skip to content

Commit

Permalink
Fix compiling error when message doesn't have a move constructor. (#1678
Browse files Browse the repository at this point in the history
)

* Fix compiling error when message doesn't have a move constructor.

* Clear response safely.
  • Loading branch information
Barenboim authored Jan 6, 2025
1 parent 5fbe73f commit b9062ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/factory/RedisTaskImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class ComplexRedisSubscribeTask : public ComplexRedisTask
ProtocolMessage *
ComplexRedisSubscribeTask::SubscribeWrapper::next_in(ProtocolMessage *message)
{
redis_reply_t *reply = ((RedisResponse *)message)->result_ptr();
redis_reply_t *reply = task_->resp.result_ptr();

if (reply->type != REDIS_REPLY_TYPE_ARRAY)
{
Expand All @@ -385,7 +385,9 @@ ComplexRedisSubscribeTask::SubscribeWrapper::next_in(ProtocolMessage *message)
task_->watching_ = true;
task_->extract_(task_);

task_->clear_resp();
RedisResponse resp;
*(protocol::ProtocolMessage *)&resp = std::move(task_->resp);
task_->resp = std::move(resp);
return task_->finished_ ? NULL : &task_->resp;
}

Expand Down
7 changes: 4 additions & 3 deletions src/factory/WFTaskFactory.inl
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ protected:

void clear_resp()
{
RESP resp;
*(protocol::ProtocolMessage *)&resp = std::move(this->resp);
this->resp = std::move(resp);
protocol::ProtocolMessage head(std::move(this->resp));
this->resp.~RESP();
new(&this->resp) RESP;
*(protocol::ProtocolMessage *)&this->resp = std::move(head);
}

void disable_retry()
Expand Down

0 comments on commit b9062ae

Please sign in to comment.