From 77a6f429600a11fae0f5f54aae732419a0beb182 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 24 Dec 2023 00:04:41 +0100 Subject: [PATCH] Fix upgrade async with cork --- src/AsyncSocket.h | 5 ----- src/HttpResponse.h | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/AsyncSocket.h b/src/AsyncSocket.h index 6770974da..a6b5e1aef 100644 --- a/src/AsyncSocket.h +++ b/src/AsyncSocket.h @@ -141,11 +141,6 @@ struct AsyncSocket { 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; diff --git a/src/HttpResponse.h b/src/HttpResponse.h index 1610694ad..bf623f418 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -496,13 +496,14 @@ struct HttpResponse : public AsyncSocket { /* Corks the response if possible. Leaves already corked socket be. */ HttpResponse *cork(MoveOnlyFunction &&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.