@@ -333,7 +333,6 @@ class ClientContext
333
333
return _written;
334
334
}
335
335
336
-
337
336
void _write_some ()
338
337
{
339
338
if (!_datasource || !_pcb) {
@@ -346,15 +345,20 @@ class ClientContext
346
345
can_send = 0 ;
347
346
}
348
347
size_t will_send = (can_send < left) ? can_send : left;
349
- if (will_send) {
350
- const uint8_t * buf = _datasource->get_buffer (will_send);
351
- err_t err = tcp_write (_pcb, buf, will_send, TCP_WRITE_FLAG_COPY);
352
- _datasource->release_buffer (buf, will_send);
348
+ bool did_write = false ;
349
+ while ( will_send ) {
350
+ size_t next_chunk =
351
+ will_send > _write_chunk_size ? _write_chunk_size : will_send;
352
+ const uint8_t * buf = _datasource->get_buffer (next_chunk);
353
+ err_t err = tcp_write (_pcb, buf, next_chunk, TCP_WRITE_FLAG_COPY);
354
+ _datasource->release_buffer (buf, next_chunk);
353
355
if (err == ERR_OK) {
354
- _written += will_send ;
355
- tcp_output (_pcb) ;
356
+ _written += next_chunk ;
357
+ did_write = true ;
356
358
}
359
+ will_send -= next_chunk;
357
360
}
361
+ if ( did_write ) tcp_output (_pcb);
358
362
359
363
if (!_datasource->available () || _noblock) {
360
364
delete _datasource;
@@ -479,6 +483,7 @@ class ClientContext
479
483
480
484
DataSource* _datasource = nullptr ;
481
485
size_t _written = 0 ;
486
+ size_t _write_chunk_size = 256 ;
482
487
bool _noblock = false ;
483
488
bool _send_waiting = false ;
484
489
};
0 commit comments