1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-27 21:16:50 +03:00

Fix for wifi disconnect handling (#431)

This commit is contained in:
Ivan Grokhotkov 2015-06-22 13:59:12 +03:00
parent dc08418f08
commit b029e78a67
2 changed files with 7 additions and 3 deletions

View File

@ -124,9 +124,10 @@ int WiFiUDP::available() {
/* Release any resources being used by this WiFiUDP instance */ /* Release any resources being used by this WiFiUDP instance */
void WiFiUDP::stop() void WiFiUDP::stop()
{ {
if (_ctx) if (_ctx) {
_ctx->disconnect(); _ctx->disconnect();
_ctx->unref(); _ctx->unref();
}
_ctx = 0; _ctx = 0;
} }
@ -271,6 +272,7 @@ uint16_t WiFiUDP::localPort()
void WiFiUDP::stopAll() void WiFiUDP::stopAll()
{ {
for (WiFiUDP* it = _s_first; it; it = it->_next) { for (WiFiUDP* it = _s_first; it; it = it->_next) {
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) it, (uint32_t) _s_first);
it->stop(); it->stop();
} }
} }

View File

@ -9,19 +9,21 @@ public:
protected: protected:
static void _add(T* self) { static void _add(T* self) {
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) self, (uint32_t) _s_first);
T* tmp = _s_first; T* tmp = _s_first;
_s_first = self; _s_first = self;
self->_next = tmp; self->_next = tmp;
} }
static void _remove(T* self) { static void _remove(T* self) {
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) self, (uint32_t) _s_first);
if (_s_first == self) { if (_s_first == self) {
_s_first = self->_next; _s_first = self->_next;
self->_next = 0; self->_next = 0;
return; return;
} }
for (T* prev = _s_first; prev->_next; _s_first = _s_first->_next) { for (T* prev = _s_first; prev->_next; prev = prev->_next) {
if (prev->_next == self) { if (prev->_next == self) {
prev->_next = self->_next; prev->_next = self->_next;
self->_next = 0; self->_next = 0;