From 6f6736bb71db060af87915bf03ddc0e020fbf989 Mon Sep 17 00:00:00 2001 From: Matevz Tadel Date: Wed, 20 Nov 2024 11:33:48 -0800 Subject: [PATCH] Implement review suggestions by @amadio. --- src/XrdPfc/XrdPfcConfiguration.cc | 5 +++++ src/XrdPfc/XrdPfcIO.hh | 2 +- src/XrdPfc/XrdPfcIOFile.cc | 2 -- src/XrdPfc/XrdPfcTrace.hh | 11 +++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/XrdPfc/XrdPfcConfiguration.cc b/src/XrdPfc/XrdPfcConfiguration.cc index 2cdb5869394..075b3dbf7d9 100644 --- a/src/XrdPfc/XrdPfcConfiguration.cc +++ b/src/XrdPfc/XrdPfcConfiguration.cc @@ -15,6 +15,11 @@ #include +namespace XrdPfc +{ + const char *trace_what_strings[] = {"","error ","warning ","info ","debug ","dump "}; +} + using namespace XrdPfc; XrdVERSIONINFO(XrdOucGetCache, XrdPfc); diff --git a/src/XrdPfc/XrdPfcIO.hh b/src/XrdPfc/XrdPfcIO.hh index 2f7564ac592..a8298927c2a 100644 --- a/src/XrdPfc/XrdPfcIO.hh +++ b/src/XrdPfc/XrdPfcIO.hh @@ -77,7 +77,6 @@ private: void SetInput(XrdOucCacheIO*); -protected: // Variables used by File to store IO-relates state. Managed under // File::m_state_cond mutex. friend class File; @@ -87,6 +86,7 @@ protected: bool m_allow_prefetching {true}; bool m_in_detach {false}; +protected: int m_incomplete_count {0}; std::map m_error_counts; bool register_incomplete_read() { diff --git a/src/XrdPfc/XrdPfcIOFile.cc b/src/XrdPfc/XrdPfcIOFile.cc index 4567a23be2b..1a54db38021 100644 --- a/src/XrdPfc/XrdPfcIOFile.cc +++ b/src/XrdPfc/XrdPfcIOFile.cc @@ -158,7 +158,6 @@ void IOFile::DetachFinalize() m_file->RequestSyncOfDetachStats(); Cache::GetInstance().ReleaseFile(m_file, this); -#ifndef NODEBUG if (( ! m_error_counts.empty() || m_incomplete_count > 0) && XRD_TRACE What >= TRACE_Error) { char info[1024]; int pos = 0, cap = 1024; @@ -175,7 +174,6 @@ void IOFile::DetachFinalize() TRACE(Error, "DetachFinalize() " << this << " n_incomplete_reads=" << m_incomplete_count << ", block (error : count) report:" << info << (truncated ? " - truncated" : "")); } -#endif delete this; } diff --git a/src/XrdPfc/XrdPfcTrace.hh b/src/XrdPfc/XrdPfcTrace.hh index 1fc36d74059..38f2719bd7a 100644 --- a/src/XrdPfc/XrdPfcTrace.hh +++ b/src/XrdPfc/XrdPfcTrace.hh @@ -38,6 +38,11 @@ #define XRD_TRACE GetTrace()-> #endif +namespace XrdPfc +{ + extern const char *trace_what_strings[]; +} + #define ERRNO_AND_ERRSTR(err_code) ", err_code=" << err_code << ", err_str=" << XrdSysE2T(err_code) #define TRACE(act, x) \ @@ -46,8 +51,7 @@ #define TRACE_INT(act, x) \ if (XRD_TRACE What >= act) \ - {static const char* t_what[]={"","error ","warning ","info ","debug ","dump "};\ - SYSTRACE(XRD_TRACE, 0, m_traceID, 0, t_what[act] << x)} + SYSTRACE(XRD_TRACE, 0, m_traceID, 0, trace_what_strings[act] << x) #define TRACE_TEST(act, x) \ SYSTRACE(XRD_TRACE, 0, m_traceID, 0, TRACE_STR_ ## act << x) @@ -66,8 +70,7 @@ #define TRACEF_INT(act, x) \ if (XRD_TRACE What >= act) \ - {static const char* t_what[]={"","error ","warning ","info ","debug ","dump "};\ - SYSTRACE(XRD_TRACE, 0, m_traceID, 0, t_what[act] << x << " " << GetLocalPath())} + SYSTRACE(XRD_TRACE, 0, m_traceID, 0, trace_what_strings[act] << x << " " << GetLocalPath()) #else