Skip to content

Commit 4afd00d

Browse files
authored
Merge pull request #14 from lyft/global-sigpipe
Globally disable SIGPIPE
2 parents 3d357f1 + 6b10ff6 commit 4afd00d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Kronos.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Kronos'
3-
s.version = '0.2.2'
3+
s.version = '0.2.3'
44
s.license = { :type => 'Apache License, Version 2.0', :file => 'LICENSE' }
55
s.summary = 'Elegant NTP client in Swift'
66
s.homepage = 'https://github.com/lyft/Kronos'

Sources/NTPClient.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ final class NTPClient {
145145
private func sendAsyncUDPQuery(to ip: InternetAddress, port: Int, timeout: TimeInterval,
146146
completion: UnsafeMutableRawPointer) -> (CFRunLoopSource, CFSocket)?
147147
{
148+
signal(SIGPIPE, SIG_IGN)
149+
148150
let callback: CFSocketCallBack = { socket, callbackType, address, data, info in
149151
if callbackType == .writeCallBack {
150152
var packet = NTPPacket()
@@ -179,9 +181,6 @@ final class NTPClient {
179181

180182
let runLoopSource = CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0)
181183
CFRunLoopAddSource(CFRunLoopGetMain(), runLoopSource, CFRunLoopMode.commonModes)
182-
183-
var noSIGPIPE: UInt32 = 1
184-
setsockopt(CFSocketGetNative(socket), SOL_SOCKET, SO_NOSIGPIPE, &noSIGPIPE, 4)
185184
CFSocketConnectToAddress(socket, ip.addressData(withPort: port), timeout)
186185
return (runLoopSource!, socket)
187186
}

0 commit comments

Comments
 (0)