Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 18d2708

Browse files
authored
fix(neb): centengine segfault fixed when it is terminated.
* pthread_cancel() is forbidden with new C++ abi. REFS: MON-10682
1 parent 07538bd commit 18d2708

29 files changed

+110
-116
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
### Bug fix
66

7+
*cbmod*
8+
9+
A link issue in cbmod caused a crash in centengine. This new version fixes it.
10+
711
*BAM*
812

913
When a new BA is created with new KPI, it is possible to have an issue during

bam/src/ba.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,17 @@ void ba::set_inherited_downtime(inherited_downtime const& dwn) {
650650
*/
651651
void ba::_apply_impact(kpi* kpi_ptr __attribute__((unused)),
652652
ba::impact_info& impact) {
653+
const std::array<short, 5> order{0, 3, 4, 2, 1};
653654
auto is_state_worse = [&](short current_state, short new_state) -> bool {
654-
std::array<short, 4> ord{0, 2, 3, 1};
655-
return ord[new_state] > ord[current_state];
655+
assert((unsigned int)current_state < order.size());
656+
assert((unsigned int)new_state < order.size());
657+
return order[new_state] > order[current_state];
656658
};
657659

658660
auto is_state_better = [&](short current_state, short new_state) -> bool {
659-
std::array<short, 4> ord{0, 2, 3, 1};
660-
return ord[new_state] < ord[current_state];
661+
assert((unsigned int)current_state < order.size());
662+
assert((unsigned int)new_state < order.size());
663+
return order[new_state] < order[current_state];
661664
};
662665

663666
// Adjust values.

neb/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ set_property(TARGET "${CBMOD}"
219219
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
220220
# Flags needed to include all symbols in shared library.
221221
target_link_libraries("${CBMOD}"
222-
"-Wl,--whole-archive" "nebbase" "rokerbase" "-Wl,--no-whole-archive" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
222+
"-Wl,--whole-archive" "rokerbase" "-Wl,--no-whole-archive" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
223223
else ()
224-
target_link_libraries("${CBMOD}" "nebbase" "rokerbase" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
224+
target_link_libraries("${CBMOD}" "rokerbase" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
225225
endif ()
226226
set_target_properties("${CBMOD}" PROPERTIES PREFIX "")
227227

neb/inc/com/centreon/broker/neb/callback.hh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ namespace neb {
3131
* Handle callback registration/deregistration with Nagios.
3232
*/
3333
class callback {
34-
public:
35-
callback(int id, void* handle, int (*function)(int, void*));
36-
~callback() throw();
37-
38-
private:
39-
callback(callback const& right);
40-
callback& operator=(callback const& right);
41-
4234
int (*_function)(int, void*);
4335
int _id;
36+
37+
public:
38+
callback(int id, void* handle, int (*function)(int, void*));
39+
~callback() noexcept;
40+
callback(const callback&);
41+
callback& operator=(const callback&);
4442
};
4543
} // namespace neb
4644

neb/inc/com/centreon/broker/neb/internal.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extern std::string gl_configuration_file;
7171
extern multiplexing::publisher gl_publisher;
7272

7373
// Registered callbacks.
74-
extern std::list<std::shared_ptr<neb::callback> > gl_registered_callbacks;
74+
extern std::list<std::unique_ptr<neb::callback>> gl_registered_callbacks;
7575

7676
// Acknowledgement list.
7777
extern std::map<std::pair<uint32_t, uint32_t>, neb::acknowledgement>

neb/inc/com/centreon/clib/version.hh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@
1717
*/
1818

1919
#ifndef CC_CLIB_VERSION_HH
20-
#define CC_CLIB_VERSION_HH
20+
# define CC_CLIB_VERSION_HH
2121

2222
// Compile-time values.
23-
#define CENTREON_CLIB_VERSION_MAJOR 20
24-
#define CENTREON_CLIB_VERSION_MINOR 10
25-
#define CENTREON_CLIB_VERSION_PATCH 1
26-
#define CENTREON_CLIB_VERSION_STRING "20.10.1"
23+
# define CENTREON_CLIB_VERSION_MAJOR 21
24+
# define CENTREON_CLIB_VERSION_MINOR 04
25+
# define CENTREON_CLIB_VERSION_PATCH 2
26+
# define CENTREON_CLIB_VERSION_STRING "21.04.2"
2727

28-
#include "com/centreon/namespace.hh"
28+
# include "com/centreon/namespace.hh"
2929

3030
CC_BEGIN()
3131

32-
namespace clib {
33-
namespace version {
34-
// Compile-time values.
35-
unsigned int const major = 20;
36-
unsigned int const minor = 10;
37-
unsigned int const patch = 1;
38-
char const* const string = "20.10.1";
39-
40-
// Run-time values.
41-
unsigned int get_major() throw();
42-
unsigned int get_minor() throw();
43-
unsigned int get_patch() throw();
44-
char const* get_string() throw();
45-
} // namespace version
46-
} // namespace clib
32+
namespace clib {
33+
namespace version {
34+
// Compile-time values.
35+
unsigned int const major = 21;
36+
unsigned int const minor = 04;
37+
unsigned int const patch = 2;
38+
char const* const string = "21.04.2";
39+
40+
// Run-time values.
41+
unsigned int get_major() throw ();
42+
unsigned int get_minor() throw ();
43+
unsigned int get_patch() throw ();
44+
char const* get_string() throw ();
45+
}
46+
}
4747

4848
CC_END()
4949

50-
#endif // !CC_HANDLE_HH
50+
#endif // !CC_HANDLE_HH

neb/inc/com/centreon/engine/common.hh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,4 @@ enum ret_val {
325325
#define HOST_STATECHANGE 0
326326
#define SERVICE_STATECHANGE 1
327327

328-
/* Thread stuff. */
329-
#define TOTAL_WORKER_THREADS 1
330-
331328
#endif /* !CCE_COMMON_HH */

neb/inc/com/centreon/engine/enginerpc.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#ifndef CCE_ENGINERPC_ENGINERPC_HH
22
#define CCE_ENGINERPC_ENGINERPC_HH
33

4-
#include <string>
5-
#include <memory>
64
#include <grpcpp/server.h>
5+
#include <memory>
6+
#include <string>
77
#include "com/centreon/engine/namespace.hh"
88
#include "engine_impl.hh"
99

1010
CCE_BEGIN()
1111
class enginerpc final {
12+
engine_impl _service;
1213
std::unique_ptr<grpc::Server> _server;
14+
1315
public:
1416
enginerpc(const std::string& address, uint16_t port);
1517
enginerpc() = delete;

neb/inc/com/centreon/engine/globals.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ extern time_t program_start;
8686
extern time_t event_start;
8787

8888
extern circular_buffer external_command_buffer;
89-
extern pthread_t worker_threads[];
9089

9190
extern check_stats check_statistics[];
9291

neb/inc/com/centreon/engine/timeperiod.hh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ class timeperiod {
5252
timeperiodexclusion const& get_exclusions() const;
5353
timeperiodexclusion& get_exclusions();
5454
void get_next_valid_time_per_timeperiod(time_t preferred_time,
55-
time_t* invalid_time);
55+
time_t* invalid_time,
56+
bool notif_timeperiod);
5657
void get_next_invalid_time_per_timeperiod(time_t preferred_time,
57-
time_t* invalid_time);
58+
time_t* invalid_time,
59+
bool notif_timeperiod);
5860

5961
void resolve(int& w, int& e);
6062

@@ -76,6 +78,9 @@ CCE_END()
7678

7779
bool check_time_against_period(time_t test_time,
7880
com::centreon::engine::timeperiod* tperiod);
81+
bool check_time_against_period_for_notif(
82+
time_t test_time,
83+
com::centreon::engine::timeperiod* tperiod);
7984
void get_next_valid_time(time_t pref_time,
8085
time_t* valid_time,
8186
com::centreon::engine::timeperiod* tperiod);

0 commit comments

Comments
 (0)