interprocess
interprocess copied to clipboard
hand-waving `ErrorKind::AddrInUse` is unhelpful
Context: latest version 2.2.0, rust 1.79.0, macos ventura 13.6
I'm working on a cross-platform client for some thing or another, and I must use ipc on unix and windows.
In the previous major, getting an AddrInUse
meant that the /tmp/whatever
file had to be removed and that was it.
This was also expressed in the examples.
Not anymore.
In the current paradigm, once a GenericNamespaced
or GenericFilePath
is created it is impossible to extract whatever actual path is being used. In practicality, it means 2 things
- it is impossible to recover from deterministically since neither the dev nor a potential user will have a shred of a clue what should be done, for example what file needs to be removed
- it is effectively impossible to even brute-force recover from unless set in a loop or recreated internally
let printname = "myPipe";
let name = printname.to_ns_name::<GenericNamespaced>()?;
// Configure our listener...
let opts = ListenerOptions::new().name(name);
// ...and create it.
let listener = match opts.create_tokio() {
Err(e) if e.kind() == io::ErrorKind::AddrInUse => {
let path = format!("/tmp/{printname}"); // for example
let path = Path::new(&path);
fs::remove_file(&path).expect("..."); // there is no input to which there will be a valid output
ListenerOptions::new().name(name).create_tokio()? // `opts` cannot be moved, so they are impossible to reuse in this way
}
x => x?,
};
myPipe
, /tmp/myPipe
. /tmp/myPipe/
, /.pipe/myPipe
, @myPipe
, myPipe.sock
, /tmp/myPipe.sock
, are all invalid (as in, non-existent) files. This is regardless of usages of GenericNamespaced
and GenericFilePath
.
It might be that you know exactly what to do to handle the situation, but I have not the slightest of clues and neither did anyone in my team and circle. I've went through the docs, issues, and source files of this project many times over. I would very much appreciate some sort of guidance