Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions library/std/src/os/freebsd/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![unstable(feature = "unix_socket_ancillary_data", issue = "76915")]

use crate::ffi::CStr;
use crate::ffi::{CStr, CString};
use crate::io;
use crate::os::unix::net;
use crate::sys::AsInner;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub impl(self) trait UnixSocketExt {

/// Gets a filter name if one had been set previously on the socket.
#[unstable(feature = "acceptfilter", issue = "121891")]
fn acceptfilter(&self) -> io::Result<&CStr>;
fn acceptfilter(&self) -> io::Result<CString>;

/// Set or disable a filter on the socket to filter incoming connections
/// to defer it before accept(2)
Expand All @@ -61,7 +61,7 @@ impl UnixSocketExt for net::UnixDatagram {
self.as_inner().set_local_creds_persistent(local_creds_persistent)
}

fn acceptfilter(&self) -> io::Result<&CStr> {
fn acceptfilter(&self) -> io::Result<CString> {
self.as_inner().acceptfilter()
}

Expand All @@ -80,7 +80,7 @@ impl UnixSocketExt for net::UnixStream {
self.as_inner().set_local_creds_persistent(local_creds_persistent)
}

fn acceptfilter(&self) -> io::Result<&CStr> {
fn acceptfilter(&self) -> io::Result<CString> {
self.as_inner().acceptfilter()
}

Expand Down
8 changes: 4 additions & 4 deletions library/std/src/os/netbsd/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![unstable(feature = "unix_socket_ancillary_data", issue = "76915")]

use crate::ffi::CStr;
use crate::ffi::{CStr, CString};
use crate::io;
use crate::os::unix::net;
use crate::sys::AsInner;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub impl(self) trait UnixSocketExt {

/// Gets a filter name if one had been set previously on the socket.
#[unstable(feature = "acceptfilter", issue = "121891")]
fn acceptfilter(&self) -> io::Result<&CStr>;
fn acceptfilter(&self) -> io::Result<CString>;

/// Set or disable a filter on the socket to filter incoming connections
/// to defer it before accept(2)
Expand All @@ -61,7 +61,7 @@ impl UnixSocketExt for net::UnixDatagram {
self.as_inner().set_local_creds(local_creds)
}

fn acceptfilter(&self) -> io::Result<&CStr> {
fn acceptfilter(&self) -> io::Result<CString> {
self.as_inner().acceptfilter()
}

Expand All @@ -80,7 +80,7 @@ impl UnixSocketExt for net::UnixStream {
self.as_inner().set_local_creds(local_creds)
}

fn acceptfilter(&self) -> io::Result<&CStr> {
fn acceptfilter(&self) -> io::Result<CString> {
self.as_inner().acceptfilter()
}

Expand Down
6 changes: 3 additions & 3 deletions library/std/src/sys/net/connection/socket/unix.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use libc::{MSG_PEEK, c_int, c_void, size_t, sockaddr, socklen_t};

#[cfg(not(any(target_os = "espidf", target_os = "nuttx")))]
use crate::ffi::CStr;
use crate::ffi::{CStr, CString};
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
use crate::net::{Shutdown, SocketAddr};
use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
Expand Down Expand Up @@ -522,13 +522,13 @@ impl Socket {
}

#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
pub fn acceptfilter(&self) -> io::Result<&CStr> {
pub fn acceptfilter(&self) -> io::Result<CString> {
let arg: libc::accept_filter_arg =
unsafe { getsockopt(self, libc::SOL_SOCKET, libc::SO_ACCEPTFILTER)? };
let s: &[u8] =
unsafe { core::slice::from_raw_parts(arg.af_name.as_ptr() as *const u8, 16) };
let name = CStr::from_bytes_with_nul(s).unwrap();
Ok(name)
Ok(name.to_owned())
}

#[cfg(any(target_os = "solaris", target_os = "illumos"))]
Expand Down