Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87e2eeda authored by Mike Yu's avatar Mike Yu Committed by Automerger Merge Worker
Browse files

DoH: Increase the size of Network mpsc channel am: 153b3fe1 am: 1f651757

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1906167

Change-Id: Ie16c64826bbd0843f90d34a84d719af75fff4b27
parents 0950c3f3 1f651757
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -283,6 +283,7 @@ impl H3Driver {
        // If the request has already timed out, don't issue it to the server.
        // If the request has already timed out, don't issue it to the server.
        if let Some(expiry) = request.expiry {
        if let Some(expiry) = request.expiry {
            if BootTime::now() > expiry {
            if BootTime::now() > expiry {
                warn!("Abandoning expired DNS request");
                return Ok(());
                return Ok(());
            }
            }
        }
        }
+9 −2
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ use crate::config::Config;
use crate::connection::Connection;
use crate::connection::Connection;
use crate::dispatcher::{QueryError, Response};
use crate::dispatcher::{QueryError, Response};
use crate::encoding;
use crate::encoding;
use anyhow::{anyhow, Result};
use anyhow::{anyhow, bail, Result};
use std::sync::Arc;
use std::sync::Arc;
use tokio::sync::{mpsc, watch};
use tokio::sync::{mpsc, watch};
use tokio::task;
use tokio::task;
@@ -90,7 +90,7 @@ async fn build_connection(
}
}


impl Driver {
impl Driver {
    const MAX_BUFFERED_COMMANDS: usize = 10;
    const MAX_BUFFERED_COMMANDS: usize = 50;


    pub async fn new(
    pub async fn new(
        info: ServerInfo,
        info: ServerInfo,
@@ -175,6 +175,13 @@ impl Driver {
    }
    }


    async fn send_query(&mut self, query: Query) -> Result<()> {
    async fn send_query(&mut self, query: Query) -> Result<()> {
        // If the associated receiver has been closed, meaning that the request has already
        // timed out, just drop it. This check helps drain the channel quickly in the case
        // where the network is stalled.
        if query.response.is_closed() {
            bail!("Abandoning expired DNS request")
        }

        if !self.connection.wait_for_live().await {
        if !self.connection.wait_for_live().await {
            // Try reconnecting
            // Try reconnecting
            self.connection =
            self.connection =
+2 −2
Original line number Original line Diff line number Diff line
@@ -703,11 +703,11 @@ TEST_F(PrivateDnsDohTest, TemporaryConnectionStalled) {
// Note: This test is subject to MAX_BUFFERED_COMMANDS. If the value is changed, this test might
// Note: This test is subject to MAX_BUFFERED_COMMANDS. If the value is changed, this test might
// need to be modified as well.
// need to be modified as well.
TEST_F(PrivateDnsDohTest, ExcessDnsRequests) {
TEST_F(PrivateDnsDohTest, ExcessDnsRequests) {
    const int total_queries = 20;
    const int total_queries = 70;


    // The number is from MAX_BUFFERED_COMMANDS + 2 (one that will be queued in
    // The number is from MAX_BUFFERED_COMMANDS + 2 (one that will be queued in
    // connection mpsc channel; the other one that will get blocked at dispatcher sending channel).
    // connection mpsc channel; the other one that will get blocked at dispatcher sending channel).
    const int timeout_queries = 12;
    const int timeout_queries = 52;


    const int initial_max_idle_timeout_ms = 2000;
    const int initial_max_idle_timeout_ms = 2000;
    ASSERT_TRUE(doh.stopServer());
    ASSERT_TRUE(doh.stopServer());