Skip to content

Commit bde49f1

Browse files
authored
Adjust sockaddr lengths for illumos in more more place. (#904)
Following up on #900, add illumos to the platforms that may return a Unix-domain socket address with a shorter string than the socklen value. And following up on #901, a another test for TCP_NODELAY.
1 parent b0a83ce commit bde49f1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/backend/libc/net/read_sockaddr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ pub(crate) unsafe fn read_sockaddr(
167167
// Otherwise we expect a NUL-terminated filesystem path.
168168

169169
// Trim off unused bytes from the end of `path_bytes`.
170-
let path_bytes = if cfg!(target_os = "freebsd") {
171-
// FreeBSD sometimes sets the length to longer than the
172-
// length of the NUL-terminated string. Find the NUL and
173-
// truncate the string accordingly.
170+
let path_bytes = if cfg!(any(solarish, target_os = "freebsd")) {
171+
// FreeBSD and illumos sometimes set the length to longer
172+
// than the length of the NUL-terminated string. Find the
173+
// NUL and truncate the string accordingly.
174174
&decode.sun_path[..decode
175175
.sun_path
176176
.iter()

tests/net/sockopt.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,18 @@ fn test_sockopts_tcp(s: &OwnedFd) {
205205
assert!(sockopt::get_tcp_keepintvl(&s).is_ok());
206206
}
207207

208-
// Set the nodelay flag;
208+
// Set the nodelay flag.
209209
sockopt::set_tcp_nodelay(&s, true).unwrap();
210210

211211
// Check that the nodelay flag is set.
212212
assert!(sockopt::get_tcp_nodelay(&s).unwrap());
213213

214+
// Clear the nodelay flag.
215+
sockopt::set_tcp_nodelay(&s, false).unwrap();
216+
217+
// Check that the nodelay flag is cleared.
218+
assert!(!sockopt::get_tcp_nodelay(&s).unwrap());
219+
214220
#[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))]
215221
{
216222
// Set keepalive values:

0 commit comments

Comments
 (0)