From b5c3b26321964978abb3b03230684a347a00a4b7 Mon Sep 17 00:00:00 2001 From: David Jones Date: Tue, 25 Jul 2017 16:16:12 +0100 Subject: [PATCH] Temporary workaround for IBM-Swift/Kitura#1034 (#211) * IBM-Swift/Kitura#1034: Debugging second crash, sacrificial first field in IncomingSocketHandler The crash always seems to relate to the first instance field of the IncomingSocketHandler class. Introducing a dummy one that is never used apparently avoids the crash. * Add comment --- Sources/KituraNet/IncomingSocketHandler.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/KituraNet/IncomingSocketHandler.swift b/Sources/KituraNet/IncomingSocketHandler.swift index 5f576a0..74405b9 100644 --- a/Sources/KituraNet/IncomingSocketHandler.swift +++ b/Sources/KituraNet/IncomingSocketHandler.swift @@ -35,7 +35,12 @@ import Socket public class IncomingSocketHandler { static let socketWriterQueue = DispatchQueue(label: "Socket Writer") - + + // This variable is unused. It is a temporary workaround for a rare crash under load + // (see: https://github.com/IBM-Swift/Kitura/issues/1034) while a proper fix is + // investigated. + var superfluousOptional:String? = String(repeating: "x", count: 2) + #if os(OSX) || os(iOS) || os(tvOS) || os(watchOS) || GCD_ASYNCH static let socketReaderQueues = [DispatchQueue(label: "Socket Reader A"), DispatchQueue(label: "Socket Reader B")]