Fix more memory leaks

This commit is contained in:
Alex Hultman
2018-12-30 17:43:11 +01:00
parent 6618f7194b
commit 339e2d72dc
6 changed files with 40 additions and 0 deletions
+10
View File
@@ -46,6 +46,8 @@ private:
/* The app always owns at least one http context, but creates websocket contexts on demand */
HttpContext<SSL> *httpContext;
std::vector<WebSocketContext<SSL, true> *> webSocketContexts;
using SOCKET_TYPE = typename StaticDispatch<SSL>::SOCKET_TYPE;
using StaticDispatch<SSL>::static_dispatch;
public:
@@ -57,6 +59,10 @@ public:
~TemplatedApp() {
/* Let's just put everything here */
httpContext->free();
for (auto *webSocketContext : webSocketContexts) {
webSocketContext->free();
}
}
TemplatedApp(const TemplatedApp &other) {
@@ -83,6 +89,9 @@ public:
/* Every route has its own websocket context with its own behavior and user data type */
auto *webSocketContext = WebSocketContext<SSL, true>::create(Loop::defaultLoop(), (typename StaticDispatch<SSL>::SOCKET_CONTEXT_TYPE *) httpContext);
/* We need to clear this later on */
webSocketContexts.push_back(webSocketContext);
/* Quick fix to disable any compression if set */
#ifdef UWS_NO_ZLIB
behavior.compression = uWS::DISABLED;
@@ -184,6 +193,7 @@ public:
}
});
// never called
return *this;
}