Skip to content

Commit 82ae8d1

Browse files
authored
Merge pull request esp8266#7 from Jason2866/revert-6-patch-2
Revert "Patch 2"
2 parents a94442e + 6c44127 commit 82ae8d1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

libraries/ESP8266WiFi/src/include/ClientContext.h

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
/*
22
ClientContext.h - TCP connection handling on top of lwIP
3+
34
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
45
This file is part of the esp8266 core for Arduino environment.
6+
57
This library is free software; you can redistribute it and/or
68
modify it under the terms of the GNU Lesser General Public
79
License as published by the Free Software Foundation; either
810
version 2.1 of the License, or (at your option) any later version.
11+
912
This library is distributed in the hope that it will be useful,
1013
but WITHOUT ANY WARRANTY; without even the implied warranty of
1114
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1215
Lesser General Public License for more details.
16+
1317
You should have received a copy of the GNU Lesser General Public
1418
License along with this library; if not, write to the Free Software
1519
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -126,8 +130,11 @@ class ClientContext
126130
}
127131
_connect_pending = 1;
128132
_op_start_time = millis();
129-
// This delay will be interrupted by esp_schedule in the connect callback
130-
delay(_timeout_ms);
133+
// Following delay will be interrupted by connect callback
134+
for (decltype(_timeout_ms) i = 0; _connect_pending && i < _timeout_ms; i++) {
135+
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
136+
delay(1);
137+
}
131138
_connect_pending = 0;
132139
if (!_pcb) {
133140
DEBUGV(":cabrt\r\n");
@@ -452,8 +459,11 @@ class ClientContext
452459
}
453460

454461
_send_waiting = true;
455-
// This delay will be interrupted by esp_schedule on next received ack
456-
delay(_timeout_ms);
462+
// Following delay will be interrupted by on next received ack
463+
for (decltype(_timeout_ms) i = 0; _send_waiting && i < _timeout_ms; i++) {
464+
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
465+
delay(1);
466+
}
457467
} while(true);
458468
_send_waiting = false;
459469

@@ -599,6 +609,7 @@ class ClientContext
599609
(void) pcb;
600610
assert(pcb == _pcb);
601611
assert(_connect_pending);
612+
_connect_pending = 0;
602613
esp_schedule();
603614
return ERR_OK;
604615
}

0 commit comments

Comments
 (0)