mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +03:00
* ClientConnection uses too much heap when streaming files #2871 * make write_chunk_size a member variable * untabify
This commit is contained in:
parent
90729ea50c
commit
61787b23af
@ -333,7 +333,6 @@ protected:
|
|||||||
return _written;
|
return _written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _write_some()
|
void _write_some()
|
||||||
{
|
{
|
||||||
if (!_datasource || !_pcb) {
|
if (!_datasource || !_pcb) {
|
||||||
@ -346,15 +345,20 @@ protected:
|
|||||||
can_send = 0;
|
can_send = 0;
|
||||||
}
|
}
|
||||||
size_t will_send = (can_send < left) ? can_send : left;
|
size_t will_send = (can_send < left) ? can_send : left;
|
||||||
if (will_send) {
|
bool did_write = false;
|
||||||
const uint8_t* buf = _datasource->get_buffer(will_send);
|
while( will_send ) {
|
||||||
err_t err = tcp_write(_pcb, buf, will_send, TCP_WRITE_FLAG_COPY);
|
size_t next_chunk =
|
||||||
_datasource->release_buffer(buf, will_send);
|
will_send > _write_chunk_size ? _write_chunk_size : will_send;
|
||||||
|
const uint8_t* buf = _datasource->get_buffer(next_chunk);
|
||||||
|
err_t err = tcp_write(_pcb, buf, next_chunk, TCP_WRITE_FLAG_COPY);
|
||||||
|
_datasource->release_buffer(buf, next_chunk);
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
_written += will_send;
|
_written += next_chunk;
|
||||||
tcp_output(_pcb);
|
did_write = true;
|
||||||
}
|
}
|
||||||
|
will_send -= next_chunk;
|
||||||
}
|
}
|
||||||
|
if( did_write ) tcp_output(_pcb);
|
||||||
|
|
||||||
if (!_datasource->available() || _noblock) {
|
if (!_datasource->available() || _noblock) {
|
||||||
delete _datasource;
|
delete _datasource;
|
||||||
@ -479,6 +483,7 @@ private:
|
|||||||
|
|
||||||
DataSource* _datasource = nullptr;
|
DataSource* _datasource = nullptr;
|
||||||
size_t _written = 0;
|
size_t _written = 0;
|
||||||
|
size_t _write_chunk_size = 256;
|
||||||
bool _noblock = false;
|
bool _noblock = false;
|
||||||
bool _send_waiting = false;
|
bool _send_waiting = false;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user