@@ -9,13 +9,13 @@ use anyhow::{Context, Result};
99use listener:: Listen ;
1010use listener:: { Connection , ConnectionMetadata } ;
1111use log:: { error, warn} ;
12- use std:: convert:: TryInto ;
1312use std:: fs;
1413use std:: fs:: Permissions ;
1514use std:: io:: { Error , ErrorKind } ;
1615use std:: os:: unix:: fs:: FileTypeExt ;
1716use std:: os:: unix:: fs:: PermissionsExt ;
1817use std:: os:: unix:: io:: FromRawFd ;
18+ use std:: os:: unix:: io:: RawFd ;
1919use std:: os:: unix:: net:: UnixListener ;
2020use std:: path:: PathBuf ;
2121use 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