From 77268fe2f36cffc64555441ec9d1ffd844f232d6 Mon Sep 17 00:00:00 2001 From: Eugen Betke Date: Tue, 14 Jan 2025 17:25:35 +0100 Subject: [PATCH] Move mutex outside the for loop --- src/grib_dumper_factory.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/grib_dumper_factory.cc b/src/grib_dumper_factory.cc index eb0a33595..ab1b9cf83 100644 --- a/src/grib_dumper_factory.cc +++ b/src/grib_dumper_factory.cc @@ -160,15 +160,15 @@ void grib_dump_keys(grib_handle* h, FILE* f, const char* mode, unsigned long fla eccodes::Dumper* dumper = grib_dumper_factory(mode ? mode : "serialize", h, f, flags, data); if (!dumper) return; + GRIB_MUTEX_INIT_ONCE(&once, &init_mutex); + GRIB_MUTEX_LOCK(&mutex); for (size_t i = 0; i < num_keys; ++i) { acc = grib_find_accessor(h, keys[i]); if (acc) { - GRIB_MUTEX_INIT_ONCE(&once, &init_mutex); - GRIB_MUTEX_LOCK(&mutex); acc->dump(dumper); - GRIB_MUTEX_UNLOCK(&mutex); } } + GRIB_MUTEX_UNLOCK(&mutex); dumper->destroy(); }