From: Iain Patterson Date: Fri, 15 Apr 2011 15:10:16 +0000 (+0100) Subject: Add an extra level of race avoidance. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=c42eb645b7dcc81838dd22c11bbd0970c02eeec5;p=profile.git Add an extra level of race avoidance. Checking for a kinit child can introduce a race. --- diff --git a/opt/bin/ktmux_helper b/opt/bin/ktmux_helper index 0e48ad4..e2b58a5 100755 --- a/opt/bin/ktmux_helper +++ b/opt/bin/ktmux_helper @@ -35,6 +35,8 @@ my $klist = $opts{'L'} || "klist"; my $krenew = $opts{'R'} || "krenew"; my $tmux = $opts{'T'} || "tmux"; +my $avoid_race = 0; + my $exitasap = 0; my $pid = 0; @@ -111,9 +113,12 @@ sub check_credentials { # We were signalled by our child which noticed that our credentials expired. sub want_credentials { + return sleep 1 if $avoid_race; + $avoid_race = 1; # Do we already know? - return sleep 1 if &check_kinit_child; - system $tmux, "new-window", "-n", "Renew Kerberos credentials", "exec $kinit"; + system $tmux, "new-window", "-n", "Renew Kerberos credentials", "exec $kinit" unless &check_kinit_child; + sleep 1; + $avoid_race = 0; } sub cleanup {