Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b474307 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Use into_raw_fd to convert unixstream

Using as_raw_fd will drop the unixstream once it's out of scope.
Instead, convert it back to a standard unixstream (from tokio
unixstream) and then convert to raw fd.

Bug: 259485364
Tag: #floss
Test: Manually
Change-Id: I3a50531f3d12cc8947f35a847094693c0b7be48f
parent 84ba244d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -366,7 +366,11 @@ impl InternalConnectingSocket {
// an open and valid file to operate on, converting to file via RawFd is just
// boilerplate.
fn unixstream_to_file(stream: UnixStream) -> std::fs::File {
    unsafe { std::fs::File::from_raw_fd(stream.as_raw_fd()) }
    unsafe {
        std::fs::File::from_raw_fd(
            stream.into_std().expect("Failed to convert tokio unixstream").into_raw_fd(),
        )
    }
}

// This is a safe operation in an unsafe wrapper. A file is already open and owned