Parcourir la source

vncserver: Display check should check for lock file first

Checking for the existence of `/tmp/.X<n>-lock` is a fast read-only
operation, while calls to bind() or connect() are more expensive and
may have side effects. Perform the fast operation first.
tags/v1.10.90
Mark Mielke il y a 3 ans
Parent
révision
344a9b2da3
1 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 6
    6
      unix/vncserver/vncserver.in

+ 6
- 6
unix/vncserver/vncserver.in Voir le fichier

{ {
local ($n) = @_; local ($n) = @_;


if (-e "/tmp/.X$n-lock") {
warn "\nWarning: $host:$n is taken because of /tmp/.X$n-lock\n";
warn "Remove this file if there is no X server $host:$n\n";
return 0;
}

socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n"; socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))'; eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))';
if (!bind(S, pack('S n x12', $AF_INET, 6000 + $n))) { if (!bind(S, pack('S n x12', $AF_INET, 6000 + $n))) {
} }
close(S); close(S);


if (-e "/tmp/.X$n-lock") {
warn "\nWarning: $host:$n is taken because of /tmp/.X$n-lock\n";
warn "Remove this file if there is no X server $host:$n\n";
return 0;
}

if (-e "/tmp/.X11-unix/X$n") { if (-e "/tmp/.X11-unix/X$n") {
warn "\nWarning: $host:$n is taken because of /tmp/.X11-unix/X$n\n"; warn "\nWarning: $host:$n is taken because of /tmp/.X11-unix/X$n\n";
warn "Remove this file if there is no X server $host:$n\n"; warn "Remove this file if there is no X server $host:$n\n";

Chargement…
Annuler
Enregistrer