diff options
author | Tobias Markmann <tm@ayena.de> | 2016-07-29 09:47:23 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-11-28 10:35:05 (GMT) |
commit | 2039930eadd4756068a8a60c8340d9908a7136d3 (patch) | |
tree | d8aca4bf98a2bb6e3b819305b1f87af3117f4910 /Swiften/StreamStack | |
parent | 2f90eb7409df91a80c60b189242ac0c1de313910 (diff) | |
download | swift-2039930eadd4756068a8a60c8340d9908a7136d3.zip swift-2039930eadd4756068a8a60c8340d9908a7136d3.tar.bz2 |
Correctly handle server initiated closing of stream
If a server closes the XMPP stream, it sends a </stream:stream>
tag. The client is supposed to respond with the same tag and
then both parties can close the TLS/TCP socket.
Previously Swift(-en) would simply ignore </stream:stream>
tag if it was not directly followed by a shutdown of the TCP
connection.
In addition there is now a timeout timer started as soon as
Swiften or the server initiates a shutdown. It will close
the socket and cleanup the ClientSession if the server does
not respond in time or the network is faulty.
Refactored some code in ClientSession in the process. Moved
ClientSession::State to a C++11 strongly typed enum class.
This also fixes issues where duplicated </stream:stream>
tags would be send by Swift.
Test-Information:
Tested against Prosody ba782a093b14 and M-Link 16.3v6-0,
which provide ad-hoc commands to end a user session.
Previously this was ignored by Swift. Now it correctly responds
to the server, detects it as a disconnect and tries to
reconnect afterwards.
Added unit test for the case where the server closes the
session stream.
Change-Id: I59dfde3aa6b50dc117f340e5db6b9e58b54b3c60
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r-- | Swiften/StreamStack/XMPPLayer.cpp | 1 | ||||
-rw-r--r-- | Swiften/StreamStack/XMPPLayer.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp index 2eed906..982d13f 100644 --- a/Swiften/StreamStack/XMPPLayer.cpp +++ b/Swiften/StreamStack/XMPPLayer.cpp @@ -86,6 +86,7 @@ void XMPPLayer::handleElement(std::shared_ptr<ToplevelElement> stanza) { } void XMPPLayer::handleStreamEnd() { + onStreamEnd(); } void XMPPLayer::resetParser() { diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h index 1d4abf8..f0b5afb 100644 --- a/Swiften/StreamStack/XMPPLayer.h +++ b/Swiften/StreamStack/XMPPLayer.h @@ -51,6 +51,7 @@ namespace Swift { public: boost::signals2::signal<void (const ProtocolHeader&)> onStreamStart; + boost::signals2::signal<void ()> onStreamEnd; boost::signals2::signal<void (std::shared_ptr<ToplevelElement>)> onElement; boost::signals2::signal<void (const SafeByteArray&)> onWriteData; boost::signals2::signal<void (const SafeByteArray&)> onDataRead; |