JosiahWI commented on code in PR #11634:
URL: https://github.com/apache/trafficserver/pull/11634#discussion_r1700884107
##########
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:
I think a better way to fix this is to have the allocator wait for the diags
to become ready, but we need to make sure this can't cause a deadlock. (This
will also fix it for all the other unit tests that have the same problem.)
--
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]