Skip to content

Commit

Permalink
* fix stats muxer memory-leak
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Feb 8, 2024
1 parent bf4da23 commit fc10c88
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions broker/core/multiplexing/src/muxer.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
** Copyright 2009-2013,2015-2017,2019-2021 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : [email protected]
*/
/**
* Copyright 2009-2013,2015-2017,2019-2021 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/

#include "com/centreon/broker/multiplexing/muxer.hh"

Expand Down Expand Up @@ -195,15 +195,19 @@ std::shared_ptr<muxer> muxer::create(std::string name,
* Destructor.
*/
muxer::~muxer() noexcept {
stats::center::instance().unregister_muxer(_name);
unsubscribe();
std::lock_guard<std::mutex> lock(_mutex);
SPDLOG_LOGGER_INFO(log_v2::core(),
"Destroying muxer {}: number of events in the queue: {}",
_name, _events_size);
_clean();
{
std::lock_guard<std::mutex> lock(_mutex);
SPDLOG_LOGGER_INFO(log_v2::core(),
"Destroying muxer {}: number of events in the queue: {}",
_name, _events_size);
_clean();
}
DEBUG(
fmt::format("DESTRUCTOR muxer {:p} {}", static_cast<void*>(this), _name));
// caution, unregister_muxer must be the last center method called at muxer
// destruction to avoid re create a muxer stat entry
stats::center::instance().unregister_muxer(_name);
}

/**
Expand Down

1 comment on commit fc10c88

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
3 2 0 5 60.00 0s

Failed Tests

Name Message ⏱️ Duration Suite
BRGC1 There should not exist que map files. 0.000 s Reverse-Connection
BRCTS1 Connection to map has failed 0.000 s Reverse-Connection

Please sign in to comment.