esp32/network_ppp: Reduce PPP thread CPU usage.

Reduces the CPU usage by the PPP thread by sleeping for one tick if
there was nothing to read; preventing the loop using 100% CPU when the
read operation has a zero timeout and immediately returns.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
pull/12728/head
Daniël van de Giessen 2023-08-25 15:17:04 +02:00 zatwierdzone przez Damien George
rodzic f1d6af9819
commit a1d20e0747
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -108,9 +108,10 @@ static void pppos_client_task(void *self_in) {
ppp_if_obj_t *self = (ppp_if_obj_t *)self_in;
uint8_t buf[256];
while (ulTaskNotifyTake(pdTRUE, 0) == 0) {
int len = 0;
while (ulTaskNotifyTake(pdTRUE, len <= 0) == 0) {
int err;
int len = mp_stream_rw(self->stream, buf, sizeof(buf), &err, 0);
len = mp_stream_rw(self->stream, buf, sizeof(buf), &err, 0);
if (len > 0) {
pppos_input_tcpip(self->pcb, (u8_t *)buf, len);
}