1SD_EVENT_SOURCE_SET_RATELIsMdI_Te(v3e)nt_source_set_raStDe_lEiVmEiNtT_SOURCE_SET_RATELIMIT(3)
2
3
4

NAME

6       sd_event_source_set_ratelimit, sd_event_source_get_ratelimit,
7       sd_event_source_is_ratelimited - Configure rate limiting on event
8       sources
9

SYNOPSIS

11       #include <systemd/sd-event.h>
12
13       int sd_event_source_set_ratelimit(sd_event_source *source,
14                                         uint64_t interval_usec,
15                                         unsigned burst);
16
17       int sd_event_source_get_ratelimit(sd_event_source *source,
18                                         uint64_t* ret_interval_usec,
19                                         unsigned* ret_burst);
20
21       int sd_event_source_is_ratelimited(sd_event_source *source);
22

DESCRIPTION

24       sd_event_source_set_ratelimit() may be used to enforce rate limiting on
25       an event source. When used an event source will be temporarily turned
26       off when it fires more often then a specified burst number within a
27       specified time interval. This is useful as simple mechanism to avoid
28       event source starvation if high priority event sources fire very
29       frequently.
30
31       Pass the event source to operate on as first argument, a time interval
32       in microseconds as second argument and a maximum dispatch limit
33       ("burst") as third parameter. Whenever the event source is dispatched
34       more often than the specified burst within the specified interval it is
35       placed in a mode similar to being disabled with
36       sd_event_source_set_enabled(3) and the SD_EVENT_OFF parameter. However
37       it is disabled only temporarily – once the specified interval is over
38       regular operation resumes. It is again disabled temporarily once the
39       specified rate limiting is hit the next time. If either the interval or
40       the burst value are specified as zero, rate limiting is turned off. By
41       default event sources do not have rate limiting enabled. Note that rate
42       limiting and disabling via sd_event_source_set_enabled() are
43       independent of each other, and an event source will only effect event
44       loop wake-ups and is dispatched while it both is enabled and rate
45       limiting is not in effect.
46
47       sd_event_source_get_ratelimit() may be used to query the current rate
48       limiting parameters set on the event source object source. The
49       previously set interval and burst vales are returned in the second and
50       third argument.
51
52       sd_event_source_is_ratelimited() may be used to query whether the event
53       source is currently affected by rate limiting, i.e. it has recently hit
54       the rate limit and is currently temporarily disabled due to that.
55
56       Rate limiting is currently implemented for I/O, timer, signal, defer
57       and inotify event sources.
58

RETURN VALUE

60       On success, sd_event_source_set_ratelimit() and
61       sd_event_source_get_ratelimit() return a non-negative integer. On
62       failure, they return a negative errno-style error code.
63       sd_event_source_is_ratelimited returns zero if rate limiting is
64       currently not in effect and greater than zero if it is in effect; it
65       returns a negative errno-style error code on failure.
66
67   Errors
68       Returned errors may indicate the following problems:
69
70       -EINVAL
71           source is not a valid pointer to an sd_event_source object.
72
73       -ECHILD
74           The event loop has been created in a different process.
75
76       -EDOM
77           It was attempted to use the rate limiting feature on an event
78           source type that does not support rate limiting.
79
80       -ENOEXEC
81           sd_event_source_get_ratelimit() was called on a event source that
82           doesn't have rate limiting configured.
83

NOTES

85       These APIs are implemented as a shared library, which can be compiled
86       and linked to with the libsystemd pkg-config(1) file.
87

SEE ALSO

89       sd-event(3), sd_event_add_io(3), sd_event_add_time(3),
90       sd_event_add_signal(3), sd_event_add_inotify(3), sd_event_add_defer(3),
91       sd_event_source_set_enabled(3)
92
93
94
95systemd 248                                   SD_EVENT_SOURCE_SET_RATELIMIT(3)
Impressum