Commit graph

11 commits

Author SHA1 Message Date
David Lamparter ff76fb21d7 lib: improve late timer warnings
Refactor the "timer getting executed too late" warning:

- warning threshold is now adjustable
- check is performed when event actually executes, rather than when it's
  thrown on ready list
- ignore_late_timer replaced with threshold = 0
- system load averages printed in log message
- warning ratelimited to once per 10s rather than once per poll()

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-02-11 12:16:08 +01:00
David Lamparter cae176e10a lib: fix use after free in clear event cpu
Freeing any item here means freeing someone's `event->hist`, leaving a
dangling pointer there.  Which will immediately be written to because
we're executing in a CLI function under the `vty_read` event, whose
`event->hist` is then updated.

Deallocating `event->hist` anywhere other than shutting down the whole
event loop is a bad idea to begin with, just zero out the stats instead.

Fixes: FRRouting/frr#16419
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 16:40:25 +01:00
Donald Sharp cd80fa0af4 lib: Remove counter and a function
The `alloc` counter was tracking the current active
number of events in the system and if it went to
0 when freeing a new one it would assert.  This
assert is a duplicate of what would happen with the
XFREE in the same situation.  As such it is not
necessary.

Also remove the `event_master_free_unused` function
from the system.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 14:07:04 -04:00
Donatas Abraitis f03b0bfaa4 lib: Fix unknown sig_atomic_t compile error
This is happening for Alpine Linux.

```
26 64.59 ./lib/sigevent.h:23:18: error: unknown type name 'sig_atomic_t'
26 64.59    23 |         volatile sig_atomic_t caught; /* private member   */
26 64.59       |                  ^~~~~~~~~~~~
26 64.60 In file included from ./lib/libfrr.h:12,
26 64.60                  from ./lib/vty.h:28,
26 64.60                  from ./lib/command.h:11,
26 64.60                  from ./lib/debug.h:11,
26 64.60                  from ./mgmtd/mgmt.h:12,
26 64.60                  from mgmtd/mgmt_history.c:14:
26 64.60 ./lib/sigevent.h:23:18: error: unknown type name 'sig_atomic_t'
26 64.60    23 |         volatile sig_atomic_t caught; /* private member   */
26 64.60       |                  ^~~~~~~~~~~~
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-09 09:33:00 +02:00
Igor Ryzhov 057f442309 lib, mgmtd: remove function duplication
And also remove lib dependency on mgmtd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-17 11:27:03 +01:00
Donald Sharp 57ea8ac8c3 lib: Modify event system to treat fd access more fairly
Keep track of the last starting spot of where fd's were
being handled for read operations.  Modify the io read
handler to cycle through the list of fd's that need
to be handled such that fd's at the front do not take
precedence for being handled all the time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-08 15:32:56 -05:00
Donatas Abraitis fd0fe0bb6a lib: Drop deprecated enable-time-check, enable-cpu-time compile options
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-24 20:41:24 +03:00
David Lamparter 3d1a678e24 lib: fix delete during hash_iterate() in event_*
... by converting the hash table to a typesafe hash.

Honestly I was just looking around for things to convert to the typesafe
hash table code, but then I noticed that cpu_record_clear() deletes
items from inside the hash_iterate() callback :(

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-07 17:19:39 +02:00
Mark Stapp adca5c22c5 * : include event ptr in event_execute api
Include an event ptr-to-ptr in the event_execute() api
call, like the various schedule api calls. This allows the
execute() api to cancel an existing scheduled task if that
task is being executed inline.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-07-25 10:17:48 -04:00
Donald Sharp 02e701e49e *: Fixup formatting issues due to reordering
All the event changes exposed a bunch of places where
we were not properly following our standards.  Just
clean them up in one big fell swoop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:37:21 -04:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Renamed from lib/event.h (Browse further)