Overview
Comment: | Updated to avoid hammering remote servers if cache cannot be updated for some reason other than downloading failed |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | df8e635cacec68652b909590743e1d61ea6f51e3 |
User & Date: | rkeene on 2015-12-08 14:13:58 |
Other Links: | manifest | tags |
Context
2016-07-10
| ||
19:05 | Updated to finalize a thread that terminated even if there are no current Tcl interpreters associated with it check-in: b03c6db3d1 user: rkeene tags: trunk | |
2015-12-08
| ||
14:13 | Updated to avoid hammering remote servers if cache cannot be updated for some reason other than downloading failed check-in: df8e635cac user: rkeene tags: trunk | |
2015-11-19
| ||
16:01 | Updated initializer to be explicitly unsigned check-in: f905360d64 user: rkeene tags: trunk | |
Changes
Modified appfsd.tcl from [9efbb291d1] to [865f14848a].
284 284 return -code error "Unable to fetch (file does not exist: $file)" 285 285 } 286 286 287 287 return $file 288 288 } 289 289 290 290 proc getindex {hostname} { 291 + if {[string match "*\[/~\]*" $hostname]} { 292 + return -code error "Invalid hostname" 293 + } 294 + 291 295 set now [clock seconds] 292 296 293 297 set lastUpdates [db eval {SELECT lastUpdate, ttl FROM sites WHERE hostname = $hostname LIMIT 1;}] 294 298 if {[llength $lastUpdates] == 0} { 295 299 set lastUpdate 0 296 300 set ttl 0 297 301 } else { ................................................................................ 299 303 set ttl [lindex $lastUpdates 1] 300 304 } 301 305 302 306 if {$now < ($lastUpdate + $ttl)} { 303 307 return COMPLETE 304 308 } 305 309 306 - if {[string match "*\[/~\]*" $hostname]} { 307 - return -code error "Invalid hostname" 308 - } 309 - 310 310 set url "http://$hostname/appfs/index" 311 311 312 312 catch { 313 313 set token [::http::geturl $url] 314 314 if {[::http::ncode $token] == "200"} { 315 315 set indexhash_data [::http::data $token] 316 316 } 317 317 ::http::reset $token 318 318 ::http::cleanup $token 319 319 } 320 320 321 + # Note that we attempted to fetch this index and do not try 322 + # again for a while 323 + db eval {INSERT OR REPLACE INTO sites (hostname, lastUpdate, ttl) VALUES ($hostname, $now, $::appfs::nttl);} 324 + 321 325 if {![info exists indexhash_data]} { 322 - # Cache this result for 60 seconds 323 - db eval {INSERT OR REPLACE INTO sites (hostname, lastUpdate, ttl) VALUES ($hostname, $now, $::appfs::nttl);} 324 - 325 326 return -code error "Unable to fetch $url" 326 327 } 327 328 328 329 set indexhash_data [string trim $indexhash_data "\r\n"] 329 330 set indexhash_data [split $indexhash_data ","] 330 331 set indexhash [lindex $indexhash_data 0] 331 332 set indexhashmethod [lindex $indexhash_data 1]