You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/04/20 20:43:07 UTC

[trafficserver] branch 9.0.x updated: Update TSStatFindName to check that sync callback is set on the stat

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new c807986  Update TSStatFindName to check that sync callback is set on the stat
c807986 is described below

commit c807986dbada4edc6316da208677efc90584b12f
Author: Sudheer Vinukonda <su...@apache.org>
AuthorDate: Tue Apr 14 16:20:10 2020 -0700

    Update TSStatFindName to check that sync callback is set on the stat
    
    (cherry picked from commit 0b31904a728a1606757be3779af5205fe9f3897c)
---
 lib/records/I_RecCore.h      |  2 +-
 lib/records/RecCore.cc       | 20 +++++++++++---------
 src/traffic_server/InkAPI.cc |  2 +-
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 6a0e3b2..061ebb8 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -166,7 +166,7 @@ RecErrT RecLookupMatchingRecords(unsigned rec_type, const char *match, RecLookup
 RecErrT RecGetRecordType(const char *name, RecT *rec_type, bool lock = true);
 RecErrT RecGetRecordDataType(const char *name, RecDataT *data_type, bool lock = true);
 RecErrT RecGetRecordPersistenceType(const char *name, RecPersistT *persist_type, bool lock = true);
-RecErrT RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock = true);
+RecErrT RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock = true, bool check_sync_cb = false);
 RecErrT RecGetRecordUpdateType(const char *name, RecUpdateT *update_type, bool lock = true);
 RecErrT RecGetRecordCheckType(const char *name, RecCheckT *check_type, bool lock = true);
 RecErrT RecGetRecordCheckExpr(const char *name, char **check_expr, bool lock = true);
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 75b481d..8ab0683 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -607,7 +607,7 @@ RecGetRecordPersistenceType(const char *name, RecPersistT *persist_type, bool lo
 }
 
 RecErrT
-RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock)
+RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock, bool check_sync_cb)
 {
   RecErrT err = REC_ERR_FAIL;
 
@@ -619,15 +619,17 @@ RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock)
     RecRecord *r = it->second;
 
     if (r->registered) {
-      rec_mutex_acquire(&(r->lock));
-      if (order) {
-        *order = r->order;
-      }
-      if (id) {
-        *id = r->rsb_id;
+      if (!check_sync_cb || r->stat_meta.sync_cb) {
+        rec_mutex_acquire(&(r->lock));
+        if (order) {
+          *order = r->order;
+        }
+        if (id) {
+          *id = r->rsb_id;
+        }
+        err = REC_ERR_OKAY;
+        rec_mutex_release(&(r->lock));
       }
-      err = REC_ERR_OKAY;
-      rec_mutex_release(&(r->lock));
     }
   }
 
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index 75810a2..6c3069e 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -7450,7 +7450,7 @@ TSStatFindName(const char *name, int *idp)
 
   sdk_assert(sdk_sanity_check_null_ptr((void *)name) == TS_SUCCESS);
 
-  if (RecGetRecordOrderAndId(name, nullptr, &id) != REC_ERR_OKAY) {
+  if (RecGetRecordOrderAndId(name, nullptr, &id, true, true) != REC_ERR_OKAY) {
     return TS_ERROR;
   }