<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/0a000c436ce0f8bc7da7bb34efad896dca6a1e59">https://github.com/macports/macports-base/commit/0a000c436ce0f8bc7da7bb34efad896dca6a1e59</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 0a000c43 Ping no more than 50 hosts per invocation
</span>0a000c43 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 0a000c436ce0f8bc7da7bb34efad896dca6a1e59
</span>Author: Ryan Schmidt <ryandesign@macports.org>
AuthorDate: Fri Jul 10 01:23:18 2020 -0500
<span style='display:block; white-space:pre;color:#404040;'> Ping no more than 50 hosts per invocation
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Closes: https://trac.macports.org/ticket/60509
</span>---
src/port1.0/fetch_common.tcl | 47 +++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 14 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/fetch_common.tcl b/src/port1.0/fetch_common.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 10d3f7a9..fec62786 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/fetch_common.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/fetch_common.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -234,7 +234,6 @@ proc portfetch::sortsites {urls default_listvar} {
</span> }
}
set urllist $urlmap($url_var)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set hosts {}
</span>
if {[llength $urllist] <= 1} {
# there is only one mirror, no need to ping or sort
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -248,6 +247,7 @@ proc portfetch::sortsites {urls default_listvar} {
</span> seteuid 0; setegid 0
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set hosts {}
</span> foreach site $urllist {
if {[string range $site 0 6] eq "file://"} {
set pingtimes(localhost) 0
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -259,23 +259,42 @@ proc portfetch::sortsites {urls default_listvar} {
</span> if { [info exists seen($host)] } {
continue
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if { ![info exists seen($host)] } {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # first check the persistent cache
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set pingtimes($host) [get_pingtime $host]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$pingtimes($host) eq {}} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[catch {set fds($host) [open "|ping -noq -c3 -t3 $host"]}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Spawning ping for $host failed"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # will end up after all hosts that were pinged OK but before those that didn't respond
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set pingtimes($host) 5000
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set seen($host) yes
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend hosts $host
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # first check the persistent cache
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pingtimes($host) [get_pingtime $host]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$pingtimes($host) eq {}} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set seen($host) yes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend hosts $host
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set max_hosts_to_ping 50
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set len [llength $hosts]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$len > $max_hosts_to_ping} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # randomize them
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # shuffle10a from https://wiki.tcl-lang.org/page/Shuffle+a+list
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while {$len} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set n [expr {int($len*rand())}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set tmp [lindex $hosts $n]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lset hosts $n [lindex $hosts [incr len -1]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lset hosts $len $tmp
</span> }
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pinged_hosts {}
</span> foreach host $hosts {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $pinged_hosts] < $max_hosts_to_ping} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set fds($host) [open "|ping -noq -c3 -t3 $host"]}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "Spawning ping for $host failed"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend pinged_hosts $host
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # will end up after all hosts that were pinged OK but before those that didn't respond
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pingtimes($host) 5000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach host $pinged_hosts {
</span> set pingtimes($host) ""
while {[gets $fds($host) pingline] >= 0} {
if {[string match round-trip* $pingline]} {
</pre><pre style='margin:0'>
</pre>