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

Fix WS memory leak when disconnected #1857

Merged
merged 1 commit into from
Aug 15, 2019
Merged

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Aug 15, 2019

Fix #1843 & #1851 queues not clearing when disconnected
Fix continuously filling ws message queue when disconnected

@mcspr mcspr merged commit c5827b2 into xoseperez:dev Aug 15, 2019
@mcspr mcspr deleted the ws/clear-queue branch August 15, 2019 15:24
@davebuk
Copy link
Contributor

davebuk commented Aug 15, 2019

Hi Max

I am having issues building with the latest dev branch and get the following errors:

espurna/code/espurna/ws.ino:132:1: error: 'queue' in namespace 'std' does not name a type
 std::queue<ws_data_t> _ws_client_data;
 ^
espurna/code/espurna/ws.ino: In function 'void _wsHandleClientData(bool)':
espurna/code/espurna/ws.ino:637:24: error: '_ws_client_data' was not declared in this scope
C ompiling .pio\build\wemos-d1mini-relayshield\liba5b\ESP8266WiFi\WiFiClient.cpp.o
    if (!connected && !_ws_client_data.empty()) {
                        ^
espurna/ws.ino:642:9: error: '_ws_client_data' was not declared in this scope
     if (_ws_client_data.empty()) return;
C ompiling .pio\build\wemos-d1mini-relayshield\liba5b\ESP8266WiFi\WiFiClientSecure.cpp.o
        ^
espurna/code/espurna/ws.ino:643:18: error: '_ws_client_data' was not declared in this scope
     auto& data = _ws_client_data.front();
                  ^
espurna/code/espurna/ws.ino: In function 'void wsPost(const ws_on_send_callback_f&)':
espurna/code/espurna/ws.ino:749:5: error: '_ws_client_data' was not declared in this scope
     _ws_client_data.emplace(cb);
     ^
espurna/code/espurna/ws.ino: In function 'void wsPostAll(uint32_t, const ws_on_send_callback_list_t&)':
espurna/code/espurna/ws.ino:753:5: error: '_ws_client_data' was not declared in this scope
     _ws_client_data.emplace(client_id, cbs, ws_data_t::ALL);
     ^
espurna/code/espurna/ws.ino: In function 'void wsPostAll(const ws_on_send_callback_list_t&)':
espurna/code/espurna/ws.ino:757:5: error: '_ws_client_data' was not declared in this scope
     _ws_client_data.emplace(0, cbs, ws_data_t::ALL);
     ^
espurna/code/espurna/ws.ino: In function 'void wsPostSequence(uint32_t, const ws_on_send_callback_list_t&)':
espurna/code/espurna/ws.ino:761:5: error: '_ws_client_data' was not declared in this scope
     _ws_client_data.emplace(client_id, cbs, ws_data_t::SEQUENCE);
     ^
espurna/code/espurna/ws.ino: In function 'void wsPostSequence(const ws_on_send_callback_list_t&)':
espurna/code/espurna/ws.ino:765:5: error: '_ws_client_data' was not declared in this scope
     _ws_client_data.emplace(0, cbs, ws_data_t::SEQUENCE);
     ^
*** [.pio\build\wemos-d1mini-relayshield\src\espurna.ino.cpp.o] Error 1

@mcspr
Copy link
Collaborator Author

mcspr commented Aug 15, 2019

Adding #include <queue> somewhere in the prototypes.h will fix this, I missed that homeassistant & alexa include those locally

@davebuk
Copy link
Contributor

davebuk commented Aug 15, 2019

I had homeassistant and alexa not defined to keep the size down. I defined alexa support and it builds fine now.

@mcspr mcspr mentioned this pull request Aug 15, 2019
@mcspr
Copy link
Collaborator Author

mcspr commented Aug 15, 2019

Right. b652ee6 is what I meant though, merged as part of #1860

@davebuk
Copy link
Contributor

davebuk commented Aug 16, 2019

It was easier for me to test by enabling alexa rather than modifying core files. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants