Commit graph

2125 commits

Author SHA1 Message Date
Julian Brost
4bd2222412
Merge pull request #9719 from Icinga/execvp
ProcessSpawnImpl(): use POSIX execvp(3), not own copy of GNU/OpenBSD-only execvpe(3)
2026-04-23 14:04:31 +02:00
Yonas Habteab
a01870a6aa Fix compiler crash on SLES 15.7 arm64 runner 2026-04-16 14:01:49 +02:00
Yonas Habteab
e4436cbcf0 IoEngine: introduce & use IsStrandRunningOnThisThread function 2026-04-15 17:51:17 +02:00
Yonas Habteab
ecf5632ef8 Timeout: lift VERIFY -> ASSERT to prevent crashes in release builds
`strand.running_in_this_thread()` relies on thread-local storage
internally, and may return false positives if the coroutine is resumed
in a different thread than it was suspended in. In debug builds, this is
not problem, since there's no TLS optimization done by the compiler, but
in release builds, the compiler might cache the address of the
thread-local variable read before the coroutine suspension, and thus
potentially reuse the same address in a different thread after
resumption, which would cause `running_in_this_thread()` to return false
or even crash (but we didn't see any crashes related to this). So,
perform the assertion only in debug builds to prevent potential wrong
usages of the `Timeout` class. For more details, see [^1][^2][^3].

[^1]: https://github.com/chriskohlhoff/asio/issues/1366
[^2]: https://bugs.llvm.org/show_bug.cgi?id=19177
[^3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26461
2026-04-15 17:25:14 +02:00
Yonas Habteab
374cc6e282 Cache Icinga DB env_id in Application class as well
So that other components can use it without having to import any Icinga
DB related header files, but only the base library.
2026-04-01 12:15:58 +02:00
Julian Brost
9d361e1fb3
Merge pull request #10734 from Icinga/deprecate-everything-we-dont-like
Schedule deprecated features for removal in v2.18
2026-03-31 10:25:44 +02:00
Johannes Schmidt
7d4af75189 Make ShowCodeLocation() show the full line with a LastColumn of 0 2026-03-24 13:53:31 +01:00
Alexander A. Klimov
85b16d2186 Remove unused IoEngine#m_AlreadyExpiredTimer 2026-03-19 14:53:29 +01:00
Alexander A. Klimov
7b45d8d625 Remove unused IoEngine::YieldCurrentCoroutine() 2026-03-19 14:53:29 +01:00
Alexander A. Klimov
cefa942c31 Make IoEngine#m_CpuBoundSemaphore unsigned 2026-03-19 14:53:29 +01:00
Alexander A. Klimov
06cfdbb650 CpuBoundWork#CpuBoundWork(): don't spin on atomic int to acquire slot
This is inefficient and involves possible bad surprises regarding
waiting durations on busy nodes. Instead, use `AsioConditionVariable#Wait()`
if there are no free slots. It's notified by others'
`CpuBoundWork#~CpuBoundWork()` once finished.
2026-03-19 14:53:29 +01:00
Alexander A. Klimov
c40c15ee11 Introduce AsioConditionVariable 2026-03-19 14:53:29 +01:00
Alexander A. Klimov
e03db5f71d [Refactor] CpuBoundWork#CpuBoundWork(): require an io_context::strand 2026-03-19 14:53:29 +01:00
Alexander A. Klimov
149aecf3b9 CpuBoundWork#~CpuBoundWork(): just call #Done() to deduplicate code 2026-03-19 14:53:29 +01:00
Alexander A. Klimov
844b341225 Remove unused IoBoundWorkSlot 2026-03-19 14:53:29 +01:00
Julian Brost
6592eae21d
Merge pull request #10668 from Icinga/perfdata-writers-connection-handling
Add PerfdatawriterConnection to handle network requests for Perfdata Writers
2026-03-17 15:10:57 +01:00
Johannes Schmidt
907f41bae4 Use perfect-forwarding references to prevent passing temporaries
Without this change, it is easy to pass a temporary, for example a vector
returned by a function to ParallelFor(). With this commit a type-constraint
is added to disable the use of this function for rvalue sequences.

An alternative would have been to capture rvalue-references in the function,
but that would have made the function unnecessarily complex, involving tuple-capture
and `shared_ptr`s, while it is usually easy to control lifetime at the call-site.
2026-03-13 13:14:52 +01:00
Johannes Schmidt
eb97638743 Make retrieval of the vector size more generic
This also enables the use of the function with "containers" that
don't have a size function but implement an overload for `std::size()`,
like c-arrays with fixed sizes.
2026-03-12 15:37:24 +01:00
Yonas Habteab
c1763e4753 ObjectLock: allow to TryLock the mutex 2026-03-02 15:36:59 +01:00
Johannes Schmidt
7955d04ae3 Import std::chrono_literals into icinga namespace 2026-02-26 13:31:10 +01:00
Johannes Schmidt
27c954dde8
Merge pull request #10715 from Icinga/fix-ubsan-errors
Some checks failed
Container Image / Container Image (push) Has been cancelled
Linux / alpine:bash (push) Has been cancelled
Linux / amazonlinux:2 (push) Has been cancelled
Linux / amazonlinux:2023 (push) Has been cancelled
Linux / debian:11 (linux/386) (push) Has been cancelled
Linux / debian:11 (push) Has been cancelled
Linux / debian:12 (linux/386) (push) Has been cancelled
Linux / debian:12 (push) Has been cancelled
Linux / debian:13 (push) Has been cancelled
Linux / fedora:41 (push) Has been cancelled
Linux / fedora:42 (push) Has been cancelled
Linux / fedora:43 (push) Has been cancelled
Linux / opensuse/leap:15.6 (push) Has been cancelled
Linux / opensuse/leap:16.0 (push) Has been cancelled
Linux / registry.suse.com/bci/bci-base:16.0 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.6 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.7 (push) Has been cancelled
Linux / rockylinux/rockylinux:10 (push) Has been cancelled
Linux / rockylinux:8 (push) Has been cancelled
Linux / rockylinux:9 (push) Has been cancelled
Linux / ubuntu:22.04 (push) Has been cancelled
Linux / ubuntu:24.04 (push) Has been cancelled
Linux / ubuntu:25.04 (push) Has been cancelled
Linux / ubuntu:25.10 (push) Has been cancelled
Windows / Windows (push) Has been cancelled
Fix undefined behavior discovered with `-fsanitize=undefined`
2026-02-19 08:38:40 +01:00
Yonas Habteab
32887884e5 Make ValueGenerator more flexible & easy to use
This commit refactors the ValueGenerator class to be a template that can
work with any container type. Previously, one has to manually take care
of the used container by lazily iterating over it within a lambda. Now,
the `ValueGenerator` class itself takes care of all the iteration,
making it easier to use and less error-prone. The new base `Generator`
class is required to allow the `JsonEncoder` to handle generators in a
type-erased manner.
2026-02-10 16:57:56 +01:00
Johannes Schmidt
216e2d9861 Fix uninitialized member in ScriptError 2026-02-06 12:10:20 +01:00
Alexander A. Klimov
56f8307c9a ProcessSpawnImpl(): outsource array build and Convert::ToString() to child 2026-02-05 14:31:04 +01:00
Alexander A. Klimov
c5c572c4a2 Remove unused execvpe(3) copy 2026-02-05 14:31:01 +01:00
Alexander A. Klimov
f6124f39a3 ProcessSpawnImpl(): use POSIX execvp(3), not GNU/OpenBSD-only execvpe(3)
Modify the fork(2)ed process' env in-place, then call execvp(3).
2026-02-05 14:30:42 +01:00
Yonas Habteab
91c7e60df8 Replace all existing copyright headers with SPDX headers
I've used the following command to replace the original copyright header
lines in a C-style comment block:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

For files that use shell-style comments (#) like CMakeLists.txt, I've
used this command:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

And for SQL files:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
2026-02-04 14:00:05 +01:00
Alexander Aleksandrovič Klimov
9bffe06169
Merge pull request #10388 from Icinga/Registry-Freeze
Some checks failed
Container Image / Container Image (push) Has been cancelled
Linux / alpine:bash (push) Has been cancelled
Linux / amazonlinux:2 (push) Has been cancelled
Linux / amazonlinux:2023 (push) Has been cancelled
Linux / debian:11 (linux/386) (push) Has been cancelled
Linux / debian:11 (push) Has been cancelled
Linux / debian:12 (linux/386) (push) Has been cancelled
Linux / debian:12 (push) Has been cancelled
Linux / debian:13 (push) Has been cancelled
Linux / fedora:41 (push) Has been cancelled
Linux / fedora:42 (push) Has been cancelled
Linux / fedora:43 (push) Has been cancelled
Linux / opensuse/leap:15.6 (push) Has been cancelled
Linux / opensuse/leap:16.0 (push) Has been cancelled
Linux / registry.suse.com/bci/bci-base:16.0 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.6 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.7 (push) Has been cancelled
Linux / rockylinux/rockylinux:10 (push) Has been cancelled
Linux / rockylinux:8 (push) Has been cancelled
Linux / rockylinux:9 (push) Has been cancelled
Linux / ubuntu:22.04 (push) Has been cancelled
Linux / ubuntu:24.04 (push) Has been cancelled
Linux / ubuntu:25.04 (push) Has been cancelled
Linux / ubuntu:25.10 (push) Has been cancelled
Windows / Windows (push) Has been cancelled
Freeze registries at startup, when everything has been registered
2026-01-26 17:28:43 +01:00
Alexander A. Klimov
74ac0183ca Registry<U,T>: remove unused template typename U 2026-01-26 10:24:22 +01:00
Alexander A. Klimov
4ba46f9eb2 Silence compiler warnings about unused parameters
Every of these parameters exists for a reason.
The best we can do is to convince the compiler.
2026-01-23 13:31:01 +01:00
Johannes Schmidt
1505f09ed6 Refactor HttpMessage into generalized templated types
This adds generalized IncomingHttpMessage and OutgoingHttpMessage templates
that support different types of streams (via a std::variant) and can both
be used for either requests or responses.

The tacked on metadata from the old HttpRequest and server connection from
the old HttpServerConnection have been moved to HttpApi(Request|Response)
classes that derive from the above generalized message types.
2026-01-22 17:20:32 +01:00
Yonas Habteab
0b2f22ce40 tlsutility: make cert ts configurable & use ASN1_TIME_compare for comparison 2025-12-04 13:01:48 +01:00
Brad Smith
bbc1859aa1 Have thread name length clamping also apply for the other OSes
This covers macOS, *BSDs, Linux, Cygwin.

NetBSD PTHREAD_MAX_NAMELEN_NP 32
macOS 64
OpenBSD 24
Linux/FreeBSD/DragonFly/Cygwin 16
2025-11-27 09:19:16 -05:00
Brad Smith
7aa777c40f Fix usage of pthread_setname_np() on NetBSD
NetBSD's pthread_setname_np() takes a slightly different set of parameters.
2025-11-27 07:16:34 -05:00
Alvar
8c230df3da
Merge pull request #10640 from brad0/openbsd_dlopen
Fix dlopen()'ing libraries on OpenBSD
2025-11-27 12:13:18 +00:00
Brad Smith
d243da72e5 Fix dlopen()'ing libraries on OpenBSD 2025-11-27 04:52:28 -05:00
Brad Smith
cf8fc3d64f
Add tests for pthread_set_name_np() and pthread_setname_np()
Looks like the conversion from autoconf to CMake dropped
these tests along the way.
2025-11-27 10:48:54 +01:00
Brad Smith
77881a7e18 Enable the pthread_np.h header on OpenBSD and DragonFly
Necessary for pthread_set_name_np().
2025-11-25 15:46:02 -05:00
Johannes Schmidt
a2e0ce426f Fix -Wunused-variable warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
7b4697a237 Fix -Wredundant-move warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
93e69ed0e8 Fix -Wsign-compare warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
758d1b6873 Fix -Wsuggest-override warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
4f0a24f8ab Add ABORT() macro for unconditionally failing ASSERTS
This is necessary to stop MSVC complaining that "not all paths return a value", because
it is not able to infer that the expression `false ? 0 : non_returning_function()`
never returns.

In the process of debugging this I've also slightly simplified the other assert macros and
abort function, so they don't need compiler specific preprocessor-paths anymore.
2025-11-19 11:55:49 +01:00
Alexander A. Klimov
68a8480251 Introduce Registry::GetInstance() to deduplicate such methods
in derived classes and inline them, as side effect, to speed up calls.
2025-11-07 18:01:38 +01:00
Alexander A. Klimov
2e3551e497 Introduce Registry#Freeze() 2025-11-07 18:01:38 +01:00
Alexander A. Klimov
496a65d0d0 Registry#Get*(): use shared locking to allow concurrent access 2025-11-07 18:01:38 +01:00
Alexander A. Klimov
7fc722e581 Make Registry#ItemMap a hash table to speed up lookups 2025-11-07 18:01:38 +01:00
Alexander A. Klimov
c3d9727133 Inline Registry#RegisterInternal() used only once 2025-11-07 18:01:38 +01:00
Alexander A. Klimov
87a2f9fade Remove unused Registry#OnRegistered 2025-11-07 18:01:38 +01:00
Alexander A. Klimov
0fb4e4d642 Remove unused Registry#OnUnregistered 2025-11-07 18:01:38 +01:00