Skip to content

Commit

Permalink
Merge pull request #12 from lyft/nosigpipe
Browse files Browse the repository at this point in the history
Handle SIGPIPE on the UDP socket
  • Loading branch information
Reflejo committed Oct 27, 2016
2 parents d12f364 + 8512899 commit 3d357f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
`Kronos` adheres to [Semantic Versioning](http://semver.org/).

## [0.2.2](https://github.com/lyft/Kronos/releases/tag/0.2.1)
- Add NOSIGPIPE to socket so the app doesn't crash on the event of a
PIPE signal

## [0.2.1](https://github.com/lyft/Kronos/releases/tag/0.2.1)
- Fix crash on DNS timeout after Swift 3 integration

Expand Down
2 changes: 1 addition & 1 deletion Kronos.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Kronos'
s.version = '0.2.1'
s.version = '0.2.2'
s.license = { :type => 'Apache License, Version 2.0', :file => 'LICENSE' }
s.summary = 'Elegant NTP client in Swift'
s.homepage = 'https://github.com/lyft/Kronos'
Expand Down
3 changes: 3 additions & 0 deletions Sources/NTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ final class NTPClient {

let runLoopSource = CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0)
CFRunLoopAddSource(CFRunLoopGetMain(), runLoopSource, CFRunLoopMode.commonModes)

var noSIGPIPE: UInt32 = 1
setsockopt(CFSocketGetNative(socket), SOL_SOCKET, SO_NOSIGPIPE, &noSIGPIPE, 4)
CFSocketConnectToAddress(socket, ip.addressData(withPort: port), timeout)
return (runLoopSource!, socket)
}
Expand Down

0 comments on commit 3d357f1

Please sign in to comment.