From 1becc9e34e8bf6f666224ae2d6f4b10eef9f6b2f Mon Sep 17 00:00:00 2001 From: Edward Hartnett <38856240+edwardhartnett@users.noreply.github.com> Date: Wed, 25 Dec 2024 10:08:28 -0700 Subject: [PATCH] fixed threading problem in g2c_inq_dim() (#573) --- src/g2cinq.c | 3 +++ tests/tst_inq.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/g2cinq.c b/src/g2cinq.c index 0a959551..0a172b7d 100644 --- a/src/g2cinq.c +++ b/src/g2cinq.c @@ -377,5 +377,8 @@ g2c_inq_dim(int g2cid, int msg_num, int prod_num, int dim_num, size_t *len, for (d = 0; d < dim->len; d++) val[d] = dim->value[d]; + /* If using threading, unlock the mutex. */ + MUTEX_UNLOCK(m); + return ret; } diff --git a/tests/tst_inq.c b/tests/tst_inq.c index 51cec899..c53a2ec9 100644 --- a/tests/tst_inq.c +++ b/tests/tst_inq.c @@ -150,6 +150,8 @@ main() short year; short center, subcenter; unsigned char master_version, local_version; + size_t dimlen; + char dimname[G2C_MAX_NAME]; int p; printf("\t\tinquiring about message %d...\n", m); @@ -202,6 +204,12 @@ main() if (drs_template[p] != expected_drs_template[m][p]) return G2C_ERROR; } + + if ((ret = g2c_inq_dim(g2cid, m, 0, 0, &dimlen, dimname, NULL))) + return ret; + /* printf("dimlen = %ld, dimname = %s\n", dimlen, dimname); */ + if (dimlen != 151 || strcmp(dimname, "Latitude")) + return G2C_ERROR; } /* Close the file. */