On Sun, Jan 23, 2000 at 06:56:39PM -0700, Warner Losh wrote:
>
> Each host gets a value of 1 (unless you go in and tweak it). Hosts
> are tried in order of their values and in some unspecified order in
[...]
> Each time you successfully connect, you get a bonus of B.
I think you need to keep an element of randomness to prevent "good
enough" from defeating "best".
Bonus B should be weighted by wire speed. I don't know how to make
cvsup spit this out when in batch mode.
This isn't exactly the algorithm you described. Finding differences
is left as an exercise. Acceptability of the constants chosen for the
algorithm varies with expected usage pattern of script.
This is the type of thing that should really be done in cvsup itself,
but I don't feel like learning Modula-3... :)
I disclaim responsibility for any stupid errors. All subtle errors
are completely my fault.
PS: I don't believe this script will work under Linux. Oops. ;-)
Sample cvshosts.dat file:
50 cvsup1.freebsd.org
50 cvsup2.freebsd.org
50 cvsup3.freebsd.org
50 cvsup4.freebsd.org
50 cvsup5.freebsd.org
50 cvsup6.freebsd.org
50 cvsup7.freebsd.org
50 cvsup8.freebsd.org
And the script,
#! /bin/sh
DATFILE=cvshosts.dat
if [ -z "$1" ];
then
fairings=$( (while read -t 0 host
do
if [ "${host%%[ ]*}" -eq 0 ]
then
continue
fi
fairings="${fairings}
$((${host%% *} * $(jot -r 1 5 9) + $(jot -r 1 1 3))) ${host#*[ ]}"
done; echo "${fairings}") < ${DATFILE})
hosts=`echo "$fairings" | sort -rn | awk '{print $2}'`
else
hosts=$1
shift
fi
# Potential security problem, probably
trap 'rm -f /tmp/cvshosts.dat.$$' 0
cp $DATFILE /tmp/cvshosts.dat.$$
echo "Will try hosts $(echo $hosts)"
for host in $hosts
do
echo "Using host $host"
if cvsup -1 -P m -s -g ~/bin/sup/fbsd-supfile -L 2 -h $host
then
# 1 works fairly well as a 2, also
perl -pi -e \
's/^(\d+)[ \t]+'"$host"'[ \t]*$/int (($a=$1+1)>100?10:$a) . "'" $host"'"/e' \
$DATFILE
exit;
else
perl -pi -e \
's/^(\d+)[ \t]+'"$host"'[ \t]*$/int (($a=$1-$1\/6)<1?1:$a) . "'" $host"'"/e' \
$DATFILE
fi
done
mv /tmp/cvshosts.dat.$$ $DATFILE
trap 0
--
Signature withheld by request of author.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message