From e5493552215f279b0ca3c069d5ebcdfe06773d62 Mon Sep 17 00:00:00 2001
From: david gauchard <gauchard@laas.fr>
Date: Thu, 18 Oct 2018 00:32:54 +0200
Subject: [PATCH] Fix: WiFiClient::flush() yields but can be called from events
 (#5254)

Fix bug introduced by #5167 which replaced delay() by yield().
That should have been esp_yield() which is the one delay()
calls and is safe from either SYS or CONT contexts.

Fixes #5237.
---
 libraries/ESP8266WiFi/src/include/ClientContext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h
index ef4a692ed..8ec2329e3 100644
--- a/libraries/ESP8266WiFi/src/include/ClientContext.h
+++ b/libraries/ESP8266WiFi/src/include/ClientContext.h
@@ -333,7 +333,7 @@ public:
                 last_sent = millis();
             }
 
-            yield();
+            esp_yield(); // from sys or os context
 
             if ((state() != ESTABLISHED) || (sndbuf == TCP_SND_BUF)) {
                 break;