Don't set upgradedWebSocket outside the Http parser

This commit is contained in:
Alex Hultman
2020-06-03 07:56:33 +02:00
parent f8903ed32f
commit e4f81e16ea
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -120,6 +120,9 @@ private:
/* Cork this socket */ /* Cork this socket */
((AsyncSocket<SSL> *) s)->cork(); ((AsyncSocket<SSL> *) s)->cork();
/* Mark that we are inside the parser now */
httpContextData->isParsingHttp = true;
// clients need to know the cursor after http parse, not servers! // clients need to know the cursor after http parse, not servers!
// how far did we read then? we need to know to continue with websocket parsing data? or? // how far did we read then? we need to know to continue with websocket parsing data? or?
@@ -220,6 +223,9 @@ private:
return nullptr; return nullptr;
}); });
/* Mark that we are no longer parsing Http */
httpContextData->isParsingHttp = false;
/* We need to uncork in all cases, except for nullptr (closed socket, or upgraded socket) */ /* We need to uncork in all cases, except for nullptr (closed socket, or upgraded socket) */
if (returnedSocket != nullptr) { if (returnedSocket != nullptr) {
/* Timeout on uncork failure */ /* Timeout on uncork failure */
@@ -315,7 +321,10 @@ private:
void upgradeToWebSocket(void *newSocket) { void upgradeToWebSocket(void *newSocket) {
HttpContextData<SSL> *httpContextData = getSocketContextData(); HttpContextData<SSL> *httpContextData = getSocketContextData();
httpContextData->upgradedWebSocket = newSocket; /* We should only mark this if inside the parser; if upgrading "async" we cannot set this */
if (httpContextData->isParsingHttp) {
httpContextData->upgradedWebSocket = newSocket;
}
} }
public: public:
+1
View File
@@ -41,6 +41,7 @@ private:
HttpRouter<RouterData> router; HttpRouter<RouterData> router;
void *upgradedWebSocket = nullptr; void *upgradedWebSocket = nullptr;
bool isParsingHttp = false;
}; };
} }