Skip to content

Commit 423532e

Browse files
committed
commit stream state when failing to allocate packet space
1 parent 3fc826a commit 423532e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/quicly.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4498,16 +4498,24 @@ quicly_error_t quicly_send_stream(quicly_stream_t *stream, quicly_send_context_t
44984498
commit_stream_frame(stream, sent, off_of_packet, s->dst - capacity_of_first_packet, capacity_of_first_packet, 0, 0);
44994499
off_of_packet += capacity_of_first_packet;
45004500
for (size_t i = 0; scattered_payload_lengths[i + 1] != 0; ++i) {
4501-
if ((ret = allocate_ack_eliciting_frame(stream->conn, s, 1, &sent, on_ack_stream)) != 0)
4502-
return ret;
4501+
if ((ret = allocate_ack_eliciting_frame(stream->conn, s, 1, &sent, on_ack_stream)) != 0) {
4502+
len = off_of_packet - off;
4503+
wrote_all = 0;
4504+
is_fin = 0;
4505+
goto UpdateStreamState;
4506+
}
45034507
assert(s->dst == s->dst_payload_from && "scatter does not expect other frames");
45044508
s->dst = s->dst_end;
45054509
commit_stream_frame(stream, sent, off_of_packet, s->dst - scattered_payload_lengths[i],
45064510
scattered_payload_lengths[i], 0, 0);
45074511
off_of_packet += scattered_payload_lengths[i];
45084512
}
4509-
if ((ret = allocate_ack_eliciting_frame(stream->conn, s, 1, &sent, on_ack_stream)) != 0)
4510-
return ret;
4513+
if ((ret = allocate_ack_eliciting_frame(stream->conn, s, 1, &sent, on_ack_stream)) != 0) {
4514+
len = off_of_packet - off;
4515+
wrote_all = 0;
4516+
is_fin = 0;
4517+
goto UpdateStreamState;
4518+
}
45114519
assert(s->dst == s->dst_payload_from && "scatter does not expect other frames");
45124520
}
45134521
/* determine if the frame incorporates FIN, set flags as necessary */
@@ -4527,10 +4535,11 @@ quicly_error_t quicly_send_stream(quicly_stream_t *stream, quicly_send_context_t
45274535
commit_stream_frame(stream, sent, off_of_packet, s->dst - data_len, data_len, wrote_all, is_fin);
45284536
}
45294537

4538+
UpdateStreamState:
45304539
/* update stream sendstate */
45314540
update_stream_sendstate(stream, off, len, is_fin, wrote_all);
45324541

4533-
return 0;
4542+
return ret;
45344543
}
45354544

45364545
static inline quicly_error_t init_acks_iter(quicly_conn_t *conn, quicly_sentmap_iter_t *iter)

0 commit comments

Comments
 (0)