Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: Add unix socket support?#172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
javaarchive wants to merge8 commits intolemunozm:master
base:master
Choose a base branch
Loading
fromjavaarchive:master
Draft
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Store bind path and delete on drop
  • Loading branch information
@javaarchive
javaarchive committedMay 31, 2024
commit1b416ece67078a315d745f6bdbd943be635cca62
2 changes: 1 addition & 1 deletionCargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ maintenance = { status = "actively-developed" }
all-features = true

[features]
default = ["tcp", "udp", "websocket"] # All features that are crossplatform by default
default = ["tcp", "udp", "websocket", "unixsocket"] # All features that are crossplatform by default
tcp = ["mio/net", "socket2"]
udp = ["mio/net", "socket2"]
websocket = ["tungstenite", "url", "tcp"]
Expand Down
18 changes: 16 additions & 2 deletionssrc/adapters/unix_socket.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::io::{self, ErrorKind, Read, Write};
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::fs;

// Note: net.core.rmem_max = 212992 by default on linux systems
// not used because w euse unixstream I think?
Expand DownExpand Up@@ -165,7 +166,8 @@ impl Remote for RemoteResource {
}

pub(crate) struct LocalResource {
listener: UnixListener
listener: UnixListener,
bind_path: PathBuf
}

impl Resource for LocalResource {
Expand All@@ -174,6 +176,16 @@ impl Resource for LocalResource {
}
}

impl Drop for LocalResource {
fn drop(&mut self) {
// this may fail if the file is already removed
match fs::remove_file(&self.bind_path) {
Ok(_) => (),
Err(err) => log::error!("Error removing unix socket file on drop: {}", err),
}
}
}

impl Local for LocalResource {
type Remote = RemoteResource;

Expand All@@ -184,11 +196,13 @@ impl Local for LocalResource {
};

// TODO: fallback to ip when we are able to set path to none
let path_copy = config.path.clone();
let listener = UnixListener::bind(config.path)?;
let local_addr = listener.local_addr()?;
Ok(ListeningInfo {
local: Self {
listener
listener,
bind_path: path_copy
},
// same issue as above my change in https://github.com/tokio-rs/mio/pull/1749
// relevant issue https://github.com/tokio-rs/mio/issues/1527
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp