mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
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:
parent
02dc49c272
commit
96ab6b51b8
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue