Skip to content

Commit 992078f

Browse files
Merge pull request parallaxsecond#651 from stevecapperarm/bump-sdnotify
Bump sd-notify to 0.3.0
2 parents 0de9b61 + d843ac2 commit 992078f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ base64 = "0.13.0"
2121
uuid = "0.8.2"
2222
threadpool = "1.8.1"
2323
signal-hook = "0.3.4"
24-
sd-notify = "0.2.0"
24+
sd-notify = "0.3.0"
2525
toml = "0.5.8"
2626
serde = { version = "1.0.123", features = ["derive"] }
2727
env_logger = "0.8.3"

src/front/domain_socket.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use anyhow::{Context, Result};
99
use listener::Listen;
1010
use listener::{Connection, ConnectionMetadata};
1111
use log::{error, warn};
12-
use std::convert::TryInto;
1312
use std::fs;
1413
use std::fs::Permissions;
1514
use std::io::{Error, ErrorKind};
1615
use std::os::unix::fs::FileTypeExt;
1716
use std::os::unix::fs::PermissionsExt;
1817
use std::os::unix::io::FromRawFd;
18+
use std::os::unix::io::RawFd;
1919
use std::os::unix::net::UnixListener;
2020
use std::path::PathBuf;
2121
use std::time::Duration;
@@ -38,7 +38,8 @@ impl DomainSocketListener {
3838
pub fn new(timeout: Duration, socket_path: PathBuf) -> Result<Self> {
3939
// If Parsec was service activated or not started under systemd, this
4040
// will return `0`. `1` will be returned in case Parsec is socket activated.
41-
let listener = match sd_notify::listen_fds()? {
41+
let listeners: Vec<RawFd> = sd_notify::listen_fds()?.collect();
42+
let listener = match listeners.len() {
4243
0 => {
4344
if socket_path.exists() {
4445
let meta = fs::metadata(&socket_path)?;
@@ -72,10 +73,10 @@ impl DomainSocketListener {
7273
1 => {
7374
// No need to set the socket as non-blocking, parsec.service
7475
// already requests that.
75-
let nfd = sd_notify::SD_LISTEN_FDS_START;
76+
let nfd = listeners[0];
7677
// Safe as listen_fds gives us the information that one file descriptor was
7778
// received and its value starts from SD_LISTEN_FDS_START.
78-
unsafe { UnixListener::from_raw_fd(nfd.try_into()?) }
79+
unsafe { UnixListener::from_raw_fd(nfd) }
7980
// Expect the socket created by systemd to be 666 on permissions.
8081
}
8182
n => {

0 commit comments

Comments
 (0)