Merge remote-tracking branch 'origin/topic/timw/3163-gperftools-build'

* origin/topic/timw/3163-gperftools-build:
  Define early_shutdown lambda earlier in zeek-setup, avoids build failure with gperftools

(cherry picked from commit 2da6f94ab6)
This commit is contained in:
Arne Welzel 2023-07-06 09:27:03 +02:00 committed by Tim Wojtulewicz
parent ddaa553418
commit c19069acdb

View file

@ -774,6 +774,20 @@ SetupResult setup(int argc, char** argv, Options* zopts)
dbl_histogram_metric_type = make_intrusive<OpaqueType>("dbl_histogram_metric");
dbl_histogram_metric_family_type = make_intrusive<OpaqueType>("dbl_histogram_metric_family");
// After spinning up Broker, we have background threads running now. If
// we exit early, we need to shut down at least Broker to get a clean
// program exit. Otherwise, we may run into undefined behavior, e.g., if
// Broker is still accessing OpenSSL but OpenSSL has already cleaned up
// its state due to calling exit(). This needs to be defined here before
// potential USE_PERFTOOLS_DEBUG scope below or the definition gets lost
// when that variable is defined.
auto early_shutdown = []
{
broker_mgr->Terminate();
delete iosource_mgr;
delete telemetry_mgr;
};
// The leak-checker tends to produce some false
// positives (memory which had already been
// allocated before we start the checking is
@ -867,18 +881,6 @@ SetupResult setup(int argc, char** argv, Options* zopts)
if ( supervisor_mgr )
supervisor_mgr->InitPostScript();
// After spinning up Broker, we have background threads running now. If
// we exit early, we need to shut down at least Broker to get a clean
// program exit. Otherwise, we may run into undefined behavior, e.g., if
// Broker is still accessing OpenSSL but OpenSSL has already cleaned up
// its state due to calling exit().
auto early_shutdown = []
{
broker_mgr->Terminate();
delete iosource_mgr;
delete telemetry_mgr;
};
if ( options.print_plugins )
{
early_shutdown();