1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Fix initializing clientHandledStanzasCount

From XEP-198: Stream Management § 4. Acks:

"""
Note: There are two values of 'h' for any given stream: one maintained
by the client to keep track of stanzas it has handled from the server,
and one maintained by the server to keep track of stanzas it has handled
from the client. The client initializes its value to zero when it sends
<enable/> to the server, and the server initializes its value to zero
when it sends <enabled/> to the client (it is expected that the server
will respond immediately to <enable/> and set its counter to zero at
that time).
"""

Previously smack initialized both to 0 just before sending enabled. But
according to the note from XEP-198 the server's counter is initialized
by the server "when it sends <enabled/> to the client, so we need to set
clientHandledStanzasCount to 0 when we receive <enabled/>. Because the
server started counted right after he send <enabled/>.

Thanks to Kim "zash" Alvefur for pointing this out.
This commit is contained in:
Florian Schmaus 2015-01-15 14:42:08 +01:00
parent 9950f4d5de
commit 3582de0654

View file

@ -362,7 +362,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
if (isSmAvailable() && useSm) { if (isSmAvailable() && useSm) {
// Remove what is maybe left from previously stream managed sessions // Remove what is maybe left from previously stream managed sessions
unacknowledgedStanzas = new ArrayBlockingQueue<Packet>(QUEUE_SIZE); unacknowledgedStanzas = new ArrayBlockingQueue<Packet>(QUEUE_SIZE);
clientHandledStanzasCount = 0;
serverHandledStanzasCount = 0; serverHandledStanzasCount = 0;
// XEP-198 3. Enabling Stream Management. If the server response to 'Enable' is 'Failed' // XEP-198 3. Enabling Stream Management. If the server response to 'Enable' is 'Failed'
// then this is a non recoverable error and we therefore throw an exception. // then this is a non recoverable error and we therefore throw an exception.
@ -1047,6 +1046,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// Mark this a aon-resumable stream by setting smSessionId to null // Mark this a aon-resumable stream by setting smSessionId to null
smSessionId = null; smSessionId = null;
} }
clientHandledStanzasCount = 0;
smWasEnabledAtLeastOnce = true; smWasEnabledAtLeastOnce = true;
smEnabledSyncPoint.reportSuccess(); smEnabledSyncPoint.reportSuccess();
LOGGER.fine("Stream Management (XEP-198): succesfully enabled"); LOGGER.fine("Stream Management (XEP-198): succesfully enabled");