@@ -9,13 +9,13 @@ use anyhow::{Context, Result};
9
9
use listener:: Listen ;
10
10
use listener:: { Connection , ConnectionMetadata } ;
11
11
use log:: { error, warn} ;
12
- use std:: convert:: TryInto ;
13
12
use std:: fs;
14
13
use std:: fs:: Permissions ;
15
14
use std:: io:: { Error , ErrorKind } ;
16
15
use std:: os:: unix:: fs:: FileTypeExt ;
17
16
use std:: os:: unix:: fs:: PermissionsExt ;
18
17
use std:: os:: unix:: io:: FromRawFd ;
18
+ use std:: os:: unix:: io:: RawFd ;
19
19
use std:: os:: unix:: net:: UnixListener ;
20
20
use std:: path:: PathBuf ;
21
21
use std:: time:: Duration ;
@@ -38,7 +38,8 @@ impl DomainSocketListener {
38
38
pub fn new ( timeout : Duration , socket_path : PathBuf ) -> Result < Self > {
39
39
// If Parsec was service activated or not started under systemd, this
40
40
// 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 ( ) {
42
43
0 => {
43
44
if socket_path. exists ( ) {
44
45
let meta = fs:: metadata ( & socket_path) ?;
@@ -72,10 +73,10 @@ impl DomainSocketListener {
72
73
1 => {
73
74
// No need to set the socket as non-blocking, parsec.service
74
75
// already requests that.
75
- let nfd = sd_notify :: SD_LISTEN_FDS_START ;
76
+ let nfd = listeners [ 0 ] ;
76
77
// Safe as listen_fds gives us the information that one file descriptor was
77
78
// 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) }
79
80
// Expect the socket created by systemd to be 666 on permissions.
80
81
}
81
82
n => {
0 commit comments