From 750043461ecb1a0eaa7d29c406306bab9072f76c Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Wed, 8 Mar 2023 14:23:19 -0600 Subject: [PATCH 1/7] refactor src/records to remove dependency on iocore/eventsystem --- include/records/I_RecDefs.h | 14 + include/records/I_RecProcess.h | 16 +- iocore/eventsystem/CMakeLists.txt | 5 +- iocore/eventsystem/EventSystem.cc | 5 + iocore/eventsystem/RecRawStatsImpl.cc | 256 ++++++++++++++++++ src/records/CMakeLists.txt | 29 +- src/records/Makefile.am | 6 +- src/records/RecCore.cc | 24 ++ src/records/RecRawStats.cc | 232 ++-------------- src/traffic_server/CMakeLists.txt | 3 +- src/{records => traffic_server}/RecProcess.cc | 45 --- src/traffic_server/RecProcess.h | 43 +++ src/traffic_server/traffic_server.cc | 3 +- src/tscore/CMakeLists.txt | 2 +- 14 files changed, 372 insertions(+), 311 deletions(-) create mode 100644 iocore/eventsystem/RecRawStatsImpl.cc rename src/{records => traffic_server}/RecProcess.cc (86%) create mode 100644 src/traffic_server/RecProcess.h diff --git a/include/records/I_RecDefs.h b/include/records/I_RecDefs.h index 5362e5e00f6..9859bfb74cf 100644 --- a/include/records/I_RecDefs.h +++ b/include/records/I_RecDefs.h @@ -151,6 +151,19 @@ struct RecRawStat { uint32_t version; }; +struct RecRawStatBlock; + +// This defines the interface to the low level stat block operations +// The implementation of this was moved out of the records library due to a circular dependency this produced. +// look for the implmenetation of RecRawStatBlockOps in iocore/eventsystem +struct RecRawStatBlockOps { + virtual int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_clear_count(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) = 0; + virtual int raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_clear(RecRawStatBlock *rsb, int id) = 0; +}; + // WARNING! It's advised that developers do not modify the contents of // the RecRawStatBlock. ^_^ struct RecRawStatBlock { @@ -159,6 +172,7 @@ struct RecRawStatBlock { int num_stats; // number of stats in this block int max_stats; // maximum number of stats for this block ink_mutex mutex; + RecRawStatBlockOps* ops; }; //------------------------------------------------------------------------- diff --git a/include/records/I_RecProcess.h b/include/records/I_RecProcess.h index 1d510b12fb8..509412e7bc3 100644 --- a/include/records/I_RecProcess.h +++ b/include/records/I_RecProcess.h @@ -27,22 +27,12 @@ #include "I_EventSystem.h" //------------------------------------------------------------------------- -// Initialization/Starting +// RawStat Registration //------------------------------------------------------------------------- -int RecProcessInit(Diags *diags = nullptr); -int RecProcessInitMessage(); -int RecProcessStart(); -//------------------------------------------------------------------------- -// Setters for manipulating internal sleep intervals -//------------------------------------------------------------------------- -void RecProcess_set_raw_stat_sync_interval_ms(int ms); -void RecProcess_set_config_update_interval_ms(int ms); -void RecProcess_set_remote_sync_interval_ms(int ms); +using RecRawStatBlockAllocator = RecRawStatBlock* (*)(int num_stats); -//------------------------------------------------------------------------- -// RawStat Registration -//------------------------------------------------------------------------- +void SetRecAllocateRawStatBlockAllocator(RecRawStatBlockAllocator); RecRawStatBlock *RecAllocateRawStatBlock(int num_stats); int _RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id, diff --git a/iocore/eventsystem/CMakeLists.txt b/iocore/eventsystem/CMakeLists.txt index 14615544445..c9dd0550006 100644 --- a/iocore/eventsystem/CMakeLists.txt +++ b/iocore/eventsystem/CMakeLists.txt @@ -33,5 +33,6 @@ add_library(inkevent SHARED UnixEvent.cc UnixEventProcessor.cc ConfigProcessor.cc -) -target_include_directories(inkevent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file + RecRawStatsImpl.cc) +target_include_directories(inkevent PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(inkevent ${PCRE_LIBRARIES} ${OPENSSL_LIBRARIES} yaml-cpp::yaml-cpp tscpputil resolv libswoc tscore records_p) \ No newline at end of file diff --git a/iocore/eventsystem/EventSystem.cc b/iocore/eventsystem/EventSystem.cc index cf3c989197e..21e70dd4910 100644 --- a/iocore/eventsystem/EventSystem.cc +++ b/iocore/eventsystem/EventSystem.cc @@ -31,12 +31,17 @@ #include "P_EventSystem.h" #include "tscore/hugepages.h" +void +SetupRecRawStatBlockAllocator(); + void ink_event_system_init(ts::ModuleVersion v) { ink_release_assert(v.check(EVENT_SYSTEM_MODULE_INTERNAL_VERSION)); int iobuffer_advice = 0; + SetupRecRawStatBlockAllocator(); + // For backwards compatibility make sure to allow thread_freelist_size // This needs to change in 6.0 REC_EstablishStaticConfigInt32(thread_freelist_high_watermark, "proxy.config.allocator.thread_freelist_size"); diff --git a/iocore/eventsystem/RecRawStatsImpl.cc b/iocore/eventsystem/RecRawStatsImpl.cc new file mode 100644 index 00000000000..717459805db --- /dev/null +++ b/iocore/eventsystem/RecRawStatsImpl.cc @@ -0,0 +1,256 @@ +/** @file + +Record statistics support (EThread implementation). + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include "records/I_RecDefs.h" +#include "records/P_RecCore.h" +#include "records/P_RecProcess.h" +#include + +//------------------------------------------------------------------------- +// raw_stat_get_total +//------------------------------------------------------------------------- + +struct RecRawStatBlockOpsImpl : RecRawStatBlockOps +{ + int raw_stat_clear(RecRawStatBlock *rsb, int id) override; + int raw_stat_clear_count(RecRawStatBlock *rsb, int id) override; + int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) override; + int raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) override; + int raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) override; +}; + +RecRawStatBlock* +RecAllocateRawStatBlockImpl(int num_stats) +{ + static RecRawStatBlockOpsImpl ops; + + off_t ethr_stat_offset; + RecRawStatBlock *rsb; + + // allocate thread-local raw-stat memory + if ((ethr_stat_offset = eventProcessor.allocate(num_stats * sizeof(RecRawStat))) == -1) { + return nullptr; + } + + // create the raw-stat-block structure + rsb = static_cast(ats_malloc(sizeof(RecRawStatBlock))); + memset(rsb, 0, sizeof(RecRawStatBlock)); + + rsb->global = static_cast(ats_malloc(num_stats * sizeof(RecRawStat *))); + memset(rsb->global, 0, num_stats * sizeof(RecRawStat *)); + + rsb->num_stats = 0; + rsb->max_stats = num_stats; + rsb->ethr_stat_offset = ethr_stat_offset; + + ink_mutex_init(&(rsb->mutex)); + + rsb->ops = &ops; + return rsb; +} + +void +SetupRecRawStatBlockAllocator() +{ + SetRecAllocateRawStatBlockAllocator(RecAllocateRawStatBlockImpl); +} + +// Commonly used access to a raw stat, avoid typos. +static RecRawStat * +thread_stat(EThread *et, RecRawStatBlock *rsb, int id) +{ + return (reinterpret_cast(reinterpret_cast(et) + rsb->ethr_stat_offset)) + id; +} + +int +RecRawStatBlockOpsImpl::raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) +{ + total->sum = 0; + total->count = 0; + + // get global values + total->sum = rsb->global[id]->sum; + total->count = rsb->global[id]->count; + + // get thread local values + for (EThread *et : eventProcessor.active_ethreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + total->sum += tlp->sum; + total->count += tlp->count; + } + + for (EThread *et : eventProcessor.active_dthreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + total->sum += tlp->sum; + total->count += tlp->count; + } + + if (total->sum < 0) { // Assure that we stay positive + total->sum = 0; + } + + return REC_ERR_OKAY; +} + +//------------------------------------------------------------------------- +// raw_stat_sync_to_global +//------------------------------------------------------------------------- +int +RecRawStatBlockOpsImpl::raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) +{ + RecRawStat total; + + total.sum = 0; + total.count = 0; + + // sum the thread local values + for (EThread *et : eventProcessor.active_ethreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + total.sum += tlp->sum; + total.count += tlp->count; + } + + for (EThread *et : eventProcessor.active_dthreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + total.sum += tlp->sum; + total.count += tlp->count; + } + + if (total.sum < 0) { // Assure that we stay positive + total.sum = 0; + } + + // lock so the setting of the globals and last values are atomic + { + ink_scoped_mutex_lock lock(rsb->mutex); + + // get the delta from the last sync + RecRawStat delta; + delta.sum = total.sum - rsb->global[id]->last_sum; + delta.count = total.count - rsb->global[id]->last_count; + + // increment the global values by the delta + ink_atomic_increment(&(rsb->global[id]->sum), delta.sum); + ink_atomic_increment(&(rsb->global[id]->count), delta.count); + + // set the new totals as the last values seen + ink_atomic_swap(&(rsb->global[id]->last_sum), total.sum); + ink_atomic_swap(&(rsb->global[id]->last_count), total.count); + } + + return REC_ERR_OKAY; +} + +//------------------------------------------------------------------------- +// raw_stat_clear +//------------------------------------------------------------------------- +int +RecRawStatBlockOpsImpl::raw_stat_clear(RecRawStatBlock *rsb, int id) +{ + Debug("stats", "raw_stat_clear(): rsb pointer:%p id:%d", rsb, id); + + // the globals need to be reset too + // lock so the setting of the globals and last values are atomic + { + ink_scoped_mutex_lock lock(rsb->mutex); + ink_atomic_swap(&(rsb->global[id]->sum), static_cast(0)); + ink_atomic_swap(&(rsb->global[id]->last_sum), static_cast(0)); + ink_atomic_swap(&(rsb->global[id]->count), static_cast(0)); + ink_atomic_swap(&(rsb->global[id]->last_count), static_cast(0)); + } + // reset the local stats + for (EThread *et : eventProcessor.active_ethreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + ink_atomic_swap(&(tlp->sum), static_cast(0)); + ink_atomic_swap(&(tlp->count), static_cast(0)); + } + + for (EThread *et : eventProcessor.active_dthreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + ink_atomic_swap(&(tlp->sum), static_cast(0)); + ink_atomic_swap(&(tlp->count), static_cast(0)); + } + + return REC_ERR_OKAY; +} + +//------------------------------------------------------------------------- +// raw_stat_clear_sum +//------------------------------------------------------------------------- +int +RecRawStatBlockOpsImpl::raw_stat_clear_sum(RecRawStatBlock *rsb, int id) +{ + Debug("stats", "raw_stat_clear_sum(): rsb pointer:%p id:%d", rsb, id); + + // the globals need to be reset too + // lock so the setting of the globals and last values are atomic + { + ink_scoped_mutex_lock lock(rsb->mutex); + ink_atomic_swap(&(rsb->global[id]->sum), static_cast(0)); + ink_atomic_swap(&(rsb->global[id]->last_sum), static_cast(0)); + } + + // reset the local stats + for (EThread *et : eventProcessor.active_ethreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + ink_atomic_swap(&(tlp->sum), static_cast(0)); + } + + for (EThread *et : eventProcessor.active_dthreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + ink_atomic_swap(&(tlp->sum), static_cast(0)); + } + + return REC_ERR_OKAY; +} + +//------------------------------------------------------------------------- +// raw_stat_clear_count +//------------------------------------------------------------------------- +int +RecRawStatBlockOpsImpl::raw_stat_clear_count(RecRawStatBlock *rsb, int id) +{ + Debug("stats", "raw_stat_clear_count(): rsb pointer:%p id:%d", rsb, id); + + // the globals need to be reset too + // lock so the setting of the globals and last values are atomic + { + ink_scoped_mutex_lock lock(rsb->mutex); + ink_atomic_swap(&(rsb->global[id]->count), static_cast(0)); + ink_atomic_swap(&(rsb->global[id]->last_count), static_cast(0)); + } + + // reset the local stats + for (EThread *et : eventProcessor.active_ethreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + ink_atomic_swap(&(tlp->count), static_cast(0)); + } + + for (EThread *et : eventProcessor.active_dthreads()) { + RecRawStat *tlp = thread_stat(et, rsb, id); + ink_atomic_swap(&(tlp->count), static_cast(0)); + } + + return REC_ERR_OKAY; +} + diff --git a/src/records/CMakeLists.txt b/src/records/CMakeLists.txt index 20897ed6ada..c3a9953fb32 100644 --- a/src/records/CMakeLists.txt +++ b/src/records/CMakeLists.txt @@ -15,8 +15,7 @@ # ####################### - -add_library(records_lm STATIC +add_library(records_p SHARED P_RecCore.cc RecConfigParse.cc RecCore.cc @@ -25,36 +24,13 @@ add_library(records_lm STATIC RecHttp.cc RecMessage.cc RecMutex.cc - RecRawStats.cc RecUtils.cc RecYAMLDecoder.cc RecordsConfig.cc RecordsConfigUtils.cc -) -target_include_directories(records_lm PRIVATE - ${CMAKE_SOURCE_DIR}/mgmt - ${CMAKE_SOURCE_DIR}/mgmt/api/include - ${CMAKE_SOURCE_DIR}/mgmt/utils - ${CMAKE_SOURCE_DIR}/iocore/eventsystem - ${CMAKE_SOURCE_DIR}/iocore/utils -) - -add_library(records_p STATIC - P_RecCore.cc - RecConfigParse.cc - RecCore.cc - RecDebug.cc - RecFile.cc - RecHttp.cc - RecMessage.cc - RecMutex.cc RecRawStats.cc - RecUtils.cc - RecProcess.cc - RecYAMLDecoder.cc - RecordsConfig.cc - RecordsConfigUtils.cc ) + target_include_directories(records_p PRIVATE ${CMAKE_SOURCE_DIR}/mgmt ${CMAKE_SOURCE_DIR}/mgmt/api/include @@ -62,3 +38,4 @@ target_include_directories(records_p PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/utils ) +target_link_libraries(records_p tscore libswoc) \ No newline at end of file diff --git a/src/records/Makefile.am b/src/records/Makefile.am index 2bdb5e0527d..15c64dce4fb 100644 --- a/src/records/Makefile.am +++ b/src/records/Makefile.am @@ -56,11 +56,7 @@ librecords_COMMON = \ RecordsConfig.cc \ RecordsConfigUtils.cc -librecords_p_a_SOURCES = \ - $(librecords_COMMON) \ - I_RecProcess.h \ - P_RecProcess.h \ - RecProcess.cc +librecords_p_a_SOURCES = $(librecords_COMMON) TESTS = $(check_PROGRAMS) diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index 7f9212ed883..ae1803d9a01 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -1294,3 +1294,27 @@ RecConfigWarnIfUnregistered() }, nullptr); } + +//------------------------------------------------------------------------- +// i_am_the_record_owner, only used for librecords_p.a +//------------------------------------------------------------------------- +bool +i_am_the_record_owner(RecT rec_type) +{ + if (g_mode_type == RECM_STAND_ALONE) { + switch (rec_type) { + case RECT_CONFIG: + case RECT_PROCESS: + case RECT_NODE: + case RECT_LOCAL: + case RECT_PLUGIN: + return true; + default: + ink_assert(!"Unexpected RecT type"); + return false; + } + } + + return false; +} + diff --git a/src/records/RecRawStats.cc b/src/records/RecRawStats.cc index 1760a0a746b..fe8bb590a9b 100644 --- a/src/records/RecRawStats.cc +++ b/src/records/RecRawStats.cc @@ -1,6 +1,6 @@ /** @file - Record statistics support. +Record statistics support @section license License @@ -26,218 +26,18 @@ #include //------------------------------------------------------------------------- -// raw_stat_get_total -//------------------------------------------------------------------------- - -namespace -{ -// Commonly used access to a raw stat, avoid typos. -inline RecRawStat * -thread_stat(EThread *et, RecRawStatBlock *rsb, int id) -{ - return (reinterpret_cast(reinterpret_cast(et) + rsb->ethr_stat_offset)) + id; -} -} // namespace - -static int -raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) -{ - total->sum = 0; - total->count = 0; - - // get global values - total->sum = rsb->global[id]->sum; - total->count = rsb->global[id]->count; - - // get thread local values - for (EThread *et : eventProcessor.active_ethreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - total->sum += tlp->sum; - total->count += tlp->count; - } - - for (EThread *et : eventProcessor.active_dthreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - total->sum += tlp->sum; - total->count += tlp->count; - } - - if (total->sum < 0) { // Assure that we stay positive - total->sum = 0; - } - - return REC_ERR_OKAY; -} - -//------------------------------------------------------------------------- -// raw_stat_sync_to_global -//------------------------------------------------------------------------- -static int -raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) -{ - RecRawStat total; - - total.sum = 0; - total.count = 0; - - // sum the thread local values - for (EThread *et : eventProcessor.active_ethreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - total.sum += tlp->sum; - total.count += tlp->count; - } - - for (EThread *et : eventProcessor.active_dthreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - total.sum += tlp->sum; - total.count += tlp->count; - } - - if (total.sum < 0) { // Assure that we stay positive - total.sum = 0; - } - - // lock so the setting of the globals and last values are atomic - { - ink_scoped_mutex_lock lock(rsb->mutex); - - // get the delta from the last sync - RecRawStat delta; - delta.sum = total.sum - rsb->global[id]->last_sum; - delta.count = total.count - rsb->global[id]->last_count; - - // increment the global values by the delta - ink_atomic_increment(&(rsb->global[id]->sum), delta.sum); - ink_atomic_increment(&(rsb->global[id]->count), delta.count); - - // set the new totals as the last values seen - ink_atomic_swap(&(rsb->global[id]->last_sum), total.sum); - ink_atomic_swap(&(rsb->global[id]->last_count), total.count); - } - - return REC_ERR_OKAY; -} - -//------------------------------------------------------------------------- -// raw_stat_clear -//------------------------------------------------------------------------- -static int -raw_stat_clear(RecRawStatBlock *rsb, int id) -{ - Debug("stats", "raw_stat_clear(): rsb pointer:%p id:%d", rsb, id); - - // the globals need to be reset too - // lock so the setting of the globals and last values are atomic - { - ink_scoped_mutex_lock lock(rsb->mutex); - ink_atomic_swap(&(rsb->global[id]->sum), static_cast(0)); - ink_atomic_swap(&(rsb->global[id]->last_sum), static_cast(0)); - ink_atomic_swap(&(rsb->global[id]->count), static_cast(0)); - ink_atomic_swap(&(rsb->global[id]->last_count), static_cast(0)); - } - // reset the local stats - for (EThread *et : eventProcessor.active_ethreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - ink_atomic_swap(&(tlp->sum), static_cast(0)); - ink_atomic_swap(&(tlp->count), static_cast(0)); - } - - for (EThread *et : eventProcessor.active_dthreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - ink_atomic_swap(&(tlp->sum), static_cast(0)); - ink_atomic_swap(&(tlp->count), static_cast(0)); - } - - return REC_ERR_OKAY; -} - -//------------------------------------------------------------------------- -// raw_stat_clear_sum -//------------------------------------------------------------------------- -static int -raw_stat_clear_sum(RecRawStatBlock *rsb, int id) -{ - Debug("stats", "raw_stat_clear_sum(): rsb pointer:%p id:%d", rsb, id); - - // the globals need to be reset too - // lock so the setting of the globals and last values are atomic - { - ink_scoped_mutex_lock lock(rsb->mutex); - ink_atomic_swap(&(rsb->global[id]->sum), static_cast(0)); - ink_atomic_swap(&(rsb->global[id]->last_sum), static_cast(0)); - } - - // reset the local stats - for (EThread *et : eventProcessor.active_ethreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - ink_atomic_swap(&(tlp->sum), static_cast(0)); - } - - for (EThread *et : eventProcessor.active_dthreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - ink_atomic_swap(&(tlp->sum), static_cast(0)); - } - - return REC_ERR_OKAY; -} - -//------------------------------------------------------------------------- -// raw_stat_clear_count +// RecAllocateRawStatBlock //------------------------------------------------------------------------- -static int -raw_stat_clear_count(RecRawStatBlock *rsb, int id) +static RecRawStatBlockAllocator raw_stat_block_allocator = nullptr; +void SetRecAllocateRawStatBlockAllocator(RecRawStatBlockAllocator f) { - Debug("stats", "raw_stat_clear_count(): rsb pointer:%p id:%d", rsb, id); - - // the globals need to be reset too - // lock so the setting of the globals and last values are atomic - { - ink_scoped_mutex_lock lock(rsb->mutex); - ink_atomic_swap(&(rsb->global[id]->count), static_cast(0)); - ink_atomic_swap(&(rsb->global[id]->last_count), static_cast(0)); - } - - // reset the local stats - for (EThread *et : eventProcessor.active_ethreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - ink_atomic_swap(&(tlp->count), static_cast(0)); - } - - for (EThread *et : eventProcessor.active_dthreads()) { - RecRawStat *tlp = thread_stat(et, rsb, id); - ink_atomic_swap(&(tlp->count), static_cast(0)); - } - - return REC_ERR_OKAY; + raw_stat_block_allocator = f; } -//------------------------------------------------------------------------- -// RecAllocateRawStatBlock -//------------------------------------------------------------------------- RecRawStatBlock * RecAllocateRawStatBlock(int num_stats) { - off_t ethr_stat_offset; - RecRawStatBlock *rsb; - - // allocate thread-local raw-stat memory - if ((ethr_stat_offset = eventProcessor.allocate(num_stats * sizeof(RecRawStat))) == -1) { - return nullptr; - } - - // create the raw-stat-block structure - rsb = static_cast(ats_malloc(sizeof(RecRawStatBlock))); - memset(rsb, 0, sizeof(RecRawStatBlock)); - - rsb->global = static_cast(ats_malloc(num_stats * sizeof(RecRawStat *))); - memset(rsb->global, 0, num_stats * sizeof(RecRawStat *)); - - rsb->num_stats = 0; - rsb->max_stats = num_stats; - rsb->ethr_stat_offset = ethr_stat_offset; - - ink_mutex_init(&(rsb->mutex)); - return rsb; + return raw_stat_block_allocator(num_stats); } //------------------------------------------------------------------------- @@ -295,7 +95,7 @@ RecRawStatSyncSum(const char *name, RecDataT data_type, RecData *data, RecRawSta RecRawStat total; Debug("stats", "raw sync:sum for %s", name); - raw_stat_sync_to_global(rsb, id); + rsb->ops->raw_stat_sync_to_global(rsb, id); total.sum = rsb->global[id]->sum; total.count = rsb->global[id]->count; RecDataSetFromInt64(data_type, data, total.sum); @@ -309,7 +109,7 @@ RecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawS RecRawStat total; Debug("stats", "raw sync:count for %s", name); - raw_stat_sync_to_global(rsb, id); + rsb->ops->raw_stat_sync_to_global(rsb, id); total.sum = rsb->global[id]->sum; total.count = rsb->global[id]->count; RecDataSetFromInt64(data_type, data, total.count); @@ -324,7 +124,7 @@ RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawSta RecFloat avg = 0.0f; Debug("stats", "raw sync:avg for %s", name); - raw_stat_sync_to_global(rsb, id); + rsb->ops->raw_stat_sync_to_global(rsb, id); total.sum = rsb->global[id]->sum; total.count = rsb->global[id]->count; if (total.count != 0) { @@ -341,7 +141,7 @@ RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, Rec RecFloat r; Debug("stats", "raw sync:hr-timeavg for %s", name); - raw_stat_sync_to_global(rsb, id); + rsb->ops->raw_stat_sync_to_global(rsb, id); total.sum = rsb->global[id]->sum; total.count = rsb->global[id]->count; @@ -363,7 +163,7 @@ RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecDa RecFloat r; Debug("stats", "raw sync:seconds for %s", name); - raw_stat_sync_to_global(rsb, id); + rsb->ops->raw_stat_sync_to_global(rsb, id); total.sum = rsb->global[id]->sum; total.count = rsb->global[id]->count; @@ -383,7 +183,7 @@ RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecDa int RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64_t data) { - raw_stat_clear_sum(rsb, id); + rsb->ops->raw_stat_clear_sum(rsb, id); ink_atomic_swap(&(rsb->global[id]->sum), data); return REC_ERR_OKAY; } @@ -391,7 +191,7 @@ RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64_t data) int RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64_t data) { - raw_stat_clear_count(rsb, id); + rsb->ops->raw_stat_clear_count(rsb, id); ink_atomic_swap(&(rsb->global[id]->count), data); return REC_ERR_OKAY; } @@ -405,7 +205,7 @@ RecGetRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data) { RecRawStat total; - raw_stat_get_total(rsb, id, &total); + rsb->ops->raw_stat_get_total(rsb, id, &total); *data = total.sum; return REC_ERR_OKAY; } @@ -415,7 +215,7 @@ RecGetRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data) { RecRawStat total; - raw_stat_get_total(rsb, id, &total); + rsb->ops->raw_stat_get_total(rsb, id, &total); *data = total.count; return REC_ERR_OKAY; } @@ -555,7 +355,7 @@ RecExecRawStatSyncCbs() if (REC_TYPE_IS_STAT(r->rec_type)) { if (r->stat_meta.sync_cb) { if (r->version && r->version != r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version) { - raw_stat_clear(r->stat_meta.sync_rsb, r->stat_meta.sync_id); + r->stat_meta.sync_rsb->ops->raw_stat_clear(r->stat_meta.sync_rsb, r->stat_meta.sync_id); r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version = r->version; } else { (*(r->stat_meta.sync_cb))(r->name, r->data_type, &(r->data), r->stat_meta.sync_rsb, r->stat_meta.sync_id); diff --git a/src/traffic_server/CMakeLists.txt b/src/traffic_server/CMakeLists.txt index 97955731cbf..89f426904a3 100644 --- a/src/traffic_server/CMakeLists.txt +++ b/src/traffic_server/CMakeLists.txt @@ -25,8 +25,9 @@ add_executable(traffic_server SocksProxy.cc traffic_server.cc RpcAdminPubHandlers.cc + RecProcess.cc ${CMAKE_SOURCE_DIR}/src/shared/overridable_txn_vars.cc -) + RecProcess.h) target_include_directories(traffic_server PRIVATE ${IOCORE_INCLUDE_DIRS} ${PROXY_INCLUDE_DIRS} diff --git a/src/records/RecProcess.cc b/src/traffic_server/RecProcess.cc similarity index 86% rename from src/records/RecProcess.cc rename to src/traffic_server/RecProcess.cc index 884120a817b..a9d4185dcbf 100644 --- a/src/records/RecProcess.cc +++ b/src/traffic_server/RecProcess.cc @@ -34,7 +34,6 @@ #include "records/P_RecFile.h" // Marks whether the message handler has been initialized. -static bool message_initialized_p = false; static bool g_started = false; static EventNotify g_force_req_notify; static int g_rec_raw_stat_sync_interval_ms = REC_RAW_STAT_SYNC_INTERVAL_MS; @@ -44,27 +43,6 @@ static Event *raw_stat_sync_cont_event; static Event *config_update_cont_event; static Event *sync_cont_event; -//------------------------------------------------------------------------- -// i_am_the_record_owner, only used for librecords_p.a -//------------------------------------------------------------------------- -bool -i_am_the_record_owner(RecT rec_type) -{ - switch (rec_type) { - case RECT_CONFIG: - case RECT_PROCESS: - case RECT_NODE: - case RECT_LOCAL: - case RECT_PLUGIN: - return true; - default: - ink_assert(!"Unexpected RecT type"); - return false; - } - - return false; -} - //------------------------------------------------------------------------- // Simple setters for the intervals to decouple this from the proxy //------------------------------------------------------------------------- @@ -181,29 +159,6 @@ RecProcessInit(Diags *_diags) return REC_ERR_OKAY; } -void -RecMessageInit() -{ - message_initialized_p = true; -} -//------------------------------------------------------------------------- -// RecProcessInitMessage -//------------------------------------------------------------------------- -int -RecProcessInitMessage() -{ - static bool initialized_p = false; - - if (initialized_p) { - return REC_ERR_OKAY; - } - - RecMessageInit(); - initialized_p = true; - - return REC_ERR_OKAY; -} - //------------------------------------------------------------------------- // RecProcessStart //------------------------------------------------------------------------- diff --git a/src/traffic_server/RecProcess.h b/src/traffic_server/RecProcess.h new file mode 100644 index 00000000000..e6bd53eb100 --- /dev/null +++ b/src/traffic_server/RecProcess.h @@ -0,0 +1,43 @@ +/** @file + +Public RecProcess declarations + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#pragma once + + +#include "records/I_RecDefs.h" +#include "tscore/Diags.h" + + +//------------------------------------------------------------------------- +// Initialization/Starting +//------------------------------------------------------------------------- +int RecProcessInit(RecModeT mode_type, Diags *diags = nullptr); +int RecProcessStart(); + +//------------------------------------------------------------------------- +// Setters for manipulating internal sleep intervals +//------------------------------------------------------------------------- +void RecProcess_set_raw_stat_sync_interval_ms(int ms); +void RecProcess_set_config_update_interval_ms(int ms); +void RecProcess_set_remote_sync_interval_ms(int ms); + diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index 46acf960cbb..c728a67bae0 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -77,7 +77,7 @@ extern "C" int plock(int); #include "tscore/I_Layout.h" #include "I_Machine.h" #include "records/I_RecordsConfig.h" -#include "records/I_RecProcess.h" +#include "RecProcess.h" #include "Transform.h" #include "ConfigProcessor.h" #include "HttpProxyServerMain.h" @@ -672,7 +672,6 @@ initialize_process_manager() RecProcessInit(diags()); LibRecordsConfigInit(); - RecProcessInitMessage(); check_config_directories(); // diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt index 8ab2f393f6b..8a288ed1469 100644 --- a/src/tscore/CMakeLists.txt +++ b/src/tscore/CMakeLists.txt @@ -109,7 +109,7 @@ target_include_directories(tscore PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${YAML_INCLUDE_DIRS} ) -target_link_libraries(tscore ${PCRE_LIBRARIES} ${OPENSSL_LIBRARIES} yaml-cpp::yaml-cpp tscpputil resolv) +target_link_libraries(tscore ${PCRE_LIBRARIES} ${OPENSSL_LIBRARIES} yaml-cpp::yaml-cpp tscpputil resolv libswoc) add_executable(test_tscore unit_tests/test_AcidPtr.cc From dd77a03cf7b2f7f3fd45da0d33ee59555fcc15c2 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Wed, 8 Mar 2023 15:28:09 -0600 Subject: [PATCH 2/7] Also move the RecProcess code to iocore/eventsystem --- include/records/I_RecDefs.h | 10 +++++----- include/records/I_RecProcess.h | 2 +- iocore/eventsystem/EventSystem.cc | 3 +-- iocore/eventsystem/Makefile.am | 2 ++ .../eventsystem}/RecProcess.cc | 2 +- .../traffic_server => iocore/eventsystem}/RecProcess.h | 3 --- iocore/eventsystem/RecRawStatsImpl.cc | 6 ++---- proxy/logging/LogStandalone.cc | 3 +-- src/records/RecCore.cc | 1 - src/records/RecRawStats.cc | 3 ++- src/traffic_crashlog/traffic_crashlog.cc | 1 + src/traffic_layout/engine.cc | 2 ++ src/traffic_layout/info.cc | 1 + src/traffic_quic/traffic_quic.cc | 2 ++ src/traffic_server/CMakeLists.txt | 1 - 15 files changed, 21 insertions(+), 21 deletions(-) rename {src/traffic_server => iocore/eventsystem}/RecProcess.cc (99%) rename {src/traffic_server => iocore/eventsystem}/RecProcess.h (99%) diff --git a/include/records/I_RecDefs.h b/include/records/I_RecDefs.h index 9859bfb74cf..d96f1e0deaa 100644 --- a/include/records/I_RecDefs.h +++ b/include/records/I_RecDefs.h @@ -157,11 +157,11 @@ struct RecRawStatBlock; // The implementation of this was moved out of the records library due to a circular dependency this produced. // look for the implmenetation of RecRawStatBlockOps in iocore/eventsystem struct RecRawStatBlockOps { - virtual int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) = 0; - virtual int raw_stat_clear_count(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_clear_count(RecRawStatBlock *rsb, int id) = 0; virtual int raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) = 0; - virtual int raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) = 0; - virtual int raw_stat_clear(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) = 0; + virtual int raw_stat_clear(RecRawStatBlock *rsb, int id) = 0; }; // WARNING! It's advised that developers do not modify the contents of @@ -172,7 +172,7 @@ struct RecRawStatBlock { int num_stats; // number of stats in this block int max_stats; // maximum number of stats for this block ink_mutex mutex; - RecRawStatBlockOps* ops; + RecRawStatBlockOps *ops; }; //------------------------------------------------------------------------- diff --git a/include/records/I_RecProcess.h b/include/records/I_RecProcess.h index 509412e7bc3..15a51117fb2 100644 --- a/include/records/I_RecProcess.h +++ b/include/records/I_RecProcess.h @@ -30,7 +30,7 @@ // RawStat Registration //------------------------------------------------------------------------- -using RecRawStatBlockAllocator = RecRawStatBlock* (*)(int num_stats); +using RecRawStatBlockAllocator = RecRawStatBlock *(*)(int num_stats); void SetRecAllocateRawStatBlockAllocator(RecRawStatBlockAllocator); RecRawStatBlock *RecAllocateRawStatBlock(int num_stats); diff --git a/iocore/eventsystem/EventSystem.cc b/iocore/eventsystem/EventSystem.cc index 21e70dd4910..4e54a0d4eb7 100644 --- a/iocore/eventsystem/EventSystem.cc +++ b/iocore/eventsystem/EventSystem.cc @@ -31,8 +31,7 @@ #include "P_EventSystem.h" #include "tscore/hugepages.h" -void -SetupRecRawStatBlockAllocator(); +void SetupRecRawStatBlockAllocator(); void ink_event_system_init(ts::ModuleVersion v) diff --git a/iocore/eventsystem/Makefile.am b/iocore/eventsystem/Makefile.am index a18ee043f20..3b642e9104e 100644 --- a/iocore/eventsystem/Makefile.am +++ b/iocore/eventsystem/Makefile.am @@ -63,6 +63,8 @@ libinkevent_a_SOURCES = \ Processor.cc \ ProtectedQueue.cc \ ProxyAllocator.cc \ + RecProcess.cc \ + RecRawStatsImpl.cc \ SocketManager.cc \ Tasks.cc \ Thread.cc \ diff --git a/src/traffic_server/RecProcess.cc b/iocore/eventsystem/RecProcess.cc similarity index 99% rename from src/traffic_server/RecProcess.cc rename to iocore/eventsystem/RecProcess.cc index a9d4185dcbf..b92462b8a6f 100644 --- a/src/traffic_server/RecProcess.cc +++ b/iocore/eventsystem/RecProcess.cc @@ -34,7 +34,7 @@ #include "records/P_RecFile.h" // Marks whether the message handler has been initialized. -static bool g_started = false; +static bool g_started = false; static EventNotify g_force_req_notify; static int g_rec_raw_stat_sync_interval_ms = REC_RAW_STAT_SYNC_INTERVAL_MS; static int g_rec_config_update_interval_ms = REC_CONFIG_UPDATE_INTERVAL_MS; diff --git a/src/traffic_server/RecProcess.h b/iocore/eventsystem/RecProcess.h similarity index 99% rename from src/traffic_server/RecProcess.h rename to iocore/eventsystem/RecProcess.h index e6bd53eb100..76a39c23eb9 100644 --- a/src/traffic_server/RecProcess.h +++ b/iocore/eventsystem/RecProcess.h @@ -23,11 +23,9 @@ Public RecProcess declarations #pragma once - #include "records/I_RecDefs.h" #include "tscore/Diags.h" - //------------------------------------------------------------------------- // Initialization/Starting //------------------------------------------------------------------------- @@ -40,4 +38,3 @@ int RecProcessStart(); void RecProcess_set_raw_stat_sync_interval_ms(int ms); void RecProcess_set_config_update_interval_ms(int ms); void RecProcess_set_remote_sync_interval_ms(int ms); - diff --git a/iocore/eventsystem/RecRawStatsImpl.cc b/iocore/eventsystem/RecRawStatsImpl.cc index 717459805db..cd66e819c5c 100644 --- a/iocore/eventsystem/RecRawStatsImpl.cc +++ b/iocore/eventsystem/RecRawStatsImpl.cc @@ -30,8 +30,7 @@ Record statistics support (EThread implementation). // raw_stat_get_total //------------------------------------------------------------------------- -struct RecRawStatBlockOpsImpl : RecRawStatBlockOps -{ +struct RecRawStatBlockOpsImpl : RecRawStatBlockOps { int raw_stat_clear(RecRawStatBlock *rsb, int id) override; int raw_stat_clear_count(RecRawStatBlock *rsb, int id) override; int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) override; @@ -39,7 +38,7 @@ struct RecRawStatBlockOpsImpl : RecRawStatBlockOps int raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) override; }; -RecRawStatBlock* +RecRawStatBlock * RecAllocateRawStatBlockImpl(int num_stats) { static RecRawStatBlockOpsImpl ops; @@ -253,4 +252,3 @@ RecRawStatBlockOpsImpl::raw_stat_clear_count(RecRawStatBlock *rsb, int id) return REC_ERR_OKAY; } - diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc index 58e80d7ec4e..9565afb0260 100644 --- a/proxy/logging/LogStandalone.cc +++ b/proxy/logging/LogStandalone.cc @@ -40,6 +40,7 @@ // Needs LibRecordsConfigInit() #include "records/I_RecordsConfig.h" #include "I_Machine.h" +#include "RecProcess.h" #define LOG_FILENAME_SIZE 255 @@ -103,8 +104,6 @@ initialize_process_manager() RecProcessInit(diags()); LibRecordsConfigInit(); - RecProcessInitMessage(); - // // Define version info records // diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index ae1803d9a01..53bd8d6dfde 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -1317,4 +1317,3 @@ i_am_the_record_owner(RecT rec_type) return false; } - diff --git a/src/records/RecRawStats.cc b/src/records/RecRawStats.cc index fe8bb590a9b..deaf8398250 100644 --- a/src/records/RecRawStats.cc +++ b/src/records/RecRawStats.cc @@ -29,7 +29,8 @@ Record statistics support // RecAllocateRawStatBlock //------------------------------------------------------------------------- static RecRawStatBlockAllocator raw_stat_block_allocator = nullptr; -void SetRecAllocateRawStatBlockAllocator(RecRawStatBlockAllocator f) +void +SetRecAllocateRawStatBlockAllocator(RecRawStatBlockAllocator f) { raw_stat_block_allocator = f; } diff --git a/src/traffic_crashlog/traffic_crashlog.cc b/src/traffic_crashlog/traffic_crashlog.cc index 47b67dd5902..f7bee21a624 100644 --- a/src/traffic_crashlog/traffic_crashlog.cc +++ b/src/traffic_crashlog/traffic_crashlog.cc @@ -31,6 +31,7 @@ #include "records/I_RecordsConfig.h" #include "tscore/BaseLogFile.h" #include "tscore/runroot.h" +#include "RecProcess.h" static int syslog_mode = false; static int debug_mode = false; diff --git a/src/traffic_layout/engine.cc b/src/traffic_layout/engine.cc index 7ba0e120efb..c6a2eba40a3 100644 --- a/src/traffic_layout/engine.cc +++ b/src/traffic_layout/engine.cc @@ -41,6 +41,8 @@ #include #include +#include "RecProcess.h" + static const long MAX_LOGIN = ink_login_name_max(); static constexpr int MAX_GROUP_NUM = 32; diff --git a/src/traffic_layout/info.cc b/src/traffic_layout/info.cc index e9ed63a1392..1de8cfe40f0 100644 --- a/src/traffic_layout/info.cc +++ b/src/traffic_layout/info.cc @@ -29,6 +29,7 @@ #include "records/I_RecProcess.h" #include "records/I_RecordsConfig.h" #include "info.h" +#include "RecProcess.h" #if TS_USE_HWLOC #include diff --git a/src/traffic_quic/traffic_quic.cc b/src/traffic_quic/traffic_quic.cc index f61db271e90..5e1212b340c 100644 --- a/src/traffic_quic/traffic_quic.cc +++ b/src/traffic_quic/traffic_quic.cc @@ -39,6 +39,8 @@ #include "P_SSLUtils.h" #include "P_SSLConfig.h" +#include "RecProcess.h" + #define THREADS 1 constexpr size_t stacksize = 1048576; diff --git a/src/traffic_server/CMakeLists.txt b/src/traffic_server/CMakeLists.txt index 89f426904a3..e0ed574ad84 100644 --- a/src/traffic_server/CMakeLists.txt +++ b/src/traffic_server/CMakeLists.txt @@ -25,7 +25,6 @@ add_executable(traffic_server SocksProxy.cc traffic_server.cc RpcAdminPubHandlers.cc - RecProcess.cc ${CMAKE_SOURCE_DIR}/src/shared/overridable_txn_vars.cc RecProcess.h) target_include_directories(traffic_server PRIVATE From 8ec3ed3800e606cc6519355d19c14c47131c4823 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Wed, 8 Mar 2023 17:27:51 -0600 Subject: [PATCH 3/7] Move call to setup statblock allocator. Fix include --- iocore/eventsystem/EventSystem.cc | 4 ---- iocore/eventsystem/I_EventSystem.h | 1 + iocore/eventsystem/RecProcess.cc | 4 ++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/iocore/eventsystem/EventSystem.cc b/iocore/eventsystem/EventSystem.cc index 4e54a0d4eb7..cf3c989197e 100644 --- a/iocore/eventsystem/EventSystem.cc +++ b/iocore/eventsystem/EventSystem.cc @@ -31,16 +31,12 @@ #include "P_EventSystem.h" #include "tscore/hugepages.h" -void SetupRecRawStatBlockAllocator(); - void ink_event_system_init(ts::ModuleVersion v) { ink_release_assert(v.check(EVENT_SYSTEM_MODULE_INTERNAL_VERSION)); int iobuffer_advice = 0; - SetupRecRawStatBlockAllocator(); - // For backwards compatibility make sure to allow thread_freelist_size // This needs to change in 6.0 REC_EstablishStaticConfigInt32(thread_freelist_high_watermark, "proxy.config.allocator.thread_freelist_size"); diff --git a/iocore/eventsystem/I_EventSystem.h b/iocore/eventsystem/I_EventSystem.h index a062b5c31a8..8064be7fe1b 100644 --- a/iocore/eventsystem/I_EventSystem.h +++ b/iocore/eventsystem/I_EventSystem.h @@ -44,6 +44,7 @@ #include "I_VConnection.h" #include "records/I_RecProcess.h" #include "I_SocketManager.h" +#include "RecProcess.h" static constexpr ts::ModuleVersion EVENT_SYSTEM_MODULE_PUBLIC_VERSION(1, 0, ts::ModuleVersion::PUBLIC); diff --git a/iocore/eventsystem/RecProcess.cc b/iocore/eventsystem/RecProcess.cc index b92462b8a6f..fff53ca6acc 100644 --- a/iocore/eventsystem/RecProcess.cc +++ b/iocore/eventsystem/RecProcess.cc @@ -138,6 +138,8 @@ struct sync_cont : public Continuation { } }; +void SetupRecRawStatBlockAllocator(); + //------------------------------------------------------------------------- // RecProcessInit //------------------------------------------------------------------------- @@ -146,6 +148,8 @@ RecProcessInit(Diags *_diags) { static bool initialized_p = false; + SetupRecRawStatBlockAllocator(); + if (initialized_p) { return REC_ERR_OKAY; } From 9bf774ae7cd18dcab4e263e74907f975949b10b9 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Wed, 8 Mar 2023 18:34:18 -0600 Subject: [PATCH 4/7] fix library order for linker --- mgmt/rpc/Makefile.am | 4 ---- src/traffic_crashlog/Makefile.inc | 2 +- src/traffic_layout/Makefile.inc | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/mgmt/rpc/Makefile.am b/mgmt/rpc/Makefile.am index 415ad089c12..04c4145d609 100644 --- a/mgmt/rpc/Makefile.am +++ b/mgmt/rpc/Makefile.am @@ -66,11 +66,9 @@ test_jsonrpc_SOURCES = \ test_jsonrpc_LDADD = \ libjsonrpc_protocol.la \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ - $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/src/tscore/libtscore.la \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/src/records/librecords_p.a \ - $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/src/tscore/libtscore.la \ $(top_builddir)/mgmt/utils/libutils_p.la \ @YAMLCPP_LIBS@ @HWLOC_LIBS@ @@ -109,11 +107,9 @@ test_jsonrpcserver_SOURCES = \ test_jsonrpcserver_LDADD = \ libjsonrpc_protocol.la \ libjsonrpc_server.la \ - $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/src/tscore/libtscore.la \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/src/records/librecords_p.a \ - $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ $(top_builddir)/src/tscore/libtscore.la \ $(top_builddir)/mgmt/utils/libutils_p.la \ diff --git a/src/traffic_crashlog/Makefile.inc b/src/traffic_crashlog/Makefile.inc index 1d88fe10ca7..ceee194fc63 100644 --- a/src/traffic_crashlog/Makefile.inc +++ b/src/traffic_crashlog/Makefile.inc @@ -38,8 +38,8 @@ traffic_crashlog_traffic_crashlog_SOURCES = \ traffic_crashlog/traffic_crashlog.h traffic_crashlog_traffic_crashlog_LDADD = \ - $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ + $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/iocore/net/libinknet.a \ $(top_builddir)/src/tscore/libtscore.la \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ diff --git a/src/traffic_layout/Makefile.inc b/src/traffic_layout/Makefile.inc index ccc10d033a8..0bdde7f6a06 100644 --- a/src/traffic_layout/Makefile.inc +++ b/src/traffic_layout/Makefile.inc @@ -42,8 +42,8 @@ traffic_layout_traffic_layout_SOURCES = \ traffic_layout/info.h traffic_layout_traffic_layout_LDADD = \ - $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ + $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/src/tscore/libtscore.la \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ @SWOC_LIBS@ @HWLOC_LIBS@ @YAMLCPP_LIBS@ @LIBLZMA@ From 0d7a84c1242855bad267d49d803a3f178a1ba822 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Thu, 9 Mar 2023 16:26:38 -0600 Subject: [PATCH 5/7] fix merge issue --- iocore/eventsystem/RecProcess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocore/eventsystem/RecProcess.h b/iocore/eventsystem/RecProcess.h index 76a39c23eb9..f34d6f9621c 100644 --- a/iocore/eventsystem/RecProcess.h +++ b/iocore/eventsystem/RecProcess.h @@ -29,7 +29,7 @@ Public RecProcess declarations //------------------------------------------------------------------------- // Initialization/Starting //------------------------------------------------------------------------- -int RecProcessInit(RecModeT mode_type, Diags *diags = nullptr); +int RecProcessInit(Diags *diags = nullptr); int RecProcessStart(); //------------------------------------------------------------------------- From deaf5574777ab64beac2b4adedb0fad38c34596b Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Thu, 9 Mar 2023 16:40:49 -0600 Subject: [PATCH 6/7] fix merge issue --- src/records/RecCore.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index 53bd8d6dfde..20daab92f69 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -1301,18 +1301,16 @@ RecConfigWarnIfUnregistered() bool i_am_the_record_owner(RecT rec_type) { - if (g_mode_type == RECM_STAND_ALONE) { - switch (rec_type) { - case RECT_CONFIG: - case RECT_PROCESS: - case RECT_NODE: - case RECT_LOCAL: - case RECT_PLUGIN: - return true; - default: - ink_assert(!"Unexpected RecT type"); - return false; - } + switch (rec_type) { + case RECT_CONFIG: + case RECT_PROCESS: + case RECT_NODE: + case RECT_LOCAL: + case RECT_PLUGIN: + return true; + default: + ink_assert(!"Unexpected RecT type"); + return false; } return false; From 4b92f14d8ae2bcf29a44858b499b956d8b9365f5 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 13 Mar 2023 09:32:47 -0500 Subject: [PATCH 7/7] fix typo --- include/records/I_RecDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/records/I_RecDefs.h b/include/records/I_RecDefs.h index d96f1e0deaa..24851a44027 100644 --- a/include/records/I_RecDefs.h +++ b/include/records/I_RecDefs.h @@ -155,7 +155,7 @@ struct RecRawStatBlock; // This defines the interface to the low level stat block operations // The implementation of this was moved out of the records library due to a circular dependency this produced. -// look for the implmenetation of RecRawStatBlockOps in iocore/eventsystem +// look for the implementation of RecRawStatBlockOps in iocore/eventsystem struct RecRawStatBlockOps { virtual int raw_stat_clear_sum(RecRawStatBlock *rsb, int id) = 0; virtual int raw_stat_clear_count(RecRawStatBlock *rsb, int id) = 0;