Commit 56cf829b authored by Dietmar Maurer's avatar Dietmar Maurer

spiceproxy: keep socket open on restart

parent 01b3b6ee
......@@ -61,7 +61,21 @@ sub init {
my $lockfh = IO::File->new(">>${accept_lock_fn}") ||
die "unable to open lock file '${accept_lock_fn}' - $!\n";
my $socket = IO::Socket::INET->new(
my ($socket, $sockfd);
if (defined($sockfd = $ENV{PVE_DAEMON_SOCKET_3128}) &&
$self->{env_restart_pve_daemon}) {
die "unable to parse socket fd '$sockfd'\n"
if $sockfd !~ m/^(\d+)$/;
$sockfd = $1; # untaint
$socket = IO::Socket::INET->new;
$socket->fdopen($sockfd, 'w') ||
die "cannot fdopen file descriptor '$sockfd' - $!\n";
} else {
$socket = IO::Socket::INET->new(
LocalAddr => undef, # all interfaces
LocalPort => 3128,
Listen => SOMAXCONN,
......@@ -73,6 +87,12 @@ sub init {
# so we disable that to maximize performance
setsockopt($socket, IPPROTO_TCP, TCP_NODELAY, 1);
$ENV{PVE_DAEMON_SOCKET_3128} = $socket->fileno;
}
# remove FD_CLOEXEC bit to reuse on exec
$socket->fcntl(Fcntl::F_SETFD(), 0);
$self->{server_config} = {
base_handler_class => 'PVE::API2',
keep_alive => 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment