Skip to content

Commit 6fb772b

Browse files
committed
use big length delimited codec frame sizes
1 parent 6fa8d9e commit 6fb772b

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

crates/corro-admin/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,12 @@ async fn handle_conn(
295295
) -> Result<(), AdminError> {
296296
// wrap in stream in line delimited json decoder
297297
let mut stream: FramedStream = tokio_serde::Framed::new(
298-
tokio_util::codec::Framed::new(stream, LengthDelimitedCodec::new()),
298+
tokio_util::codec::Framed::new(
299+
stream,
300+
LengthDelimitedCodec::builder()
301+
.max_frame_length(100 * 1_024 * 1_024)
302+
.new_codec(),
303+
),
299304
Json::<Command, Response>::default(),
300305
);
301306

crates/corro-agent/src/agent/bi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn spawn_bipayload_handler(
5656
let agent = agent.clone();
5757
let bookie = bookie.clone();
5858
async move {
59-
let mut framed = FramedRead::new(rx, LengthDelimitedCodec::new());
59+
let mut framed = FramedRead::new(rx, LengthDelimitedCodec::builder().max_frame_length(100 * 1_024 * 1_024).new_codec());
6060

6161
loop {
6262
match timeout(Duration::from_secs(5), StreamExt::next(&mut framed)).await {

crates/corro-agent/src/agent/uni.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ pub fn spawn_unipayload_handler(tripwire: &Tripwire, conn: &quinn::Connection, a
4141
tokio::spawn({
4242
let agent = agent.clone();
4343
async move {
44-
let mut framed = FramedRead::new(rx, LengthDelimitedCodec::new());
44+
let mut framed = FramedRead::new(
45+
rx,
46+
LengthDelimitedCodec::builder()
47+
.max_frame_length(100 * 1_024 * 1_024)
48+
.new_codec(),
49+
);
4550

4651
loop {
4752
match StreamExt::next(&mut framed).await {

crates/corro-agent/src/api/peer.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1063,13 +1063,13 @@ pub async fn parallel_sync(
10631063
*actor_id,
10641064
*addr,
10651065
async {
1066-
let mut codec = LengthDelimitedCodec::new();
1066+
let mut codec = LengthDelimitedCodec::builder().max_frame_length(100 * 1_024 * 1_024).new_codec();
10671067
let mut send_buf = BytesMut::new();
10681068
let mut encode_buf = BytesMut::new();
10691069

10701070
let actor_id = *actor_id;
10711071
let (mut tx, rx) = transport.open_bi(*addr).await?;
1072-
let mut read = FramedRead::new(rx, LengthDelimitedCodec::new());
1072+
let mut read = FramedRead::new(rx, LengthDelimitedCodec::builder().max_frame_length(100 * 1_024 * 1_024).new_codec());
10731073

10741074
encode_write_bipayload_msg(
10751075
&mut codec,
@@ -1240,7 +1240,7 @@ pub async fn parallel_sync(
12401240

12411241
tokio::spawn(async move {
12421242
// reusable buffers and constructs
1243-
let mut codec = LengthDelimitedCodec::new();
1243+
let mut codec = LengthDelimitedCodec::builder().max_frame_length(100 * 1_024 * 1_024).new_codec();
12441244
let mut send_buf = BytesMut::new();
12451245
let mut encode_buf = BytesMut::new();
12461246

@@ -1481,7 +1481,9 @@ pub async fn serve_sync(
14811481
tracing::Span::current().set_parent(context);
14821482

14831483
debug!(actor_id = %their_actor_id, self_actor_id = %agent.actor_id(), "received sync request");
1484-
let mut codec = LengthDelimitedCodec::new();
1484+
let mut codec = LengthDelimitedCodec::builder()
1485+
.max_frame_length(100 * 1_024 * 1_024)
1486+
.new_codec();
14851487
let mut send_buf = BytesMut::new();
14861488
let mut encode_buf = BytesMut::new();
14871489

crates/corro-agent/src/broadcast/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,9 @@ pub fn runtime_loop(
377377
tokio::spawn(async move {
378378
const BROADCAST_CUTOFF: usize = 64 * 1024;
379379

380-
let mut bcast_codec = LengthDelimitedCodec::new();
380+
let mut bcast_codec = LengthDelimitedCodec::builder()
381+
.max_frame_length(100 * 1_024 * 1_024)
382+
.new_codec();
381383

382384
let mut bcast_buf = BytesMut::new();
383385
let mut local_bcast_buf = BytesMut::new();

crates/corrosion/src/admin.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ impl AdminConn {
2323
let stream = UnixStream::connect(path).await?;
2424
Ok(Self {
2525
stream: Framed::new(
26-
tokio_util::codec::Framed::new(stream, LengthDelimitedCodec::new()),
26+
tokio_util::codec::Framed::new(
27+
stream,
28+
LengthDelimitedCodec::builder()
29+
.max_frame_length(100 * 1_024 * 1_024)
30+
.new_codec(),
31+
),
2732
Json::default(),
2833
),
2934
})

0 commit comments

Comments
 (0)