MCPcopy Create free account
hub / github.com/apache/trafficserver / RecRegisterStat

Function RecRegisterStat

src/records/RecCore.cc:709–734  ·  view source on GitHub ↗

------------------------------------------------------------------------- RecRegisterStat -------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

707// RecRegisterStat
708//-------------------------------------------------------------------------
709RecRecord *
710RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, RecPersistT persist_type)
711{
712 RecRecord *r = nullptr;
713
714 ink_rwlock_wrlock(&g_records_rwlock);
715 if ((r = register_record(rec_type, name, data_type, data_default, persist_type)) != nullptr) {
716 // If the persistence type we found in the records hash is not the same as the persistence
717 // type we are registering, then that means that it changed between the previous software
718 // version and the current version. If the metric changed to non-persistent, reset to the
719 // new default value.
720 if ((r->stat_meta.persist_type == RECP_NULL || r->stat_meta.persist_type == RECP_PERSISTENT) &&
721 persist_type == RECP_NON_PERSISTENT) {
722 RecDebug(DL_Debug, "resetting default value for formerly persisted stat '%s'", r->name);
723 RecDataSet(r->data_type, &(r->data), &(data_default));
724 }
725
726 r->stat_meta.persist_type = persist_type;
727 } else {
728 ink_assert(!"Can't register record!");
729 RecDebug(DL_Warning, "failed to register '%s' record", name);
730 }
731 ink_rwlock_unlock(&g_records_rwlock);
732
733 return r;
734}
735
736//-------------------------------------------------------------------------
737// RecRegisterConfig

Callers 1

_RecRegisterRawStatFunction · 0.85

Calls 4

ink_rwlock_wrlockFunction · 0.85
register_recordFunction · 0.85
RecDataSetFunction · 0.85
ink_rwlock_unlockFunction · 0.85

Tested by

no test coverage detected