Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 73703 - mirrorselect deep prefers non-existent hosts
Summary: mirrorselect deep prefers non-existent hosts
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High major
Assignee: John Mylchreest (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-07 12:09 UTC by Dieter Shirley
Modified: 2004-12-10 15:10 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dieter Shirley 2004-12-07 12:09:07 UTC
The code in mirrorselect for doing a deep check looks like this:

STIME=$(date)
wget ....
ETIME=$(date)
[ $? == 0] && echo stuff > tmpfile

What is intended, I'm sure, by the [ $? == 0 ] guard is to only include those hosts who successfully downloaded the file.  However, what $? is really checking is the return code of date.  Whoops!

The end result is that, non-existent hosts, which fail DNS lookup immediately, are considered "fast".

The code should instead look like this:

STIME=$(date)
wget ....
RESULT=$?
ETIME=$(date)
[ $RESULT == 0] && echo stuff > tmpfile

I've tested this locally to good effect.

Reproducible: Always
Steps to Reproduce:
Comment 1 John Mylchreest (RETIRED) gentoo-dev 2004-12-10 15:09:17 UTC
Im sure this is how you said it should be, as I'm sure I corrected this before I comitted.
will revisit later and correct where neccessary.
thanks.
Comment 2 John Mylchreest (RETIRED) gentoo-dev 2004-12-10 15:10:25 UTC
this is from 0.89

		YCOUNT=0
		for i in ${CHECKLIST}
		do
			YCOUNT=$((${YCOUNT}+1))
			PERCENT=$(((${YCOUNT}*100)/${COUNT}))
			print_percent "${PERCENT}" "${i}"
			STIME=$(date +%s%N)
			wget -t 1 -C off -T ${TIMEOUT} -O /dev/null - ${i}/distfiles/mirrorselect-test 2>/dev/null
			RESULT=${?}
			ETIME=$(date +%s%N)
			[ ${RESULT} == 0 ] && $(echo "$((${ETIME}-${STIME})) ${RESULT} ${i}" >> ${TMPFILE})
		done
		echo "Sorting by speed                                                                " >&2
		MIRRORS="$(sort -g < ${TMPFILE} | cut -f3- -d" " | head -n ${SERVERS})"

Could you please retest with this version and feed me back your results.
Cheers.