Skip to content

Commit

Permalink
Merge pull request #41 from Bouke/fix/readcallback
Browse files Browse the repository at this point in the history
Fix for regression with CoreFoundation 5.3
  • Loading branch information
Bouke authored Nov 30, 2020
2 parents d8c6507 + 721fa62 commit 08e1f76
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Sources/NetService/FoundationCompat.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import CoreFoundation

#if !os(Linux) || compiler(>=5.3)
internal let kCFSocketReadCallBack = CFSocketCallBackType.readCallBack.rawValue
#endif

#if os(Linux) && !compiler(>=5.0)
import class Foundation.RunLoop
import struct Foundation.RunLoopMode
Expand Down
2 changes: 1 addition & 1 deletion Sources/NetService/NetService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public class NetService {

var context = CFSocketContext(version: 0, info: info, retain: nil, release: nil, copyDescription: nil)

socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(CFSocketCallBackType.readCallBack.rawValue), _processResult, &context)
socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(kCFSocketReadCallBack), _processResult, &context)

// Don't close the underlying socket on invalidate, as it is owned by dns_sd.
var socketFlags = CFSocketGetSocketFlags(socket)
Expand Down
2 changes: 1 addition & 1 deletion Sources/NetService/NetServiceBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public class NetServiceBrowser {
let info = Unmanaged.passUnretained(self).toOpaque()

var context = CFSocketContext(version: 0, info: info, retain: nil, release: nil, copyDescription: nil)
socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(CFSocketCallBackType.readCallBack.rawValue), _processResult, &context)
socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(kCFSocketReadCallBack), _processResult, &context)

// Don't close the underlying socket on invalidate, as it is owned by dns_sd.
var socketFlags = CFSocketGetSocketFlags(socket)
Expand Down

0 comments on commit 08e1f76

Please sign in to comment.