Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release referenced resources in the destructor for ESP8266SSDP #5607

Merged
merged 10 commits into from Jan 22, 2019
25 changes: 24 additions & 1 deletion libraries/ESP8266SSDP/ESP8266SSDP.cpp
Expand Up @@ -150,7 +150,30 @@ SSDPClass::SSDPClass() :
}

SSDPClass::~SSDPClass() {
delete _timer;
#ifdef DEBUG_SSDP
devyte marked this conversation as resolved.
Show resolved Hide resolved
DEBUG_SSDP.printf("SSDP end ... ");
#endif
if(_timer) {
ETSTimer* tm = &(_timer->timer);
os_timer_disarm(tm);
delete _timer;
}

if (_server) {
_server->unref();
_server = 0;
}

IPAddress local = WiFi.localIP();
IPAddress mcast(SSDP_MULTICAST_ADDR);
if (igmp_leavegroup(local, mcast) != ERR_OK ) {
#ifdef DEBUG_SSDP
DEBUG_SSDP.printf("SSDP failed to leave igmp group\n");
#endif
}
#ifdef DEBUG_SSDP
DEBUG_SSDP.printf("ok\n");
#endif
}

bool SSDPClass::begin() {
Expand Down