vncserver: slice start time from 3 seconds to ~170ms

This commit is contained in:
Dmitry Maksyoma 2021-08-10 22:18:31 +12:00
parent 2b4f01f5ae
commit cc90fe9ff6

View File

@ -25,6 +25,8 @@
# vncserver - wrapper script to start an X VNC server.
#
use Time::HiRes qw (sleep);
&DetectEnvironment();
&SetGlobalVariables();
@ -41,7 +43,6 @@ $pidFile = "$vncUserDir/$host:$displayNumber.pid";
$kasmAuthEnabled = 1;
&DisableVncAuth();
if ($kasmAuthEnabled) {
&EnsureAtLeastOneKasmUserExists();
}
@ -54,11 +55,11 @@ $cmd = &ConstructXvncCmd();
&DeleteLogLeftFromPreviousXvncRun();
&StartXvncAndRecordPID();
&WaitForXvncToStart();
&WaitForXvncToRespond();
if (!&IsXvncRunning() && !&UsingSafeFontPath()) {
&StartXvncWithSafeFontPath();
&WaitForXvncToStart();
&WaitForXvncToRespond();
}
unless (&IsXvncRunning()) {
@ -956,8 +957,20 @@ sub WarnUserXvncNotStartedAndExit {
die "\n";
}
sub WaitForXvncToStart {
sleep(3);
sub WaitForXvncToRespond {
my $sleepSlice = 0.1;
my $sleptFor = 0;
my $sleepLimit = 3;
until (&IsXvncResponding() || $sleptFor >= $sleepLimit) {
sleep($sleepSlice);
$sleptFor += $sleepSlice;
}
}
sub IsXvncResponding {
`xdpyinfo -display :$displayNumber >/dev/null 2>&1`;
$? == 0;
}
sub UsingSafeFontPath {