Fix upgrade async with cork

This commit is contained in:
Alex Hultman
2023-12-24 00:04:41 +01:00
parent b4d73a2ed3
commit 77a6f42960
2 changed files with 2 additions and 6 deletions
-5
View File
@@ -141,11 +141,6 @@ protected:
getLoopData()->corkedSocket = this;
}
/* Returns the corked socket or nullptr */
void *corkedSocket() {
return getLoopData()->corkedSocket;
}
/* Returns wheter we are corked or not */
bool isCorked() {
return getLoopData()->corkedSocket == this;
+2 -1
View File
@@ -496,13 +496,14 @@ public:
/* Corks the response if possible. Leaves already corked socket be. */
HttpResponse *cork(MoveOnlyFunction<void()> &&handler) {
if (!Super::isCorked() && Super::canCork()) {
LoopData *loopData = Super::getLoopData();
Super::cork();
handler();
/* The only way we could possibly have changed the corked socket during handler call, would be if
* the HTTP socket was upgraded to WebSocket and caused a realloc. Because of this we cannot use "this"
* from here downwards. The corking is done with corkUnchecked() in upgrade. It steals cork. */
auto *newCorkedSocket = Super::corkedSocket();
auto *newCorkedSocket = loopData->corkedSocket;
/* If nobody is corked, it means most probably that large amounts of data has
* been written and the cork buffer has already been sent off and uncorked.