From baf92537293371b347595d94d7a8c9cdcfa84768 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Sat, 19 Jun 2021 18:40:49 +0200 Subject: [PATCH] util/fossilize_db: Pull seek into lock. Otherwise the seek can overlap with other reads/writes. Fixes: eca6bb9540d ("util/fossilize_db: add basic fossilize db util to read/write shader caches") Reviewed-by: Timothy Arceri Part-of: (cherry picked from commit bd41c51c8f4d67d18d8a4407358ea4b71f153d2a) --- .pick_status.json | 2 +- src/util/fossilize_db.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 909ec369466..346996c94a3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3352,7 +3352,7 @@ "description": "util/fossilize_db: Pull seek into lock.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "eca6bb9540d8d1b260511cd0a71bdddb00ff4a3c" }, diff --git a/src/util/fossilize_db.c b/src/util/fossilize_db.c index b77d7bcfa9b..0d26cb00cae 100644 --- a/src/util/fossilize_db.c +++ b/src/util/fossilize_db.c @@ -362,14 +362,14 @@ foz_read_entry(struct foz_db *foz_db, const uint8_t *cache_key_160bit, goto fail; } + /* Reset file offset to the end of the file ready for writing */ + fseek(foz_db->file[file_idx], offset, SEEK_SET); + simple_mtx_unlock(&foz_db->mtx); if (size) *size = data_sz; - /* Reset file offset to the end of the file ready for writing */ - fseek(foz_db->file[file_idx], offset, SEEK_SET); - return data; fail: