Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


sd_event_source_set_ratelimit(3) — Linux manual page

NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |NOTES |HISTORY |SEE ALSO |COLOPHON

SD_EVEN...ATELIMIT(3) sd_event_source_set_ratelimitSD_EVEN...ATELIMIT(3)

NAME        top

       sd_event_source_set_ratelimit, sd_event_source_get_ratelimit,       sd_event_source_is_ratelimited,       sd_event_source_set_ratelimit_expire_callback,       sd_event_source_leave_ratelimit - Configure rate limiting on event       sources

SYNOPSIS        top

#include <systemd/sd-event.h>int sd_event_source_set_ratelimit(sd_event_source *source,uint64_tinterval_usec,unsignedburst);int sd_event_source_get_ratelimit(sd_event_source *source,uint64_t*ret_interval_usec,unsigned*ret_burst);int sd_event_source_is_ratelimited(sd_event_source *source);intsd_event_source_set_ratelimit_expire_callback(sd_event_source *source,sd_event_handler_tcallback);int sd_event_source_leave_ratelimit(sd_event_source *source);

DESCRIPTION        top

sd_event_source_set_ratelimit()may be used to enforce rate       limiting on an event source. When used an event source will be       temporarily turned off when it fires more often then a specified       burst number within a specified time interval. This is useful as       simple mechanism to avoid event source starvation if high priority       event sources fire very frequently.       Pass the event source to operate on as first argument, a time       interval in microseconds as second argument and a maximum dispatch       limit ("burst") as third parameter. Whenever the event source is       dispatched more often than the specified burst within the       specified interval it is placed in a mode similar to being       disabled withsd_event_source_set_enabled(3) and theSD_EVENT_OFF       parameter. However, it is disabled only temporarily – once the       specified interval is over regular operation resumes. It is again       disabled temporarily once the specified rate limiting is hit the       next time. If either the interval or the burst value are specified       as zero, rate limiting is turned off. By default, event sources do       not have rate limiting enabled. Note that rate limiting and       disabling viasd_event_source_set_enabled()are independent of       each other, and an event source will only effect event loop       wake-ups and is dispatched while it both is enabled and rate       limiting is not in effect.sd_event_source_get_ratelimit()may be used to query the current       rate limiting parameters set on the event source objectsource.       The previously set interval and burst vales are returned in the       second and third argument.sd_event_source_is_ratelimited()may be used to query whether the       event source is currently affected by rate limiting, i.e. it has       recently hit the rate limit and is currently temporarily disabled       due to that.sd_event_source_set_ratelimit_expire_callback()may be used to set       a callback function that is invoked every time the event source       leaves rate limited state. Note that function is called in the       same event loop iteration in which state transition occurred.sd_event_source_leave_ratelimit()may be used to immediately       reenable an event source that was temporarily disabled due to rate       limiting. This will reset the ratelimit counters for the current       time interval.       Rate limiting is currently implemented for I/O, timer, signal,       defer and inotify event sources.

RETURN VALUE        top

       On success,sd_event_source_set_ratelimit(),sd_event_source_set_ratelimit_expire_callbackandsd_event_source_get_ratelimit()return a non-negative integer. On       failure, they return a negative errno-style error code.sd_event_source_is_ratelimited()returns zero if rate limiting is       currently not in effect and greater than zero if it is in effect;       it returns a negative errno-style error code on failure.sd_event_source_leave_ratelimit()returns zero if rate limiting       was not in effect on the specified event source, and positive if       it was and rate limiting is now turned off again; it returns a       negative errno-style error code on failure.Errors       Returned errors may indicate the following problems:-EINVALsource is not a valid pointer to an sd_event_source object.           Added in version 248.-ECHILD           The event loop has been created in a different process,           library or module instance.           Added in version 248.-EDOM           It was attempted to use the rate limiting feature on an event           source type that does not support rate limiting.           Added in version 248.-ENOEXECsd_event_source_get_ratelimit()was called on an event source           that does not have rate limiting configured.           Added in version 248.

NOTES        top

       Functions described here are available as a shared library, which       can be compiled against and linked to with thelibsystemd pkg-config(1) file.       The code described here usesgetenv(3), which is declared to be       not multi-thread-safe. This means that the code calling the       functions described here must not callsetenv(3) from a parallel       thread. It is recommended to only do calls tosetenv()from an       early phase of the program when no other threads have been       started.

HISTORY        top

sd_event_source_set_ratelimit(),sd_event_source_get_ratelimit(),       andsd_event_source_is_ratelimited()were added in version 248.sd_event_source_set_ratelimit_expire_callback()was added in       version 250.sd_event_source_leave_ratelimit()was added in version 254.

SEE ALSO        top

sd-event(3),sd_event_add_io(3),sd_event_add_time(3),sd_event_add_signal(3),sd_event_add_inotify(3),sd_event_add_defer(3),sd_event_source_set_enabled(3)

COLOPHON        top

       This page is part of thesystemd (systemd system and service       manager) project.  Information about the project can be found at       ⟨http://www.freedesktop.org/wiki/Software/systemd⟩.  If you have a       bug report for this manual page, see       ⟨http://www.freedesktop.org/wiki/Software/systemd/#bugreports⟩.       This page was obtained from the project's upstream Git repository       ⟨https://github.com/systemd/systemd.git⟩ on 2025-08-11.  (At that       time, the date of the most recent commit that was found in the       repository was 2025-08-11.)  If you discover any rendering       problems in this HTML version of the page, or you believe there is       a better or more up-to-date source for the page, or you have       corrections or improvements to the information in this COLOPHON       (which isnot part of the original manual page), send a mail to       man-pages@man7.orgsystemd 258~rc2SD_EVEN...ATELIMIT(3)

Pages that refer to this page:sd-event(3)sd_event_source_set_enabled(3)systemd.directives(7)systemd.index(7)



HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp