Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 73703

Summary: mirrorselect deep prefers non-existent hosts
Product: Gentoo Linux Reporter: Dieter Shirley <dete>
Component: [OLD] UnspecifiedAssignee: John Mylchreest (RETIRED) <johnm>
Status: RESOLVED TEST-REQUEST    
Severity: major    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

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.