| 1192 | } |
| 1193 | |
| 1194 | fn socket_path(run_dir: &Path, port: &str, process: u16) -> String { |
| 1195 | let desired = run_dir |
| 1196 | .join(format!("{port}-{process}")) |
| 1197 | .to_string_lossy() |
| 1198 | .into_owned(); |
| 1199 | if UnixSocketAddr::from_pathname(&desired).is_err() { |
| 1200 | // Unix socket addresses have a very low maximum length of around 100 |
| 1201 | // bytes on most platforms. |
| 1202 | env::temp_dir() |
| 1203 | .join(hex::encode(Sha1::digest(desired))) |
| 1204 | .display() |
| 1205 | .to_string() |
| 1206 | } else { |
| 1207 | desired |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | struct AddressedTcpListener { |
| 1212 | listener: TcpListener, |