xmlstream: implement simple timeout logic

This allows to detect and handle dying streams without getting stuck
forever.

Timeouts are always wrong, though, so we put the burden of choosing the
right values (mostly) on the creator of a stream.
This commit is contained in:
Jonas Schäfer 2024-08-18 17:40:39 +02:00
commit 4cfe4f8429
16 changed files with 469 additions and 76 deletions

View file

@ -2,7 +2,7 @@ use futures::{SinkExt, StreamExt};
use tokio::{self, io, net::TcpSocket};
use tokio_xmpp::parsers::stream_features::StreamFeatures;
use tokio_xmpp::xmlstream::{accept_stream, StreamHeader};
use tokio_xmpp::xmlstream::{accept_stream, StreamHeader, Timeouts};
#[tokio::main]
async fn main() -> Result<(), io::Error> {
@ -19,6 +19,7 @@ async fn main() -> Result<(), io::Error> {
let stream = accept_stream(
tokio::io::BufStream::new(stream),
tokio_xmpp::parsers::ns::DEFAULT_NS,
Timeouts::default(),
)
.await?;
let stream = stream.send_header(StreamHeader::default()).await?;