]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Daemon.pm
bump version to 8.2.1
[pve-common.git] / src / PVE / Daemon.pm
index 2095001a1c60592be9831b09523d44b388b0016f..63fd5eed29195d8f07f8400e2a066481347df448 100644 (file)
@@ -114,10 +114,10 @@ my $writepidfile = sub {
 
     my $pidfile = $self->{pidfile};
 
-    die "can't open pid file '$pidfile' - $!\n" if !open (PIDFH, ">$pidfile");
+    open (my $PID_FH, '>', "$pidfile") or die "can't open pid file '$pidfile' - $!\n";
 
-    print PIDFH "$$\n";
-    close (PIDFH);
+    print $PID_FH "$$\n";
+    close ($PID_FH);
 };
 
 my $server_cleanup = sub {
@@ -243,8 +243,7 @@ sub setup {
 
     initlog($self->{name});
 
-    my $restart = $ENV{RESTART_PVE_DAEMON};
-    delete $ENV{RESTART_PVE_DAEMON};
+    my $restart = delete $ENV{RESTART_PVE_DAEMON};
     $self->{env_restart_pve_daemon} = $restart;
 
     my $lockfd = $ENV{PVE_DAEMON_LOCK_FD};
@@ -311,8 +310,8 @@ my $server_run = sub {
     $self->init();
 
     if (!$debug) {
-       open STDIN,  '</dev/null' || die "can't read /dev/null";
-       open STDOUT, '>/dev/null' || die "can't write /dev/null";
+       open STDIN,  '<', '/dev/null' or die "can't read /dev/null - $!";
+       open STDOUT, '>', '/dev/null' or die "can't write /dev/null - $!";
     }
 
     if (!$self->{env_restart_pve_daemon} && !$debug) {
@@ -573,7 +572,6 @@ my $read_pid = sub {
 
 # checks if the process was started by systemd
 my $init_ppid = sub {
-
     if (getppid() == 1) {
        return 1;
     } else {
@@ -799,7 +797,7 @@ sub register_status_command {
 # some useful helper
 
 sub create_reusable_socket {
-    my ($self, $port, $host, $family) = @_;
+    my ($self, $port, $host) = @_;
 
     die "no port specifed" if !$port;
 
@@ -818,6 +816,7 @@ sub create_reusable_socket {
 
        $socket->fcntl(Fcntl::F_SETFD(), Fcntl::FD_CLOEXEC);
     } else {
+
        my %sockargs = (
            LocalPort => $port,
            Listen => SOMAXCONN,
@@ -825,16 +824,7 @@ sub create_reusable_socket {
            GetAddrInfoFlags => 0,
            ReuseAddr => 1,
        );
-
-       # FIXME: drop this if clause and the $family parameter with 7.0:
-       # compat code for pmgproxy
-       if (defined($family)) {
-           $socket = IO::Socket::IP->new(
-               Family => $family,
-               LocalHost => $host,
-               %sockargs) ||
-               die "unable to create socket - $@\n";
-       } elsif (defined($host)) {
+       if (defined($host)) {
            $socket = IO::Socket::IP->new( LocalHost => $host, %sockargs) ||
                die "unable to create socket - $@\n";
        } else {