Bug 1960583 - Revert minimum pacer delay constraint r=kershaw,leggert,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D245563
This commit is contained in:
@@ -14757,16 +14757,6 @@
|
||||
mirror: always
|
||||
rust: true
|
||||
|
||||
# It represents the maximum duration that we used to accumulate
|
||||
# callback timeouts before we set a timer and break out of the loop.
|
||||
#
|
||||
# Note the typo in accumlated. Not worth fixing.
|
||||
- name: network.http.http3.max_accumlated_time_ms
|
||||
type: RelaxedAtomicUint32
|
||||
value: 1
|
||||
mirror: always
|
||||
rust: true
|
||||
|
||||
# Whether to send an mlkem768x25519 key share in HTTP/3 TLS handshakes.
|
||||
# Has no effect unless security.tls.enable_kyber is true.
|
||||
- name: network.http.http3.enable_kyber
|
||||
|
||||
@@ -155,7 +155,7 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
|
||||
StaticPrefs::network_http_http3_max_stream_data(),
|
||||
StaticPrefs::network_http_http3_version_negotiation_enabled(),
|
||||
mConnInfo->GetWebTransport(), gHttpHandler->Http3QlogDir(),
|
||||
datagramSize, StaticPrefs::network_http_http3_max_accumlated_time_ms(),
|
||||
datagramSize,
|
||||
aProviderFlags, idleTimeout, getter_AddRefs(mHttp3Connection));
|
||||
} else {
|
||||
rv = NeqoHttp3Conn::Init(
|
||||
@@ -166,7 +166,7 @@ nsresult Http3Session::Init(const nsHttpConnectionInfo* aConnInfo,
|
||||
StaticPrefs::network_http_http3_max_stream_data(),
|
||||
StaticPrefs::network_http_http3_version_negotiation_enabled(),
|
||||
mConnInfo->GetWebTransport(), gHttpHandler->Http3QlogDir(),
|
||||
datagramSize, StaticPrefs::network_http_http3_max_accumlated_time_ms(),
|
||||
datagramSize,
|
||||
aProviderFlags, idleTimeout, socket->GetFileDescriptor(),
|
||||
getter_AddRefs(mHttp3Connection));
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ class NeqoHttp3Conn final {
|
||||
uint32_t aMaxTableSize, uint16_t aMaxBlockedStreams, uint64_t aMaxData,
|
||||
uint64_t aMaxStreamData, bool aVersionNegotiation, bool aWebTransport,
|
||||
const nsACString& aQlogDir, uint32_t aDatagramSize,
|
||||
uint32_t aMaxAccumulatedTime, uint32_t aProviderFlags,
|
||||
uint32_t aIdleTimeout, NeqoHttp3Conn** aConn) {
|
||||
uint32_t aProviderFlags, uint32_t aIdleTimeout, NeqoHttp3Conn** aConn) {
|
||||
return neqo_http3conn_new_use_nspr_for_io(
|
||||
&aOrigin, &aAlpn, &aLocalAddr, &aRemoteAddr, aMaxTableSize,
|
||||
aMaxBlockedStreams, aMaxData, aMaxStreamData, aVersionNegotiation,
|
||||
aWebTransport, &aQlogDir, aDatagramSize, aMaxAccumulatedTime,
|
||||
aProviderFlags, aIdleTimeout,
|
||||
aWebTransport, &aQlogDir, aDatagramSize, aProviderFlags, aIdleTimeout,
|
||||
(const mozilla::net::NeqoHttp3Conn**)aConn);
|
||||
}
|
||||
|
||||
@@ -35,15 +33,13 @@ class NeqoHttp3Conn final {
|
||||
uint64_t aMaxData, uint64_t aMaxStreamData,
|
||||
bool aVersionNegotiation, bool aWebTransport,
|
||||
const nsACString& aQlogDir, uint32_t aDatagramSize,
|
||||
uint32_t aMaxAccumulatedTime, uint32_t aProviderFlags,
|
||||
uint32_t aIdleTimeout, int64_t socket,
|
||||
NeqoHttp3Conn** aConn) {
|
||||
uint32_t aProviderFlags, uint32_t aIdleTimeout,
|
||||
int64_t socket, NeqoHttp3Conn** aConn) {
|
||||
return neqo_http3conn_new(
|
||||
&aOrigin, &aAlpn, &aLocalAddr, &aRemoteAddr, aMaxTableSize,
|
||||
aMaxBlockedStreams, aMaxData, aMaxStreamData, aVersionNegotiation,
|
||||
aWebTransport, &aQlogDir, aDatagramSize, aMaxAccumulatedTime,
|
||||
aProviderFlags, aIdleTimeout, socket,
|
||||
(const mozilla::net::NeqoHttp3Conn**)aConn);
|
||||
aWebTransport, &aQlogDir, aDatagramSize, aProviderFlags, aIdleTimeout,
|
||||
socket, (const mozilla::net::NeqoHttp3Conn**)aConn);
|
||||
}
|
||||
|
||||
void Close(uint64_t aError) { neqo_http3conn_close(this, aError); }
|
||||
|
||||
@@ -9,7 +9,6 @@ use std::time::Duration;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
cmp::{max, min},
|
||||
ffi::c_void,
|
||||
io,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||
@@ -101,8 +100,6 @@ pub struct NeqoHttp3Conn {
|
||||
conn: Http3Client,
|
||||
local_addr: SocketAddr,
|
||||
refcnt: AtomicRefcnt,
|
||||
last_output_time: Instant,
|
||||
max_accumulated_time: Duration,
|
||||
/// Socket to use for IO.
|
||||
///
|
||||
/// When [`None`], NSPR is used for IO.
|
||||
@@ -167,10 +164,6 @@ fn netaddr_to_socket_addr(arg: *const NetAddr) -> Result<SocketAddr, nsresult> {
|
||||
Err(NS_ERROR_UNEXPECTED)
|
||||
}
|
||||
|
||||
fn get_current_or_last_output_time(last_output_time: &Instant) -> Instant {
|
||||
max(*last_output_time, Instant::now())
|
||||
}
|
||||
|
||||
type SendFunc = extern "C" fn(
|
||||
context: *mut c_void,
|
||||
addr_family: u16,
|
||||
@@ -212,7 +205,6 @@ impl NeqoHttp3Conn {
|
||||
webtransport: bool,
|
||||
qlog_dir: &nsACString,
|
||||
webtransport_datagram_size: u32,
|
||||
max_accumulated_time_ms: u32,
|
||||
provider_flags: u32,
|
||||
idle_timeout: u32,
|
||||
socket: Option<i64>,
|
||||
@@ -381,8 +373,6 @@ impl NeqoHttp3Conn {
|
||||
conn,
|
||||
local_addr: local,
|
||||
refcnt: unsafe { AtomicRefcnt::new() },
|
||||
last_output_time: Instant::now(),
|
||||
max_accumulated_time: Duration::from_millis(max_accumulated_time_ms.into()),
|
||||
socket,
|
||||
datagram_segment_size_sent: networking::http_3_udp_datagram_segment_size_sent
|
||||
.start_buffer(),
|
||||
@@ -587,7 +577,6 @@ pub extern "C" fn neqo_http3conn_new(
|
||||
webtransport: bool,
|
||||
qlog_dir: &nsACString,
|
||||
webtransport_datagram_size: u32,
|
||||
max_accumulated_time_ms: u32,
|
||||
provider_flags: u32,
|
||||
idle_timeout: u32,
|
||||
socket: i64,
|
||||
@@ -608,7 +597,6 @@ pub extern "C" fn neqo_http3conn_new(
|
||||
webtransport,
|
||||
qlog_dir,
|
||||
webtransport_datagram_size,
|
||||
max_accumulated_time_ms,
|
||||
provider_flags,
|
||||
idle_timeout,
|
||||
Some(socket),
|
||||
@@ -636,7 +624,6 @@ pub extern "C" fn neqo_http3conn_new_use_nspr_for_io(
|
||||
webtransport: bool,
|
||||
qlog_dir: &nsACString,
|
||||
webtransport_datagram_size: u32,
|
||||
max_accumulated_time_ms: u32,
|
||||
provider_flags: u32,
|
||||
idle_timeout: u32,
|
||||
result: &mut *const NeqoHttp3Conn,
|
||||
@@ -656,7 +643,6 @@ pub extern "C" fn neqo_http3conn_new_use_nspr_for_io(
|
||||
webtransport,
|
||||
qlog_dir,
|
||||
webtransport_datagram_size,
|
||||
max_accumulated_time_ms,
|
||||
provider_flags,
|
||||
idle_timeout,
|
||||
None,
|
||||
@@ -693,8 +679,7 @@ pub unsafe extern "C" fn neqo_http3conn_process_input_use_nspr_for_io(
|
||||
IpTos::default(),
|
||||
(*packet).as_slice(),
|
||||
);
|
||||
conn.conn
|
||||
.process_input(d, get_current_or_last_output_time(&conn.last_output_time));
|
||||
conn.conn.process_input(d, Instant::now());
|
||||
NS_OK
|
||||
}
|
||||
|
||||
@@ -780,27 +765,8 @@ pub extern "C" fn neqo_http3conn_process_output_and_send_use_nspr_for_io(
|
||||
) -> nsresult {
|
||||
assert!(conn.socket.is_none(), "NSPR IO path");
|
||||
|
||||
let now = Instant::now();
|
||||
if conn.last_output_time > now {
|
||||
// The timer fired too early, so reschedule it.
|
||||
// The 1ms of extra delay is not ideal, but this is a fail
|
||||
let Ok(timer) =
|
||||
u64::try_from((conn.last_output_time - now + conn.max_accumulated_time).as_millis())
|
||||
else {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
};
|
||||
set_timer_func(context, timer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
let mut accumulated_time = Duration::from_nanos(0);
|
||||
loop {
|
||||
conn.last_output_time = if accumulated_time.is_zero() {
|
||||
Instant::now()
|
||||
} else {
|
||||
now + accumulated_time
|
||||
};
|
||||
match conn.conn.process_output(conn.last_output_time) {
|
||||
match conn.conn.process_output(Instant::now()) {
|
||||
Output::Datagram(dg) => {
|
||||
let Ok(len) = u32::try_from(dg.len()) else {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
@@ -828,23 +794,16 @@ pub extern "C" fn neqo_http3conn_process_output_and_send_use_nspr_for_io(
|
||||
}
|
||||
}
|
||||
Output::Callback(to) => {
|
||||
if to.is_zero() {
|
||||
set_timer_func(context, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
let timeout = min(to, Duration::from_nanos(u64::MAX - 1));
|
||||
accumulated_time += timeout;
|
||||
if accumulated_time >= conn.max_accumulated_time {
|
||||
let Ok(mut timeout) = u64::try_from(accumulated_time.as_millis()) else {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
};
|
||||
if timeout == 0 {
|
||||
timeout = 1;
|
||||
}
|
||||
set_timer_func(context, timeout);
|
||||
break;
|
||||
}
|
||||
let timeout = if to.is_zero() {
|
||||
Duration::from_millis(1)
|
||||
} else {
|
||||
to
|
||||
};
|
||||
let Ok(timeout) = u64::try_from(timeout.as_millis()) else {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
};
|
||||
set_timer_func(context, timeout);
|
||||
break;
|
||||
}
|
||||
Output::None => {
|
||||
set_timer_func(context, u64::MAX);
|
||||
@@ -869,39 +828,13 @@ pub extern "C" fn neqo_http3conn_process_output_and_send(
|
||||
context: *mut c_void,
|
||||
set_timer_func: SetTimerFunc,
|
||||
) -> ProcessOutputAndSendResult {
|
||||
let now = Instant::now();
|
||||
if conn.last_output_time > now {
|
||||
// The timer fired too early, so reschedule it.
|
||||
// The 1ms of extra delay is not ideal, but this is a fail
|
||||
let Ok(timer) =
|
||||
u64::try_from((conn.last_output_time - now + conn.max_accumulated_time).as_millis())
|
||||
else {
|
||||
return ProcessOutputAndSendResult {
|
||||
result: NS_ERROR_UNEXPECTED,
|
||||
bytes_written: 0,
|
||||
};
|
||||
};
|
||||
set_timer_func(context, timer);
|
||||
return ProcessOutputAndSendResult {
|
||||
result: NS_OK,
|
||||
bytes_written: 0,
|
||||
};
|
||||
}
|
||||
|
||||
let mut accumulated_time = Duration::from_nanos(0);
|
||||
let mut bytes_written: usize = 0;
|
||||
loop {
|
||||
conn.last_output_time = if accumulated_time.is_zero() {
|
||||
Instant::now()
|
||||
} else {
|
||||
now + accumulated_time
|
||||
};
|
||||
|
||||
let output = conn
|
||||
.buffered_outbound_datagram
|
||||
.take()
|
||||
.map(Output::Datagram)
|
||||
.unwrap_or_else(|| conn.conn.process_output(conn.last_output_time));
|
||||
.unwrap_or_else(|| conn.conn.process_output(Instant::now()));
|
||||
match output {
|
||||
Output::Datagram(mut dg) => {
|
||||
if !static_prefs::pref!("network.http.http3.ecn") {
|
||||
@@ -949,26 +882,19 @@ pub extern "C" fn neqo_http3conn_process_output_and_send(
|
||||
conn.datagram_segment_size_sent.accumulate(dg.len() as u64);
|
||||
}
|
||||
Output::Callback(to) => {
|
||||
if to.is_zero() {
|
||||
set_timer_func(context, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
let timeout = min(to, Duration::from_nanos(u64::MAX - 1));
|
||||
accumulated_time += timeout;
|
||||
if accumulated_time >= conn.max_accumulated_time {
|
||||
let Ok(mut timeout) = u64::try_from(accumulated_time.as_millis()) else {
|
||||
return ProcessOutputAndSendResult {
|
||||
result: NS_ERROR_UNEXPECTED,
|
||||
bytes_written: 0,
|
||||
};
|
||||
let timeout = if to.is_zero() {
|
||||
Duration::from_millis(1)
|
||||
} else {
|
||||
to
|
||||
};
|
||||
let Ok(timeout) = u64::try_from(timeout.as_millis()) else {
|
||||
return ProcessOutputAndSendResult {
|
||||
result: NS_ERROR_UNEXPECTED,
|
||||
bytes_written: 0,
|
||||
};
|
||||
if timeout == 0 {
|
||||
timeout = 1;
|
||||
}
|
||||
set_timer_func(context, timeout);
|
||||
break;
|
||||
}
|
||||
};
|
||||
set_timer_func(context, timeout);
|
||||
break;
|
||||
}
|
||||
Output::None => {
|
||||
set_timer_func(context, u64::MAX);
|
||||
@@ -985,11 +911,7 @@ pub extern "C" fn neqo_http3conn_process_output_and_send(
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn neqo_http3conn_close(conn: &mut NeqoHttp3Conn, error: u64) {
|
||||
conn.conn.close(
|
||||
get_current_or_last_output_time(&conn.last_output_time),
|
||||
error,
|
||||
"",
|
||||
);
|
||||
conn.conn.close(Instant::now(), error, "");
|
||||
}
|
||||
|
||||
fn is_excluded_header(name: &str) -> bool {
|
||||
@@ -1079,7 +1001,7 @@ pub extern "C" fn neqo_http3conn_fetch(
|
||||
}
|
||||
let priority = Priority::new(urgency, incremental);
|
||||
match conn.conn.fetch(
|
||||
get_current_or_last_output_time(&conn.last_output_time),
|
||||
Instant::now(),
|
||||
method_tmp,
|
||||
&(scheme_tmp, host_tmp, path_tmp),
|
||||
&hdrs,
|
||||
@@ -1754,11 +1676,10 @@ pub unsafe extern "C" fn neqo_http3conn_read_response_data(
|
||||
fin: &mut bool,
|
||||
) -> nsresult {
|
||||
let array = slice::from_raw_parts_mut(buf, len as usize);
|
||||
match conn.conn.read_data(
|
||||
get_current_or_last_output_time(&conn.last_output_time),
|
||||
StreamId::from(stream_id),
|
||||
&mut array[..],
|
||||
) {
|
||||
match conn
|
||||
.conn
|
||||
.read_data(Instant::now(), StreamId::from(stream_id), &mut array[..])
|
||||
{
|
||||
Ok((amount, fin_recvd)) => {
|
||||
let Ok(amount) = u32::try_from(amount) else {
|
||||
return NS_ERROR_NET_HTTP3_PROTOCOL_ERROR;
|
||||
@@ -1863,10 +1784,7 @@ pub extern "C" fn neqo_http3conn_peer_certificate_info(
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn neqo_http3conn_authenticated(conn: &mut NeqoHttp3Conn, error: PRErrorCode) {
|
||||
conn.conn.authenticated(
|
||||
error.into(),
|
||||
get_current_or_last_output_time(&conn.last_output_time),
|
||||
);
|
||||
conn.conn.authenticated(error.into(), Instant::now());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -1874,10 +1792,7 @@ pub extern "C" fn neqo_http3conn_set_resumption_token(
|
||||
conn: &mut NeqoHttp3Conn,
|
||||
token: &mut ThinVec<u8>,
|
||||
) {
|
||||
_ = conn.conn.enable_resumption(
|
||||
get_current_or_last_output_time(&conn.last_output_time),
|
||||
token,
|
||||
);
|
||||
_ = conn.conn.enable_resumption(Instant::now(), token);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -1960,7 +1875,7 @@ pub extern "C" fn neqo_http3conn_webtransport_create_session(
|
||||
};
|
||||
|
||||
match conn.conn.webtransport_create_session(
|
||||
get_current_or_last_output_time(&conn.last_output_time),
|
||||
Instant::now(),
|
||||
&("https", host_tmp, path_tmp),
|
||||
&hdrs,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user