diff options
author | Mike Yu <yumike@google.com> | 2021-11-29 14:57:54 +0800 |
---|---|---|
committer | Mike Yu <yumike@google.com> | 2021-12-03 21:01:57 +0800 |
commit | 5d2a10711b6194098a62a309e718117ec93238ca (patch) | |
tree | 37c096229bdc769a0d374e4ad8bf1417e3d600bc /doh | |
parent | 4bdc8678435acac88ea8bd79b06cc9114367b211 (diff) | |
download | DnsResolver-5d2a10711b6194098a62a309e718117ec93238ca.tar.gz |
DoH: Change Network to use try_send
As send() blocks until channel has capacity, Dispatcher gets blocked
at sending commands to a Network object if the Network's mpsc channel
has no capacity. This happens when there are excess DNS requests while
the connection has not been established. Therefore, change all the DoH
code to use try_send() that returns an error immediate if the channel
is full.
If a Network's mpsc channel has no capacity, DNS query threads that
called doh_query() with the associated net_id will get DOH_RESULT_CAN_NOT_SEND
error immediately. Since it's not a timeout error, they will try DoT.
Bug: 207301204
Test: cd packages/modules/DnsResolver && atest
Change-Id: I9575e6f410b8b552c07af15284b67b305ecce6b9
Diffstat (limited to 'doh')
-rw-r--r-- | doh/network/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/doh/network/mod.rs b/doh/network/mod.rs index 88b9ab63..21e47ec3 100644 --- a/doh/network/mod.rs +++ b/doh/network/mod.rs @@ -102,7 +102,7 @@ impl Network { .unwrap_or_else(|_| { warn!("Query result listener went away before receiving a response") }), - Status::Live => self.command_tx.send(Command::Query(query)).await?, + Status::Live => self.command_tx.try_send(Command::Query(query))?, } Ok(()) } |