From de5f027bdeead27fc2ec31ff2e8233dd06be3496 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Wed, 15 Mar 2023 17:09:25 +0100 Subject: [PATCH] fix potential race condition --- src/runtime/c/pgf/db.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/c/pgf/db.cxx b/src/runtime/c/pgf/db.cxx index f5685d9ce..9c8f7c11d 100644 --- a/src/runtime/c/pgf/db.cxx +++ b/src/runtime/c/pgf/db.cxx @@ -1733,6 +1733,10 @@ __forceinline bool AllClear(unsigned __int32 lock) void PgfDB::lock(DB_scope_mode m) { + // If another process has resized the file we must resize the map + if (mmap_size != ms->file_size) + resize_map(ms->file_size, m == WRITER_SCOPE); + if (m == READER_SCOPE) { #ifndef _WIN32 int res = pthread_rwlock_rdlock(&ms->rwlock); @@ -1767,10 +1771,6 @@ void PgfDB::lock(DB_scope_mode m) } #endif } - - // If another process has resized the file we must resize the map - if (mmap_size != ms->file_size) - resize_map(ms->file_size, m == WRITER_SCOPE); } void PgfDB::unlock()