Fix a crash for configs with no http block.

This commit is contained in:
Dmitry Plotnikov 2023-04-18 19:09:26 +00:00 committed by dplotnikov-f5
parent 5f611a0fc8
commit 387d391823

View file

@ -552,6 +552,10 @@ ngx_int_t initWorkerProcess(ngx_cycle_t* cycle)
auto mcf = (MainConf*)ngx_http_cycle_get_module_main_conf(
cycle, gHttpModule);
if (mcf == NULL) {
return NGX_OK;
}
try {
gExporter.reset(new BatchExporter(
toStrView(mcf->endpoint),
@ -591,6 +595,10 @@ ngx_int_t initWorkerProcess(ngx_cycle_t* cycle)
void exitWorkerProcess(ngx_cycle_t* cycle)
{
if (!gExporter) {
return;
}
try {
gExporter->flush();
} catch (const std::exception& e) {