Skip to content

Commit b6ea945

Browse files
authored
Merge pull request #105 from envoy/avoid-double-socket-closures
Avoid closing sockets twice
2 parents 845ada7 + a77d29a commit b6ea945

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/TCPSocket.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,12 @@ public final class TCPSocket {
201201

202202
/// Close the socket
203203
func close() {
204+
guard fileDescriptor != -1 else {
205+
return
206+
}
204207
_ = SystemLibrary.shutdown(fileDescriptor, Int32(SHUT_WR))
205208
_ = SystemLibrary.close(fileDescriptor)
209+
fileDescriptor = -1
206210
}
207211

208212
func getPeerName() throws -> (String, Int) {

0 commit comments

Comments
 (0)