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

Commit

Permalink
fix(neb): centengine segfault fixed when it is terminated.
Browse files Browse the repository at this point in the history
* pthread_cancel() is forbidden with new C++ abi.

REFS: MON-10682
  • Loading branch information
bouda1 authored Jul 9, 2021
1 parent 07538bd commit 18d2708
Show file tree
Hide file tree
Showing 29 changed files with 110 additions and 116 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Bug fix

*cbmod*

A link issue in cbmod caused a crash in centengine. This new version fixes it.

*BAM*

When a new BA is created with new KPI, it is possible to have an issue during
Expand Down
11 changes: 7 additions & 4 deletions bam/src/ba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,17 @@ void ba::set_inherited_downtime(inherited_downtime const& dwn) {
*/
void ba::_apply_impact(kpi* kpi_ptr __attribute__((unused)),
ba::impact_info& impact) {
const std::array<short, 5> order{0, 3, 4, 2, 1};
auto is_state_worse = [&](short current_state, short new_state) -> bool {
std::array<short, 4> ord{0, 2, 3, 1};
return ord[new_state] > ord[current_state];
assert((unsigned int)current_state < order.size());
assert((unsigned int)new_state < order.size());
return order[new_state] > order[current_state];
};

auto is_state_better = [&](short current_state, short new_state) -> bool {
std::array<short, 4> ord{0, 2, 3, 1};
return ord[new_state] < ord[current_state];
assert((unsigned int)current_state < order.size());
assert((unsigned int)new_state < order.size());
return order[new_state] < order[current_state];
};

// Adjust values.
Expand Down
4 changes: 2 additions & 2 deletions neb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ set_property(TARGET "${CBMOD}"
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Flags needed to include all symbols in shared library.
target_link_libraries("${CBMOD}"
"-Wl,--whole-archive" "nebbase" "rokerbase" "-Wl,--no-whole-archive" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
"-Wl,--whole-archive" "rokerbase" "-Wl,--no-whole-archive" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
else ()
target_link_libraries("${CBMOD}" "nebbase" "rokerbase" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
target_link_libraries("${CBMOD}" "rokerbase" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${asio_LIBS} ${OpenSSL_LIBS})
endif ()
set_target_properties("${CBMOD}" PROPERTIES PREFIX "")

Expand Down
14 changes: 6 additions & 8 deletions neb/inc/com/centreon/broker/neb/callback.hh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ namespace neb {
* Handle callback registration/deregistration with Nagios.
*/
class callback {
public:
callback(int id, void* handle, int (*function)(int, void*));
~callback() throw();

private:
callback(callback const& right);
callback& operator=(callback const& right);

int (*_function)(int, void*);
int _id;

public:
callback(int id, void* handle, int (*function)(int, void*));
~callback() noexcept;
callback(const callback&);
callback& operator=(const callback&);
};
} // namespace neb

Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/broker/neb/internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extern std::string gl_configuration_file;
extern multiplexing::publisher gl_publisher;

// Registered callbacks.
extern std::list<std::shared_ptr<neb::callback> > gl_registered_callbacks;
extern std::list<std::unique_ptr<neb::callback>> gl_registered_callbacks;

// Acknowledgement list.
extern std::map<std::pair<uint32_t, uint32_t>, neb::acknowledgement>
Expand Down
44 changes: 22 additions & 22 deletions neb/inc/com/centreon/clib/version.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@
*/

#ifndef CC_CLIB_VERSION_HH
#define CC_CLIB_VERSION_HH
# define CC_CLIB_VERSION_HH

// Compile-time values.
#define CENTREON_CLIB_VERSION_MAJOR 20
#define CENTREON_CLIB_VERSION_MINOR 10
#define CENTREON_CLIB_VERSION_PATCH 1
#define CENTREON_CLIB_VERSION_STRING "20.10.1"
# define CENTREON_CLIB_VERSION_MAJOR 21
# define CENTREON_CLIB_VERSION_MINOR 04
# define CENTREON_CLIB_VERSION_PATCH 2
# define CENTREON_CLIB_VERSION_STRING "21.04.2"

#include "com/centreon/namespace.hh"
# include "com/centreon/namespace.hh"

CC_BEGIN()

namespace clib {
namespace version {
// Compile-time values.
unsigned int const major = 20;
unsigned int const minor = 10;
unsigned int const patch = 1;
char const* const string = "20.10.1";

// Run-time values.
unsigned int get_major() throw();
unsigned int get_minor() throw();
unsigned int get_patch() throw();
char const* get_string() throw();
} // namespace version
} // namespace clib
namespace clib {
namespace version {
// Compile-time values.
unsigned int const major = 21;
unsigned int const minor = 04;
unsigned int const patch = 2;
char const* const string = "21.04.2";

// Run-time values.
unsigned int get_major() throw ();
unsigned int get_minor() throw ();
unsigned int get_patch() throw ();
char const* get_string() throw ();
}
}

CC_END()

#endif // !CC_HANDLE_HH
#endif // !CC_HANDLE_HH
3 changes: 0 additions & 3 deletions neb/inc/com/centreon/engine/common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,4 @@ enum ret_val {
#define HOST_STATECHANGE 0
#define SERVICE_STATECHANGE 1

/* Thread stuff. */
#define TOTAL_WORKER_THREADS 1

#endif /* !CCE_COMMON_HH */
6 changes: 4 additions & 2 deletions neb/inc/com/centreon/engine/enginerpc.hh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#ifndef CCE_ENGINERPC_ENGINERPC_HH
#define CCE_ENGINERPC_ENGINERPC_HH

#include <string>
#include <memory>
#include <grpcpp/server.h>
#include <memory>
#include <string>
#include "com/centreon/engine/namespace.hh"
#include "engine_impl.hh"

CCE_BEGIN()
class enginerpc final {
engine_impl _service;
std::unique_ptr<grpc::Server> _server;

public:
enginerpc(const std::string& address, uint16_t port);
enginerpc() = delete;
Expand Down
1 change: 0 additions & 1 deletion neb/inc/com/centreon/engine/globals.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ extern time_t program_start;
extern time_t event_start;

extern circular_buffer external_command_buffer;
extern pthread_t worker_threads[];

extern check_stats check_statistics[];

Expand Down
9 changes: 7 additions & 2 deletions neb/inc/com/centreon/engine/timeperiod.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ class timeperiod {
timeperiodexclusion const& get_exclusions() const;
timeperiodexclusion& get_exclusions();
void get_next_valid_time_per_timeperiod(time_t preferred_time,
time_t* invalid_time);
time_t* invalid_time,
bool notif_timeperiod);
void get_next_invalid_time_per_timeperiod(time_t preferred_time,
time_t* invalid_time);
time_t* invalid_time,
bool notif_timeperiod);

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

Expand All @@ -76,6 +78,9 @@ CCE_END()

bool check_time_against_period(time_t test_time,
com::centreon::engine::timeperiod* tperiod);
bool check_time_against_period_for_notif(
time_t test_time,
com::centreon::engine::timeperiod* tperiod);
void get_next_valid_time(time_t pref_time,
time_t* valid_time,
com::centreon::engine::timeperiod* tperiod);
Expand Down
4 changes: 2 additions & 2 deletions neb/inc/com/centreon/engine/version.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Compile-time values.
#define CENTREON_ENGINE_VERSION_MAJOR 21
#define CENTREON_ENGINE_VERSION_MINOR 04
#define CENTREON_ENGINE_VERSION_PATCH 0
#define CENTREON_ENGINE_VERSION_STRING "21.04.0"
#define CENTREON_ENGINE_VERSION_PATCH 3
#define CENTREON_ENGINE_VERSION_STRING "21.04.3"

#endif // !CCE_VERSION_HH
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/exceptions/basic.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class basic : public std::exception {

misc::stringifier _buffer;
};
} // namespace exceptions
}

CC_END()

Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/exceptions/interruption.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class interruption : public basic {
return (*this);
}
};
} // namespace exceptions
}

CC_END()

Expand Down
4 changes: 2 additions & 2 deletions neb/inc/com/centreon/io/directory_entry.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include <list>
#include <string>
#include "com/centreon/handle.hh"
#include "com/centreon/io/file_entry.hh"
#include "com/centreon/handle.hh"
#include "com/centreon/namespace.hh"

CC_BEGIN()
Expand Down Expand Up @@ -55,7 +55,7 @@ class directory_entry {
file_entry _entry;
std::list<file_entry> _entry_lst;
};
} // namespace io
}

CC_END()

Expand Down
6 changes: 3 additions & 3 deletions neb/inc/com/centreon/io/file_entry.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#ifndef CC_IO_FILE_ENTRY_HH
#define CC_IO_FILE_ENTRY_HH

#include <sys/stat.h>
#include <sys/types.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include "com/centreon/handle.hh"
#include "com/centreon/namespace.hh"

Expand Down Expand Up @@ -65,7 +65,7 @@ class file_entry {
std::string _path;
struct stat _sbuf;
};
} // namespace io
}

CC_END()

Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/io/file_stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class file_stream : public handle {
bool _auto_close;
FILE* _stream;
};
} // namespace io
}

CC_END()

Expand Down
9 changes: 7 additions & 2 deletions neb/inc/com/centreon/logging/backend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class stringifier;
}

namespace logging {
enum time_precision { none = 0, microsecond = 1, millisecond = 2, second = 3 };
enum time_precision {
none = 0,
microsecond = 1,
millisecond = 2,
second = 3
};

/**
* @class backend backend.hh "com/centreon/logging/backend.hh"
Expand Down Expand Up @@ -76,7 +81,7 @@ class backend {
protected:
void _internal_copy(backend const& right);
};
} // namespace logging
}

CC_END()

Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/logging/engine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class engine {
unsigned long long _list_types[sizeof(unsigned int) * CHAR_BIT];
mutable std::mutex _mtx;
};
} // namespace logging
}

CC_END()

Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/logging/file.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class file : public backend {
FILE* _out;
uint64_t _size;
};
} // namespace logging
}

CC_END()

Expand Down
20 changes: 12 additions & 8 deletions neb/inc/com/centreon/logging/logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ enum type_value {
type_error = (1ull << 63)
};

enum verbosity_level { low = 0, medium = 1, high = 2 };
} // namespace logging
enum verbosity_level {
low = 0,
medium = 1,
high = 2
};
}

CC_END()

#define log_info(verbose) \
for (unsigned int __com_centreon_logging_define_ui(0); \
!__com_centreon_logging_define_ui && \
com::centreon::logging::engine::instance().is_log( \
com::centreon::logging::type_info, verbose); \
com::centreon::logging::engine::instance().is_log( \
com::centreon::logging::type_info, verbose); \
++__com_centreon_logging_define_ui) \
com::centreon::logging::temp_logger(com::centreon::logging::type_info, \
verbose) \
Expand All @@ -48,8 +52,8 @@ CC_END()
#define log_debug(verbose) \
for (unsigned int __com_centreon_logging_define_ui(0); \
!__com_centreon_logging_define_ui && \
com::centreon::logging::engine::instance().is_log( \
com::centreon::logging::type_debug, verbose); \
com::centreon::logging::engine::instance().is_log( \
com::centreon::logging::type_debug, verbose); \
++__com_centreon_logging_define_ui) \
com::centreon::logging::temp_logger(com::centreon::logging::type_debug, \
verbose) \
Expand All @@ -58,8 +62,8 @@ CC_END()
#define log_error(verbose) \
for (unsigned int __com_centreon_logging_define_ui(0); \
!__com_centreon_logging_define_ui && \
com::centreon::logging::engine::instance().is_log( \
com::centreon::logging::type_error, verbose); \
com::centreon::logging::engine::instance().is_log( \
com::centreon::logging::type_error, verbose); \
++__com_centreon_logging_define_ui) \
com::centreon::logging::temp_logger(com::centreon::logging::type_error, \
verbose) \
Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/logging/syslogger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class syslogger : public backend {
int _facility;
std::string _id;
};
} // namespace logging
}

CC_END()

Expand Down
4 changes: 2 additions & 2 deletions neb/inc/com/centreon/logging/temp_logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include <string>
#include "com/centreon/logging/engine.hh"
#include "com/centreon/misc/stringifier.hh"
#include "com/centreon/namespace.hh"
#include "com/centreon/misc/stringifier.hh"

CC_BEGIN()

Expand Down Expand Up @@ -59,7 +59,7 @@ class temp_logger {
unsigned long long _type;
unsigned int _verbose;
};
} // namespace logging
}

CC_END()

Expand Down
2 changes: 1 addition & 1 deletion neb/inc/com/centreon/misc/argument.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class argument {
char _name;
std::string _value;
};
} // namespace misc
}

CC_END()

Expand Down
Loading

0 comments on commit 18d2708

Please sign in to comment.