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 GitHub
parent 02dc49c272
commit 96ab6b51b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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