stanzastream: actually count stanzas in stream management

Looks like a horrible oversight. And this will need tests, but I'm short
on time right now.

Fixes #170.
This commit is contained in:
Jonas Schäfer 2026-02-11 08:16:17 +01:00
commit a1ade974b0
4 changed files with 13 additions and 0 deletions

View file

@ -8,6 +8,8 @@ Version NEXT:
- Gate `AsRawFd` behind `ktls` feature to make Windows build work again. - Gate `AsRawFd` behind `ktls` feature to make Windows build work again.
- Implicitly use the `Client`'s bound JID on empty `to` in tokio-xmpp's - Implicitly use the `Client`'s bound JID on empty `to` in tokio-xmpp's
`IqResponseTracker`. `IqResponseTracker`.
- Actually count inbound stream management stanzas (!657) instead of
always sending h='0' in our `<a/>`.
Version 5.0.0: Version 5.0.0:
2025-10-28 pep <pep@bouah.net> 2025-10-28 pep <pep@bouah.net>

View file

@ -21,6 +21,9 @@ pub(crate) fn make_id() -> String {
} }
/// A stanza sent/received over the stream. /// A stanza sent/received over the stream.
// WARNING: do not add variants to this enum! Adding variants which refer
// to anything but IQ, Message or Presence stanzas will cause the
// stream management counters to be off.
#[derive(FromXml, AsXml, Debug, PartialEq)] #[derive(FromXml, AsXml, Debug, PartialEq)]
#[xml()] #[xml()]
pub enum Stanza { pub enum Stanza {

View file

@ -543,6 +543,9 @@ impl ConnectedState {
match item { match item {
// Easy case, we got some data. // Easy case, we got some data.
Ok(XmppStreamElement::Stanza(data)) => { Ok(XmppStreamElement::Stanza(data)) => {
if let Some(sm_state) = sm_state.as_mut() {
sm_state.received();
}
Poll::Ready(Some(ConnectedEvent::Worker(WorkerEvent::Stanza(data)))) Poll::Ready(Some(ConnectedEvent::Worker(WorkerEvent::Stanza(data))))
} }

View file

@ -214,6 +214,11 @@ impl SmState {
self.inbound_ctr self.inbound_ctr
} }
/// Increase the inbound counter.
pub fn received(&mut self) {
self.inbound_ctr = self.inbound_ctr.wrapping_add(1);
}
/// Get the info necessary for resumption. /// Get the info necessary for resumption.
/// ///
/// Returns the stream ID and the current inbound counter if resumption is /// Returns the stream ID and the current inbound counter if resumption is