Skip to content

Commit 77a6f42

Browse files
committed
Fix upgrade async with cork
1 parent b4d73a2 commit 77a6f42

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/AsyncSocket.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ struct AsyncSocket {
141141
getLoopData()->corkedSocket = this;
142142
}
143143

144-
/* Returns the corked socket or nullptr */
145-
void *corkedSocket() {
146-
return getLoopData()->corkedSocket;
147-
}
148-
149144
/* Returns wheter we are corked or not */
150145
bool isCorked() {
151146
return getLoopData()->corkedSocket == this;

src/HttpResponse.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,14 @@ struct HttpResponse : public AsyncSocket<SSL> {
496496
/* Corks the response if possible. Leaves already corked socket be. */
497497
HttpResponse *cork(MoveOnlyFunction<void()> &&handler) {
498498
if (!Super::isCorked() && Super::canCork()) {
499+
LoopData *loopData = Super::getLoopData();
499500
Super::cork();
500501
handler();
501502

502503
/* The only way we could possibly have changed the corked socket during handler call, would be if
503504
* the HTTP socket was upgraded to WebSocket and caused a realloc. Because of this we cannot use "this"
504505
* from here downwards. The corking is done with corkUnchecked() in upgrade. It steals cork. */
505-
auto *newCorkedSocket = Super::corkedSocket();
506+
auto *newCorkedSocket = loopData->corkedSocket;
506507

507508
/* If nobody is corked, it means most probably that large amounts of data has
508509
* been written and the cork buffer has already been sent off and uncorked.

0 commit comments

Comments
 (0)