remove redundant timers
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
b01d25277d
commit
00ce43d739
2 changed files with 14 additions and 30 deletions
|
@ -17,7 +17,7 @@ use ruma::{
|
||||||
DeviceKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
|
DeviceKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tracing::{debug, error};
|
use tracing::debug;
|
||||||
|
|
||||||
use super::SESSION_ID_LENGTH;
|
use super::SESSION_ID_LENGTH;
|
||||||
use crate::{services, utils, Error, Result, Ruma};
|
use crate::{services, utils, Error, Result, Ruma};
|
||||||
|
@ -368,23 +368,16 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||||
for (user_id, keys) in vec {
|
for (user_id, keys) in vec {
|
||||||
device_keys_input_fed.insert(user_id.to_owned(), keys.clone());
|
device_keys_input_fed.insert(user_id.to_owned(), keys.clone());
|
||||||
}
|
}
|
||||||
(
|
|
||||||
server,
|
let request = federation::keys::get_keys::v1::Request {
|
||||||
tokio::time::timeout(
|
device_keys: device_keys_input_fed,
|
||||||
Duration::from_secs(90),
|
};
|
||||||
services().sending.send_federation_request(
|
let response = services()
|
||||||
server,
|
.sending
|
||||||
federation::keys::get_keys::v1::Request {
|
.send_federation_request(server, request)
|
||||||
device_keys: device_keys_input_fed,
|
.await;
|
||||||
},
|
|
||||||
),
|
(server, Ok(response))
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|e| {
|
|
||||||
error!("get_keys_helper query took too long: {e}");
|
|
||||||
Error::BadServerResponse("get_keys_helper query took too long")
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -408,7 +401,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
|
||||||
false, /* Dont notify. A notification would trigger another key request resulting in an
|
false, /* Dont notify. A notification would trigger another key request resulting in an
|
||||||
* endless loop */
|
* endless loop */
|
||||||
)?;
|
)?;
|
||||||
master_keys.insert(user, raw);
|
master_keys.insert(user.clone(), raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
self_signing_keys.extend(response.self_signing_keys);
|
self_signing_keys.extend(response.self_signing_keys);
|
||||||
|
|
|
@ -44,7 +44,6 @@ pub(crate) struct Service {
|
||||||
receiver: Mutex<loole::Receiver<Msg>>,
|
receiver: Mutex<loole::Receiver<Msg>>,
|
||||||
startup_netburst: bool,
|
startup_netburst: bool,
|
||||||
startup_netburst_keep: i64,
|
startup_netburst_keep: i64,
|
||||||
timeout: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
@ -95,7 +94,6 @@ impl Service {
|
||||||
maximum_requests: Arc::new(Semaphore::new(config.max_concurrent_requests as usize)),
|
maximum_requests: Arc::new(Semaphore::new(config.max_concurrent_requests as usize)),
|
||||||
startup_netburst: config.startup_netburst,
|
startup_netburst: config.startup_netburst,
|
||||||
startup_netburst_keep: config.startup_netburst_keep,
|
startup_netburst_keep: config.startup_netburst_keep,
|
||||||
timeout: config.sender_timeout,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,17 +244,10 @@ impl Service {
|
||||||
where
|
where
|
||||||
T: OutgoingRequest + Debug,
|
T: OutgoingRequest + Debug,
|
||||||
{
|
{
|
||||||
let permit = self.maximum_requests.acquire().await;
|
|
||||||
let timeout = Duration::from_secs(self.timeout);
|
|
||||||
let client = &services().globals.client.federation;
|
let client = &services().globals.client.federation;
|
||||||
let response = tokio::time::timeout(timeout, send::send(client, dest, request))
|
let permit = self.maximum_requests.acquire().await;
|
||||||
.await
|
let response = send::send(client, dest, request).await;
|
||||||
.map_err(|_| {
|
|
||||||
warn!("Timeout after 300 seconds waiting for server response of {dest}");
|
|
||||||
Error::BadServerResponse("Timeout after 300 seconds waiting for server response")
|
|
||||||
})?;
|
|
||||||
drop(permit);
|
drop(permit);
|
||||||
|
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue