Skip to content

Commit 1c8b52b

Browse files
committed
Fix for wifi disconnect handling (#431)
1 parent 1803f30 commit 1c8b52b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiUdp.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ int WiFiUDP::available() {
124124
/* Release any resources being used by this WiFiUDP instance */
125125
void WiFiUDP::stop()
126126
{
127-
if (_ctx)
127+
if (_ctx) {
128128
_ctx->disconnect();
129-
_ctx->unref();
129+
_ctx->unref();
130+
}
130131
_ctx = 0;
131132
}
132133

@@ -271,6 +272,7 @@ uint16_t WiFiUDP::localPort()
271272
void WiFiUDP::stopAll()
272273
{
273274
for (WiFiUDP* it = _s_first; it; it = it->_next) {
275+
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) it, (uint32_t) _s_first);
274276
it->stop();
275277
}
276278
}

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/slist.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ class SList {
99
protected:
1010

1111
static void _add(T* self) {
12+
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) self, (uint32_t) _s_first);
1213
T* tmp = _s_first;
1314
_s_first = self;
1415
self->_next = tmp;
1516
}
1617

1718
static void _remove(T* self) {
19+
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) self, (uint32_t) _s_first);
1820
if (_s_first == self) {
1921
_s_first = self->_next;
2022
self->_next = 0;
2123
return;
2224
}
2325

24-
for (T* prev = _s_first; prev->_next; _s_first = _s_first->_next) {
26+
for (T* prev = _s_first; prev->_next; prev = prev->_next) {
2527
if (prev->_next == self) {
2628
prev->_next = self->_next;
2729
self->_next = 0;

0 commit comments

Comments
 (0)