Keep message wrapper available when clearing. (#1611)

This commit is contained in:
xiehan
2024-08-19 20:52:42 +08:00
committed by GitHub
parent 218681ec2b
commit 0c11e8c2e6
2 changed files with 3 additions and 10 deletions

View File

@@ -24,7 +24,6 @@
#include <time.h>
#include <netdb.h>
#include <stdio.h>
#include <new>
#include <string>
#include <functional>
#include <utility>
@@ -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()

View File

@@ -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;