Fix last obvious leak

This commit is contained in:
Alex Hultman
2018-12-30 18:02:57 +01:00
parent 339e2d72dc
commit ed7222e513
5 changed files with 14 additions and 46 deletions
+2
View File
@@ -69,6 +69,8 @@ int main(int argc, char **argv) {
uWS::Loop::defaultLoop()->free();
std::cout << "Everything fine, falling through" << std::endl;
// return 0;
// AsyncFileStreamer *asyncFileStreamer = new AsyncFileStreamer("/home/alexhultman/v0.15/public");
-45
View File
@@ -136,51 +136,6 @@ private:
}
public:
// this should probably not be public
bool upgradeToWebSocket(void *newSocket) {
HttpResponseData<SSL> *httpResponseData = getHttpResponseData();
// this flag is not really needed to keep state of, could be per http content state
httpResponseData->state |= HttpResponseData<SSL>::HTTP_UPGRADED_TO_WEBSOCKET;
// also set pointer to the websocketcontext?
// you can just check if the context of the socket changed? buy youi don't know the socket ptr!
HttpContextData<SSL> *httpContextData = (HttpContextData<SSL> *) Super::static_dispatch(us_ssl_socket_context_ext, us_socket_context_ext)(
Super::static_dispatch(us_ssl_socket_get_context, us_socket_get_context)((typename Super::SOCKET_TYPE *) this)
);
httpContextData->upgradedWebSocket = newSocket;
// I jhave no idea what this does
return true;
/*SOCKET_CONTEXT_TYPE *getSocketContext() {
return (SOCKET_CONTEXT_TYPE *) this;
}
static SOCKET_CONTEXT_TYPE *getSocketContext(SOCKET_TYPE *s) {
return (SOCKET_CONTEXT_TYPE *) static_dispatch(us_ssl_socket_get_context, us_socket_get_context)(s);
}
HttpContextData<SSL> *getSocketContextData() {
return (HttpContextData<SSL> *) static_dispatch(us_ssl_socket_context_ext, us_socket_context_ext)(getSocketContext());
}
static HttpContextData<SSL> *getSocketContextDataS(SOCKET_TYPE *s) {
return (HttpContextData<SSL> *) static_dispatch(us_ssl_socket_context_ext, us_socket_context_ext)(getSocketContext(s));
}*/
//return (HttpContextData<SSL> *) static_dispatch(us_ssl_socket_context_ext, us_socket_context_ext)(getSocketContext(s));
}
/* Immediately terminate this Http response */
using Super::close;
+1 -1
View File
@@ -35,7 +35,7 @@ private:
HTTP_STATUS_CALLED = 1, // used
HTTP_WRITE_CALLED = 2, // used
HTTP_END_CALLED = 4, // used
HTTP_UPGRADED_TO_WEBSOCKET = 8, // used
HTTP_UPGRADED_TO_WEBSOCKET = 8, // not used
HTTP_ENDED_STREAM_OUT = 16 // not used
};
+3
View File
@@ -238,6 +238,9 @@ private:
//std::cout << "close!" << std::endl;
WebSocketData *webSocketData = (WebSocketData *) (static_dispatch(us_ssl_socket_ext, us_socket_ext)(s));
webSocketData->~WebSocketData();
return s;
+8
View File
@@ -50,6 +50,14 @@ public:
deflationStream = new DeflationStream;
}
}
~WebSocketData() {
std::cout << "destruting webocketdata" << std::endl;
if (deflationStream) {
delete deflationStream;
}
}
};
}