Use vwait -timeout

This commit is contained in:
Joshua Root
2026-04-24 19:10:44 +10:00
parent 7a99a59de6
commit 65d109193c
2 changed files with 2 additions and 24 deletions
+1 -13
View File
@@ -1994,16 +1994,6 @@ match macports.conf.default."
}
}
# Call vwait on a variable after setting up a timer to write to it
# after ms milliseconds.
proc macports::vwait_with_timeout {var ms} {
set timeout_script_template {set %s [set %s]}
set timeout_script [string map [list %s $var] $timeout_script_template]
set timeout_eventid [after $ms $timeout_script]
vwait $var
after cancel $timeout_eventid
}
# call this just before you exit
proc mportshutdown {} {
global macports::portdbpath
@@ -2020,9 +2010,7 @@ proc mportshutdown {} {
# Wait up to 1 second for async pings to finish
set remaining 1000
while {$remaining > 0 && [dict size $pending_pings] > 0} {
set start [clock milliseconds]
macports::vwait_with_timeout ::macports::pending_pings $remaining
set remaining [expr {$remaining - ([clock milliseconds] - $start)}]
set remaining [vwait -timeout $remaining ::macports::pending_pings]
}
}
# Only save the cache if it was updated
+1 -11
View File
@@ -41,7 +41,6 @@ namespace eval mport_fetch_thread {
variable next_id 0
variable management_thread
trace add variable management_thread read mport_fetch_thread::init_management_thread
variable timeout_script_template {if {![info exists %s]} {set %s timeout}}
# Management thread code
variable init_script {
@@ -472,16 +471,7 @@ proc mport_fetch_thread::is_complete {id {timeout 0}} {
variable $id
if {![info exists $id]} {
if {$timeout > 0} {
variable timeout_script_template
set timeout_script [string map [list %s $id] \
$timeout_script_template]
set timeout_eventid [after $timeout $timeout_script]
vwait $id
if {[set $id] eq "timeout"} {
unset $id
} else {
after cancel $timeout_eventid
}
vwait -timeout $timeout $id
} else {
update
}