tokio_xmpp: fix Client on servers without Stream Management
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.
This commit is contained in:
parent
07f3dc4785
commit
fc62229dc5
1 changed files with 1 additions and 0 deletions
|
|
@ -260,6 +260,7 @@ impl ConnectedState {
|
|||
let next = next.take();
|
||||
match stream.as_mut().start_send(&next.stanza) {
|
||||
Ok(()) => {
|
||||
next.token.send_replace(StanzaState::Sent {});
|
||||
if let Some(sm_state) = sm_state.as_mut() {
|
||||
sm_state.enqueue(next);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue