This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch NewAPIMetricsPOC
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/NewAPIMetricsPOC by this push:
new 36be46df0b Small cleanup on lock
36be46df0b is described below
commit 36be46df0be91096c9c0a0e96753121f9557ad7e
Author: Leif Hedstrom <[email protected]>
AuthorDate: Thu Jul 6 22:58:08 2023 -0600
Small cleanup on lock
---
src/api/Metrics.cc | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/api/Metrics.cc b/src/api/Metrics.cc
index d9bb0981c6..7135ba94f8 100644
--- a/src/api/Metrics.cc
+++ b/src/api/Metrics.cc
@@ -108,16 +108,13 @@ Metrics::lookup(IdType id) const
void
Metrics::recordsDump(RecDumpEntryCb callback, void *edata)
{
- int16_t blob_ix, off_ix;
int16_t off_max = METRICS_MAX_SIZE;
- {
- std::lock_guard<std::mutex> lock(_mutex);
-
- // Capture these while protected, in case the blobs change
- blob_ix = _cur_blob;
- off_ix = _cur_off;
- }
+ // Capture these under the lock guard
+ _mutex.lock();
+ int16_t blob_ix = _cur_blob;
+ int16_t off_ix = _cur_off;
+ _mutex.unlock();
for (int i = 0; i <= blob_ix; ++i) {
auto blob = _blobs[i];
@@ -130,7 +127,6 @@ Metrics::recordsDump(RecDumpEntryCb callback, void *edata)
}
for (int j = 0; j < off_max; ++j) {
datum.rec_int = metrics[j].load();
- // ToDo: The recordtype here is fine for now, but we should probably
make this generic
callback(RECT_PLUGIN, edata, 1, std::get<0>(names[j]).c_str(),
TS_RECORDDATATYPE_INT, &datum);
}
}