API: copy the data to send into the tcp internal buffer (#1455)

Without the flag lwip only holds a reference to the supplied buffers and the reference must be valid until the tcp ack is received. This can't be guaranteed for stack allocated buffers
This commit is contained in:
mknjc 2021-01-11 14:46:21 +01:00 committed by Jesse Hills
parent 8c849b9002
commit b01db991a5
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -676,8 +676,10 @@ bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint32_t message_type)
} }
} }
this->client_->add(reinterpret_cast<char *>(header.data()), header.size()); this->client_->add(reinterpret_cast<char *>(header.data()), header.size(),
this->client_->add(reinterpret_cast<char *>(buffer.get_buffer()->data()), buffer.get_buffer()->size()); ASYNC_WRITE_FLAG_COPY | ASYNC_WRITE_FLAG_MORE);
this->client_->add(reinterpret_cast<char *>(buffer.get_buffer()->data()), buffer.get_buffer()->size(),
ASYNC_WRITE_FLAG_COPY);
bool ret = this->client_->send(); bool ret = this->client_->send();
return ret; return ret;
} }