ywkaras commented on code in PR #11634:
URL: https://github.com/apache/trafficserver/pull/11634#discussion_r1700832277
##########
src/iocore/cache/unit_tests/stub.cc:
##########
@@ -27,6 +27,29 @@
#include "proxy/HttpAPIHooks.h"
+#include "tscore/BaseLogFile.h"
+#include "tscore/Diags.h"
+
+class InitDiags
+{
+public:
+ InitDiags() : base_log_file{new BaseLogFile("stderr")}
+ {
+ DiagsPtr::set(new Diags("cache unit test", "*" /* tags */, "" /* actions
*/, this->base_log_file));
+ }
+
+ ~InitDiags() { delete this->base_log_file; }
+
+private:
+ BaseLogFile *base_log_file;
+};
+
+// The FetchSM class allocator below uses the diags in its constructor, so we
+// force them to be initialized prior to that. This gets "leaked" at shutdown
+// to ensure that the log file remains valid if accessed by other threads
+// during static object destruction.
+InitDiags const *g_init_diags_dummy = new InitDiags{};
Review Comment:
This is a leak isn't it? Why not just:
```
namespace
{
InitDiags init_diags_dummy;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]