Skip to content

Commit ebd7a52

Browse files
committed
add a yield here for esp32 to avoid a busy loop
if data isn't available yet, but is expected, yielding here is nicer than burning the cpu in a loop, just like in esp8266 case.
1 parent c038f10 commit ebd7a52

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/WebSockets.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ bool WebSockets::readCb(WSclient_t * client, uint8_t * out, size_t n, WSreadWait
625625
if(!client->tcp->available()) {
626626
#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
627627
delay(0);
628+
#endif
629+
#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32)
630+
yield();
628631
#endif
629632
continue;
630633
}

0 commit comments

Comments
 (0)