tokio_xmpp: fix Client on servers without Stream Management
Jonas Schäfer
created
The Client::send_stanza method blocks on the stanza actually being sent
over the stream. Without this change, the method will never return
on streams without XEP-0198 Stream Management because `sm_state` is
then None and thus the StanzaToken's state is never advanced: it would
be stuck in Queued state.
In addition, a lack of advancement to Sent state may cause a deadlock on
XEP-0198-enabled streams if data is received so fast that the
frontend_tx mpsc::Sender in the stanzastream::Worker is filled up. In
such a case, the Worker cannot obtain a permit and will only service
writes. However, that will mean that no StanzaTokens can be advanced
beyond Queued state, because for that, reads need to be serviced (to
receive the SM acks).
If a burst of stanzas is then received while Client::send_stanza is
being awaited, send_stanza can only return if something reads from the
frontend mpsc in the meantime. We do not want to require user code to
drive the Client in full-duplex mode, hence this is a bug.
skip-changelog, because this fixes an unreleased feature.