Skip to content

Commit

Permalink
Move mutex outside the for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
joobog committed Jan 14, 2025
1 parent 5bbdaf8 commit 77268fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/grib_dumper_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 77268fe

Please sign in to comment.