diff --git a/JustLog/Classes/LogstashDestinationSocket.swift b/JustLog/Classes/LogstashDestinationSocket.swift index 0ab9f7e..5ebdea9 100644 --- a/JustLog/Classes/LogstashDestinationSocket.swift +++ b/JustLog/Classes/LogstashDestinationSocket.swift @@ -93,19 +93,19 @@ class LogstashDestinationSocket: NSObject, LogstashDestinationSocketProtocol { return } - self.dispatchQueue.async { + self.dispatchQueue.async(group: dispatchGroup) { if let error = error { sendStatus[tag] = error } - - dispatchGroup.leave() } } } task.resume() dispatchGroup.notify(queue: queue) { - task.cancel() + task.closeRead() + task.closeWrite() + complete(sendStatus) } }