Skip to content

Commit af2e15e

Browse files
jmartinesppoljar
authored andcommitted
refactor(ffi): Add the default read_timeout value to the FFI layer
1 parent 79aa5aa commit af2e15e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bindings/matrix-sdk-ffi/src/client_builder.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ pub struct ClientBuilder {
133133
threads_enabled: bool,
134134
}
135135

136+
/// The timeout applies to each read operation, and resets after a successful
137+
/// read. This is more appropriate for detecting stalled connections when the
138+
/// size isn’t known beforehand.
139+
const DEFAULT_READ_TIMEOUT: Duration = Duration::from_secs(60);
140+
136141
#[matrix_sdk_ffi_macros::export]
137142
impl ClientBuilder {
138143
#[uniffi::constructor]
@@ -539,6 +544,7 @@ impl ClientBuilder {
539544
if let Some(timeout) = config.timeout {
540545
updated_config = updated_config.timeout(Duration::from_millis(timeout));
541546
}
547+
updated_config = updated_config.read_timeout(DEFAULT_READ_TIMEOUT);
542548
if let Some(max_concurrent_requests) = config.max_concurrent_requests {
543549
if max_concurrent_requests > 0 {
544550
updated_config = updated_config.max_concurrent_requests(NonZeroUsize::new(

0 commit comments

Comments
 (0)