From 767ec6e932091f773e144330c10703c60ac332de Mon Sep 17 00:00:00 2001 From: Dan Diemer Date: Thu, 2 Jun 2022 09:28:39 -0500 Subject: [PATCH 1/2] Update dispatchQueue async to use dispatchGroup instead of explicit leave call --- JustLog/Classes/LogstashDestinationSocket.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/JustLog/Classes/LogstashDestinationSocket.swift b/JustLog/Classes/LogstashDestinationSocket.swift index 0ab9f7e..3d2f211 100644 --- a/JustLog/Classes/LogstashDestinationSocket.swift +++ b/JustLog/Classes/LogstashDestinationSocket.swift @@ -93,12 +93,10 @@ class LogstashDestinationSocket: NSObject, LogstashDestinationSocketProtocol { return } - self.dispatchQueue.async { + self.dispatchQueue.async(group: dispatchGroup) { if let error = error { sendStatus[tag] = error } - - dispatchGroup.leave() } } } From d6e26d729ec7f508001da4198a497f5863144d44 Mon Sep 17 00:00:00 2001 From: Dan Diemer Date: Thu, 2 Jun 2022 09:29:14 -0500 Subject: [PATCH 2/2] Close task instead of cancel This feels more correct in the context of what we're doing. --- JustLog/Classes/LogstashDestinationSocket.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/JustLog/Classes/LogstashDestinationSocket.swift b/JustLog/Classes/LogstashDestinationSocket.swift index 3d2f211..5ebdea9 100644 --- a/JustLog/Classes/LogstashDestinationSocket.swift +++ b/JustLog/Classes/LogstashDestinationSocket.swift @@ -103,7 +103,9 @@ class LogstashDestinationSocket: NSObject, LogstashDestinationSocketProtocol { task.resume() dispatchGroup.notify(queue: queue) { - task.cancel() + task.closeRead() + task.closeWrite() + complete(sendStatus) } }