Skip to content

Commit b9062ae

Browse files
authored
Fix compiling error when message doesn't have a move constructor. (#1678)
* Fix compiling error when message doesn't have a move constructor. * Clear response safely.
1 parent 5fbe73f commit b9062ae

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/factory/RedisTaskImpl.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class ComplexRedisSubscribeTask : public ComplexRedisTask
367367
ProtocolMessage *
368368
ComplexRedisSubscribeTask::SubscribeWrapper::next_in(ProtocolMessage *message)
369369
{
370-
redis_reply_t *reply = ((RedisResponse *)message)->result_ptr();
370+
redis_reply_t *reply = task_->resp.result_ptr();
371371

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

388-
task_->clear_resp();
388+
RedisResponse resp;
389+
*(protocol::ProtocolMessage *)&resp = std::move(task_->resp);
390+
task_->resp = std::move(resp);
389391
return task_->finished_ ? NULL : &task_->resp;
390392
}
391393

src/factory/WFTaskFactory.inl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ protected:
179179

180180
void clear_resp()
181181
{
182-
RESP resp;
183-
*(protocol::ProtocolMessage *)&resp = std::move(this->resp);
184-
this->resp = std::move(resp);
182+
protocol::ProtocolMessage head(std::move(this->resp));
183+
this->resp.~RESP();
184+
new(&this->resp) RESP;
185+
*(protocol::ProtocolMessage *)&this->resp = std::move(head);
185186
}
186187

187188
void disable_retry()

0 commit comments

Comments
 (0)