From 0c11e8c2e68598533ff5cc43e86405efa819657a Mon Sep 17 00:00:00 2001 From: xiehan <52160700+Barenboim@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:52:42 +0800 Subject: [PATCH] Keep message wrapper available when clearing. (#1611) --- src/factory/WFTaskFactory.inl | 9 +++------ src/protocol/ProtocolMessage.h | 4 ---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/factory/WFTaskFactory.inl b/src/factory/WFTaskFactory.inl index c9a15c5d..84c4c865 100644 --- a/src/factory/WFTaskFactory.inl +++ b/src/factory/WFTaskFactory.inl @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -161,11 +160,9 @@ protected: void clear_resp() { - protocol::ProtocolMessage msg(std::move(this->resp)); - - this->resp.~RESP(); - new(&this->resp) RESP; - *(protocol::ProtocolMessage *)&this->resp = std::move(msg); + RESP resp; + *(protocol::ProtocolMessage *)&resp = std::move(this->resp); + this->resp = std::move(resp); } void disable_retry() diff --git a/src/protocol/ProtocolMessage.h b/src/protocol/ProtocolMessage.h index 2354fe03..bb54e16d 100644 --- a/src/protocol/ProtocolMessage.h +++ b/src/protocol/ProtocolMessage.h @@ -112,11 +112,9 @@ public: ProtocolMessage(ProtocolMessage&& message) { this->size_limit = message.size_limit; - message.size_limit = (size_t)-1; this->attachment = message.attachment; message.attachment = NULL; this->wrapper = message.wrapper; - message.wrapper = NULL; } ProtocolMessage& operator = (ProtocolMessage&& message) @@ -124,12 +122,10 @@ public: if (&message != this) { this->size_limit = message.size_limit; - message.size_limit = (size_t)-1; delete this->attachment; this->attachment = message.attachment; message.attachment = NULL; this->wrapper = message.wrapper; - message.wrapper = NULL; } return *this;