mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virStreamSparseSendAll: Reset @want in each iteration
There's a slight problem with the current function. Assume we are currently in a data section and we have say 42 bytes until next section. Therefore, just before (handler) is called to fill up the buffer with data, @want is changed to 42 to match the amount of data left in the current section. However, after hole is processed, we are back in data section but with incredibly small @want size. Nobody will ever reset it back. This results in incredible data fragmentation. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f9fe0f54ca
commit
9b991d0237
@ -698,7 +698,7 @@ int virStreamSparseSendAll(virStreamPtr stream,
|
|||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
char *bytes = NULL;
|
char *bytes = NULL;
|
||||||
size_t want = VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX;
|
size_t bufLen = VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned long long dataLen = 0;
|
unsigned long long dataLen = 0;
|
||||||
|
|
||||||
@ -718,12 +718,13 @@ int virStreamSparseSendAll(virStreamPtr stream,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(bytes, want) < 0)
|
if (VIR_ALLOC_N(bytes, bufLen) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int inData, got, offset = 0;
|
int inData, got, offset = 0;
|
||||||
long long sectionLen;
|
long long sectionLen;
|
||||||
|
size_t want = bufLen;
|
||||||
const unsigned int skipFlags = 0;
|
const unsigned int skipFlags = 0;
|
||||||
|
|
||||||
if (!dataLen) {
|
if (!dataLen) {
|
||||||
|
Loading…
Reference in New Issue
Block a user