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 /BuildTools | |
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 'BuildTools')
-rwxr-xr-x | BuildTools/FixIncludes.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/BuildTools/FixIncludes.py b/BuildTools/FixIncludes.py index d1b8268..8984944 100755 --- a/BuildTools/FixIncludes.py +++ b/BuildTools/FixIncludes.py @@ -1,93 +1,96 @@ #!/usr/bin/env python import sys; import os; import re; from sets import Set filename = sys.argv[1] inPlace = False if "-i" in sys.argv: inPlace = True filename_base = os.path.basename(filename) (filename_name, filename_ext) = os.path.splitext(filename_base) c_stdlib_headers = Set(["assert.h", "limits.h", "signal.h", "stdlib.h", "ctype.h", "locale.h", "stdarg.h", "string.h", "errno.h", "math.h", "stddef.h", "time.h", "float.h", "setjmp.h", "stdio.h", "iso646.h", "wchar.h", "wctype.h", "complex.h", "inttypes.h", "stdint.h", "tgmath.h", "fenv.h", "stdbool.h"]) cpp_stdlib_headers = Set(["algorithm", "fstream", "list", "regex", "typeindex", "array", "functional", "locale", "set", "typeinfo", "atomic", "future", "map", "sstream", "type_traits", "bitset", "initializer_list", "memory", "stack", "unordered_map", "chrono", "iomanip", "mutex", "stdexcept", "unordered_set", "codecvt", "ios", "new", "streambuf", "utility", "complex", "iosfwd", "numeric", "string", "valarray", "condition_variable", "iostream", "ostream", "strstream", "vector", "deque", "istream", "queue", "system_error", "exception", "iterator", "random", "thread", "forward_list", "limits", "ratio", "tuple", "cassert", "ciso646", "csetjmp", "cstdio", "ctime", "cctype", "climits", "csignal", "cstdlib", "cwchar", "cerrno", "clocale", "cstdarg", "cstring", "cwctype", "cfloat", "cmath", "cstddef"]) class HeaderType: - PRAGMA_ONCE, CORRESPONDING_HEADER, C_STDLIB, CPP_STDLIB, BOOST, QT, OTHER, SWIFTEN, LIMBER, SLIMBER, SWIFT_CONTROLLERS, SLUIFT, SWIFTOOLS, SWIFT = range(14) + PRAGMA_ONCE, CORRESPONDING_HEADER, C_STDLIB, CPP_STDLIB, BOOST, QT, SWIFTEN_BASE_DEBUG, OTHER, SWIFTEN, LIMBER, SLIMBER, SWIFT_CONTROLLERS, SLUIFT, SWIFTOOLS, SWIFT = range(15) def findHeaderBlock(lines): start = False end = False lastLine = None for idx, line in enumerate(lines): if not start and line.startswith("#"): start = idx elif start and (not end) and (not line.startswith("#")) and line.strip(): end = idx-1 break if not end: end = len(lines) return (start, end) def lineToFileName(line): match = re.match( r'#include "(.*)"', line) if match: return match.group(1) match = re.match( r'#include <(.*)>', line) if match: return match.group(1) return False def fileNameToHeaderType(name): if name.endswith("/" + filename_name + ".h"): return HeaderType.CORRESPONDING_HEADER if name in c_stdlib_headers: return HeaderType.C_STDLIB if name in cpp_stdlib_headers: return HeaderType.CPP_STDLIB if name.startswith("boost"): return HeaderType.BOOST if name.startswith("Q"): return HeaderType.QT + if name.startswith("Swiften/Base/Debug.h"): + return HeaderType.SWIFTEN_BASE_DEBUG + if name.startswith("Swiften"): return HeaderType.SWIFTEN if name.startswith("Limber"): return HeaderType.LIMBER if name.startswith("Slimber"): return HeaderType.SLIMBER if name.startswith("Swift/Controllers"): return HeaderType.SWIFT_CONTROLLERS if name.startswith("Sluift"): return HeaderType.SLUIFT if name.startswith("SwifTools"): return HeaderType.SWIFTOOLS if name.startswith("Swift"): return HeaderType.SWIFT return HeaderType.OTHER def serializeHeaderGroups(groups): headerList = [] for group in range(0, HeaderType.SWIFT + 1): if group in groups: # sorted and without duplicates headers = sorted(list(set(groups[group]))) headerList.extend(headers) |