Fix upgrade async with cork
This commit is contained in:
@@ -141,11 +141,6 @@ protected:
|
|||||||
getLoopData()->corkedSocket = this;
|
getLoopData()->corkedSocket = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the corked socket or nullptr */
|
|
||||||
void *corkedSocket() {
|
|
||||||
return getLoopData()->corkedSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns wheter we are corked or not */
|
/* Returns wheter we are corked or not */
|
||||||
bool isCorked() {
|
bool isCorked() {
|
||||||
return getLoopData()->corkedSocket == this;
|
return getLoopData()->corkedSocket == this;
|
||||||
|
|||||||
+2
-1
@@ -496,13 +496,14 @@ public:
|
|||||||
/* Corks the response if possible. Leaves already corked socket be. */
|
/* Corks the response if possible. Leaves already corked socket be. */
|
||||||
HttpResponse *cork(MoveOnlyFunction<void()> &&handler) {
|
HttpResponse *cork(MoveOnlyFunction<void()> &&handler) {
|
||||||
if (!Super::isCorked() && Super::canCork()) {
|
if (!Super::isCorked() && Super::canCork()) {
|
||||||
|
LoopData *loopData = Super::getLoopData();
|
||||||
Super::cork();
|
Super::cork();
|
||||||
handler();
|
handler();
|
||||||
|
|
||||||
/* The only way we could possibly have changed the corked socket during handler call, would be if
|
/* 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"
|
* 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. */
|
* 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
|
/* 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.
|
* been written and the cork buffer has already been sent off and uncorked.
|
||||||
|
|||||||
Reference in New Issue
Block a user