Repository navigation
fix(tiles): count MBTiles metadata reads as fetches under way, so exports wait for them #1805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,14 +322,17 @@ pub fn info_ready(archive: &str, timeout: Duration) -> Result<Option<Arc<Info>>, | |
| let address = archive.to_string(); | ||
| let worker_key = key.clone(); | ||
| let still = crate::cache::current_still(); | ||
| // Counted before the answer says pending, so a caller waiting for fetches waits for it. | ||
| let counted = crate::cache::Counted::start(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| let spawned = std::thread::Builder::new().name("rustgis-mbtiles-info".into()).spawn(move || { | ||
| crate::cache::with_optional_still(still, || { | ||
| let result = crate::cache::check_still(&crate::cache::current_still()).and_then(|_| read_info(&address)); | ||
| remember_info(&address, &result, epoch); | ||
| }); | ||
| pending.lock().unwrap_or_else(|e| e.into_inner()).remove(&worker_key); | ||
| ready.notify_all(); | ||
| crate::cache::notify(); | ||
| // Over as a fetch is: the map draws again with what was read. | ||
| drop(counted); | ||
| }); | ||
| if let Err(error) = spawned { | ||
| all.remove(&key); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the lock until the metadata read starts.
If the render or metadata worker starts more than 300 ms late, the lock is already released. The test can then pass without exercising the regression, including on unfixed code. Synchronize the lock release with an observed metadata-read attempt, and check that rendering has not completed before releasing it.