Skip to content

Commit

Permalink
Merge pull request #657 from hatoo/fix-fast-workers-http2
Browse files Browse the repository at this point in the history
Some refactors to fast http2 workers
  • Loading branch information
hatoo authored Jan 10, 2025
2 parents cbf7951 + 8c6f8af commit 5ffcf2f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,8 @@ pub mod fast {
let client = client.clone();
let token = token.clone();
local.spawn_local(Box::pin(async move {
let mut has_err = false;
let mut result_data_err = ResultData::default();
loop {
let client = client.clone();
match setup_http2(&client).await {
Expand Down Expand Up @@ -2016,20 +2018,22 @@ pub mod fast {
}

if connection_gone {
return;
break;
}
}
Err(err) => {
if counter.fetch_add(1, Ordering::Relaxed) < n_tasks {
let mut result_data = ResultData::default();
result_data.push(Err(err));
report_tx.send(result_data).unwrap();
has_err = true;
result_data_err.push(Err(err));
} else {
return;
break;
}
}
}
}
if has_err {
report_tx.send(result_data_err).unwrap();
}
}));
}

Expand Down Expand Up @@ -2143,6 +2147,8 @@ pub mod fast {
let token = token.clone();
let is_end = is_end.clone();
local.spawn_local(Box::pin(async move {
let mut has_err = false;
let mut result_data_err = ResultData::default();
loop {
let client = client.clone();
match setup_http2(&client).await {
Expand Down Expand Up @@ -2209,19 +2215,21 @@ pub mod fast {
}

if connection_gone {
return;
break;
}
}
Err(err) => {
let mut result_data = ResultData::default();
result_data.push(Err(err));
report_tx.send(result_data).unwrap();
has_err = true;
result_data_err.push(Err(err));
if is_end.load(Ordering::Relaxed) {
return;
break;
}
}
}
}
if has_err {
report_tx.send(result_data_err).unwrap();
}
}));
}

Expand Down

0 comments on commit 5ffcf2f

Please sign in to comment.