|
1 | 1 | /*
|
2 | 2 | ClientContext.h - TCP connection handling on top of lwIP
|
| 3 | +
|
3 | 4 | Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
4 | 5 | This file is part of the esp8266 core for Arduino environment.
|
| 6 | +
|
5 | 7 | This library is free software; you can redistribute it and/or
|
6 | 8 | modify it under the terms of the GNU Lesser General Public
|
7 | 9 | License as published by the Free Software Foundation; either
|
8 | 10 | version 2.1 of the License, or (at your option) any later version.
|
| 11 | +
|
9 | 12 | This library is distributed in the hope that it will be useful,
|
10 | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 | 15 | Lesser General Public License for more details.
|
| 16 | +
|
13 | 17 | You should have received a copy of the GNU Lesser General Public
|
14 | 18 | License along with this library; if not, write to the Free Software
|
15 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -126,8 +130,11 @@ class ClientContext
|
126 | 130 | }
|
127 | 131 | _connect_pending = 1;
|
128 | 132 | _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 | + } |
131 | 138 | _connect_pending = 0;
|
132 | 139 | if (!_pcb) {
|
133 | 140 | DEBUGV(":cabrt\r\n");
|
@@ -452,8 +459,11 @@ class ClientContext
|
452 | 459 | }
|
453 | 460 |
|
454 | 461 | _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 | + } |
457 | 467 | } while(true);
|
458 | 468 | _send_waiting = false;
|
459 | 469 |
|
@@ -599,6 +609,7 @@ class ClientContext
|
599 | 609 | (void) pcb;
|
600 | 610 | assert(pcb == _pcb);
|
601 | 611 | assert(_connect_pending);
|
| 612 | + _connect_pending = 0; |
602 | 613 | esp_schedule();
|
603 | 614 | return ERR_OK;
|
604 | 615 | }
|
|
0 commit comments