summaryrefslogtreecommitdiff
path: root/src/systemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-11-23 18:02:40 +0100
committerLennart Poettering <lennart@poettering.net>2020-12-01 15:11:24 +0100
commitb6d5481b3d9f7c9b1198ab54b54326ec73e855bf (patch)
tree2a2f4b4416272b96e0e86ccb1ec9ad63ac5d47c2 /src/systemd
parentf41315fceb5208c496145cda2d6c865a5458ce44 (diff)
downloadsystemd-b6d5481b3d9f7c9b1198ab54b54326ec73e855bf.tar.gz
sd-event: add ability to ratelimit event sources
Let's a concept of "rate limiting" to event sources: if specific event sources fire too often in some time interval temporarily take them offline, and take them back online once the interval passed. This is a simple scheme of avoiding starvation of event sources if some event source fires too often. This introduces the new conceptual states of "offline" and "online" for event sources: an event source is "online" only when enabled *and* not ratelimited, and offline in all other cases. An event source that is online hence has its fds registered in the epoll, its signals in the signalfd and so on.
Diffstat (limited to 'src/systemd')
-rw-r--r--src/systemd/sd-event.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
index 937c9bd460..2ae2a0da48 100644
--- a/src/systemd/sd-event.h
+++ b/src/systemd/sd-event.h
@@ -162,6 +162,9 @@ int sd_event_source_get_floating(sd_event_source *s);
int sd_event_source_set_floating(sd_event_source *s, int b);
int sd_event_source_get_exit_on_failure(sd_event_source *s);
int sd_event_source_set_exit_on_failure(sd_event_source *s, int b);
+int sd_event_source_set_ratelimit(sd_event_source *s, uint64_t interval_usec, unsigned burst);
+int sd_event_source_get_ratelimit(sd_event_source *s, uint64_t *ret_interval_usec, unsigned *ret_burst);
+int sd_event_source_is_ratelimited(sd_event_source *s);
/* Define helpers so that __attribute__((cleanup(sd_event_unrefp))) and similar may be used. */
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_event, sd_event_unref);