-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Expose UDP_MAX_SEGMENTS via System #2891
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,3 +258,18 @@ extension System { | |
public static let supportsUDPReceiveOffload: Bool = false | ||
#endif | ||
} | ||
|
||
extension System { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wy is this in a new extension? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for separation of groups of related code - but I'm happy to lump it together if you'd rather. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've consolidated them now that I'm only adding one thing. |
||
/// Returns the UDP maximum segment count if the platform supports and defines it. | ||
public static func udpMaxSegments() -> Int? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should really be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that's true: the cost of this function is pretty close to the cost of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed this to a |
||
#if os(Linux) | ||
if CNIOLinux_udp_max_segments_defined() { | ||
return Int(CNIOLinux_UDP_MAX_SEGMENTS) | ||
} else { | ||
return nil | ||
} | ||
#else | ||
return nil | ||
#endif | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than have
max_segments_defined
, we should probably just return a sentinel value.-1
is good.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I normally try to avoid sentinel values as a rule but given we know that this value should comfortably fit within an
Int64
I can live with it here, particularly if it might help the optimizer see through this logic.