Fake succeed all writes on closed socket (fix memory leak)

This commit is contained in:
Alex Hultman
2018-12-30 21:08:54 +01:00
parent cd6ab69140
commit 7afb3af614
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -101,6 +101,12 @@ protected:
* Returns pair of bytes written (anywhere) and wheter or not this call resulted in the polling for
* writable (or we are in a state that implies polling for writable). */
std::pair<int, bool> write(const char *src, int length, bool optionally = false, int nextLength = 0) {
/* Fake success if closed, simpel fix to allow uncork of closed socket to succeed */
if (us_socket_is_closed((us_socket *) this)) {
std::cout << "Faking successful send due to closed socket!" << std::endl;
return {length, false};
}
LoopData *loopData = getLoopData();
AsyncSocketData<SSL> *asyncSocketData = (AsyncSocketData<SSL> *) getExt();
+5
View File
@@ -263,6 +263,11 @@ private:
// todo: check for failures here just like for HTTP
webSocket->uncork();
// cannot do anything else if closed
if (us_socket_is_closed((us_socket *) s)) {
return s;
}
// I guess we need to check drain here - emit drain if we had to poll for writable
// are we shutdown? can onnly call this if we did succeed uncork!