Fix getSendBuffer reordering bug

This commit is contained in:
Alex Hultman
2021-09-30 22:03:58 +02:00
parent 6ec6f00ff3
commit 7956546836
+15 -2
View File
@@ -128,9 +128,22 @@ protected:
return {sendBuffer, SendBufferAttribute::NEEDS_UNCORK};
}
} else {
/* If we are corked and there is already data in the cork buffer,
mark how much is ours and reset it */
unsigned int ourCorkOffset = 0;
if (isCorked() && loopData->corkOffset) {
ourCorkOffset = loopData->corkOffset;
loopData->corkOffset = 0;
}
/* Fallback is to use the backpressure as buffer */
backPressure.resize(existingBackpressure + size);
return {(char *) backPressure.data() + existingBackpressure, SendBufferAttribute::NEEDS_DRAIN};
backPressure.resize(ourCorkOffset + existingBackpressure + size);
/* And copy corkbuffer in front */
memcpy((char *) backPressure.data() + existingBackpressure, loopData->corkBuffer, ourCorkOffset);
return {(char *) backPressure.data() + ourCorkOffset + existingBackpressure, SendBufferAttribute::NEEDS_DRAIN};
}
}