Fix: deactivate only *recent* HQ frame, not any HQ frame

This commit is contained in:
Dmitri Tikhonov 2020-10-06 16:53:03 -04:00
parent 75f54c8c52
commit a1630d9c4f

View file

@ -2629,13 +2629,17 @@ frame_hq_gen_read (void *ctx, void *begin_buf, size_t len, int *fin)
struct stream_hq_frame *shf; struct stream_hq_frame *shf;
size_t nw, frame_sz, avail, rem; size_t nw, frame_sz, avail, rem;
unsigned bits; unsigned bits;
int new;
while (p < end) while (p < end)
{ {
shf = find_cur_hq_frame(stream); shf = find_cur_hq_frame(stream);
if (shf) if (shf)
{
new = 0;
LSQ_DEBUG("found current HQ frame of type 0x%X at offset %"PRIu64, LSQ_DEBUG("found current HQ frame of type 0x%X at offset %"PRIu64,
shf->shf_frame_type, shf->shf_off); shf->shf_frame_type, shf->shf_off);
}
else else
{ {
rem = frame_std_gen_size(ctx); rem = frame_std_gen_size(ctx);
@ -2646,7 +2650,10 @@ frame_hq_gen_read (void *ctx, void *begin_buf, size_t len, int *fin)
shf = stream_activate_hq_frame(stream, shf = stream_activate_hq_frame(stream,
stream->sm_payload, HQFT_DATA, 0, rem); stream->sm_payload, HQFT_DATA, 0, rem);
if (shf) if (shf)
{
new = 1;
goto insert; goto insert;
}
else else
{ {
/* TODO: abort connection? Handle failure somehow */ /* TODO: abort connection? Handle failure somehow */
@ -2663,6 +2670,7 @@ frame_hq_gen_read (void *ctx, void *begin_buf, size_t len, int *fin)
frame_sz = stream_hq_frame_size(shf); frame_sz = stream_hq_frame_size(shf);
if (frame_sz > (uintptr_t) (end - p)) if (frame_sz > (uintptr_t) (end - p))
{ {
if (new)
stream_hq_frame_put(stream, shf); stream_hq_frame_put(stream, shf);
break; break;
} }