Skip to content

Commit

Permalink
Merge pull request #105 from envoy/avoid-double-socket-closures
Browse files Browse the repository at this point in the history
Avoid closing sockets twice
  • Loading branch information
Goos authored Jan 27, 2023
2 parents 845ada7 + a77d29a commit b6ea945
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/TCPSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ public final class TCPSocket {

/// Close the socket
func close() {
guard fileDescriptor != -1 else {
return
}
_ = SystemLibrary.shutdown(fileDescriptor, Int32(SHUT_WR))
_ = SystemLibrary.close(fileDescriptor)
fileDescriptor = -1
}

func getPeerName() throws -> (String, Int) {
Expand Down

0 comments on commit b6ea945

Please sign in to comment.