Skip to content

Commit 8566e51

Browse files
committed
protec
1 parent 20ea7ea commit 8566e51

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Sources/GCDSocket/GCDSocketClient.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@ public class GCDSocketClient<T: GCDSocketAddress> : GCDSocket, GCDSocketPointerM
4343

4444
resume()
4545

46-
let conres = rebound(from: descriptor.sockAddr) { saddr, slen in
47-
Darwin.connect(descriptor.handle, saddr, slen)
48-
}
49-
50-
if conres != 0 {
51-
if let handler = self.dataHandler { handler (.failure( .connect(errno)) ) }
52-
}
53-
else {
54-
connected?()
55-
}
46+
sockQ.async { [self] in
47+
48+
let conres = rebound(from: descriptor.sockAddr) { saddr, slen in
49+
Darwin.connect(descriptor.handle, saddr, slen)
50+
}
51+
52+
if conres != 0 {
53+
if let handler = dataHandler { handler (.failure( .connect(errno)) ) }
54+
}
55+
else {
56+
connected?()
57+
}
58+
}
5659
}
5760
}

0 commit comments

Comments
 (0)