|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
From df25afd2cf5527fe1bb542bb146fef1be8d9a489 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
From: Lennart Poettering <lennart@poettering.net>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Date: Sat, 9 Sep 2023 14:46:32 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Subject: [PATCH 1/3] core: add new "PollLimit" settings to .socket units
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
This adds a new "PollLimit" pair of settings to .socket units, very
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
similar to existing "TriggerLimit" logic. The differences are:
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
* PollLimit focusses on the polling on the sockets, and pauses that
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
temporarily if a ratelimit on that is reached. TriggerLimit otoh
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
focusses on the triggering effect of socket units, and stops
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
triggering once the ratelimit is hit.
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
* While the trigger limit being hit is an action that causes the socket
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
unit to fail the polling limit being reached will just temporarily
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
disable polling on the socket fd, and it is resumed once the ratelimit
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
interval is over.
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
* When a socket unit operates on multiple socket fds (e,g, ListenStream=
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
on both some ipv6 and an ipv4 address or so). Then the PollLimit will
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
be specific to each fd, while the trigger limit is specific to the
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
whole unit.
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Implementation-wise this is mostly a wrapper around sd-event's
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
sd_event_source_set_ratelimit(), which exposes the desired behaviour
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
directly.
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Usecase for all of this: socket services which when overloaded with
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
connections should just slow down reception of it, but not fail
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
persistently.
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
(cherry picked from commit 2bec84e7a5bf3687ae65205753ba3d8067cf2f0e)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
---
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
man/org.freedesktop.systemd1.xml | 12 ++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
src/core/dbus-socket.c | 8 +++++++
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
src/core/load-fragment-gperf.gperf.in | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
src/core/socket.c | 32 +++++++++++++++++++--------
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
src/core/socket.h | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
src/shared/bus-unit-util.c | 10 +++++----
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
6 files changed, 53 insertions(+), 13 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
diff --git a/man/org.freedesktop.systemd1.xml b/man/org.freedesktop.systemd1.xml
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
index 56906e2f3b..0557dc2379 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
--- a/man/org.freedesktop.systemd1.xml
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+++ b/man/org.freedesktop.systemd1.xml
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -4727,6 +4727,10 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
readonly t TriggerLimitIntervalUSec = ...;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
readonly u TriggerLimitBurst = ...;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ readonly t PollLimitIntervalUSec = ...;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ readonly u PollLimitBurst = ...;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
readonly u UID = ...;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
readonly u GID = ...;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@org.freedesktop.DBus.Property.EmitsChangedSignal("invalidates")
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -5961,6 +5965,10 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
<variablelist class="dbus-property" generated="True" extra-ref="TriggerLimitBurst"/>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ <variablelist class="dbus-property" generated="True" extra-ref="PollLimitIntervalUSec"/>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ <variablelist class="dbus-property" generated="True" extra-ref="PollLimitBurst"/>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
<variablelist class="dbus-property" generated="True" extra-ref="UID"/>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
<variablelist class="dbus-property" generated="True" extra-ref="GID"/>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -6497,6 +6505,10 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2esocket {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ <para><varname>PollLimitIntervalUSec</varname>/<varname>PollLimitBurst</varname> properties configure the
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ polling limit for the socket unit. Expects a time in µs, resp. an unsigned integer. If either is set to
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ zero the limiting feature is turned off.</para>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
<refsect2>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
<title>Properties</title>
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
index 09a3a9502b..04552b7c60 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
--- a/src/core/dbus-socket.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+++ b/src/core/dbus-socket.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -129,6 +129,8 @@ const sd_bus_vtable bus_socket_vtable[] = {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
SD_BUS_PROPERTY("SocketProtocol", "i", bus_property_get_int, offsetof(Socket, socket_protocol), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
SD_BUS_PROPERTY("TriggerLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Socket, trigger_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
SD_BUS_PROPERTY("TriggerLimitBurst", "u", bus_property_get_unsigned, offsetof(Socket, trigger_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ SD_BUS_PROPERTY("PollLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Socket, poll_limit_interval), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ SD_BUS_PROPERTY("PollLimitBurst", "u", bus_property_get_unsigned, offsetof(Socket, poll_limit_burst), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
SD_BUS_PROPERTY("UID", "u", bus_property_get_uid, offsetof(Unit, ref_uid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
SD_BUS_PROPERTY("GID", "u", bus_property_get_gid, offsetof(Unit, ref_gid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
BUS_EXEC_COMMAND_LIST_VTABLE("ExecStartPre", offsetof(Socket, exec_command[SOCKET_EXEC_START_PRE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -248,6 +250,9 @@ static int bus_socket_set_transient_property(
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (streq(name, "TriggerLimitBurst"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_set_transient_unsigned(u, name, &s->trigger_limit.burst, message, flags, error);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (streq(name, "PollLimitBurst"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ return bus_set_transient_unsigned(u, name, &s->poll_limit_burst, message, flags, error);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (streq(name, "SocketMode"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_set_transient_mode_t(u, name, &s->socket_mode, message, flags, error);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -275,6 +280,9 @@ static int bus_socket_set_transient_property(
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (streq(name, "TriggerLimitIntervalUSec"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_set_transient_usec(u, name, &s->trigger_limit.interval, message, flags, error);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (streq(name, "PollLimitIntervalUSec"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ return bus_set_transient_usec(u, name, &s->poll_limit_interval, message, flags, error);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (streq(name, "SmackLabel"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_set_transient_string(u, name, &s->smack, message, flags, error);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
diff --git a/src/core/load-fragment-gperf.gperf.in b/src/core/load-fragment-gperf.gperf.in
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
index b66adf2811..0d1ee9c231 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
--- a/src/core/load-fragment-gperf.gperf.in
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+++ b/src/core/load-fragment-gperf.gperf.in
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -507,6 +507,8 @@ Socket.FileDescriptorName, config_parse_fdname,
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Socket.Service, config_parse_socket_service, 0, 0
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Socket.TriggerLimitIntervalSec, config_parse_sec, 0, offsetof(Socket, trigger_limit.interval)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Socket.TriggerLimitBurst, config_parse_unsigned, 0, offsetof(Socket, trigger_limit.burst)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+Socket.PollLimitIntervalSec, config_parse_sec, 0, offsetof(Socket, poll_limit_interval)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+Socket.PollLimitBurst, config_parse_unsigned, 0, offsetof(Socket, poll_limit_burst)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
{% if ENABLE_SMACK %}
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Socket.SmackLabel, config_parse_unit_string_printf, 0, offsetof(Socket, smack)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
Socket.SmackLabelIPIn, config_parse_unit_string_printf, 0, offsetof(Socket, smack_ip_in)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
diff --git a/src/core/socket.c b/src/core/socket.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
index 75034ac357..dc18744f54 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
--- a/src/core/socket.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+++ b/src/core/socket.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -101,6 +101,9 @@ static void socket_init(Unit *u) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
s->trigger_limit.interval = USEC_INFINITY;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
s->trigger_limit.burst = UINT_MAX;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ s->poll_limit_interval = USEC_INFINITY;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ s->poll_limit_burst = UINT_MAX;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
}
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
static void socket_unwatch_control_pid(Socket *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -310,17 +313,20 @@ static int socket_add_extras(Socket *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
* off the queues, which it might not necessarily do. Moreover, while Accept=no services are supposed to
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
* process whatever is queued in one go, and thus should normally never have to be started frequently. This is
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
* different for Accept=yes where each connection is processed by a new service instance, and thus frequent
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- * service starts are typical. */
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ * service starts are typical.
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ *
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ * For the poll limit we follow a similar rule, but use 3/4th of the trigger limit parameters, to
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ * trigger this earlier. */
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (s->trigger_limit.interval == USEC_INFINITY)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
s->trigger_limit.interval = 2 * USEC_PER_SEC;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (s->trigger_limit.burst == UINT_MAX)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ s->trigger_limit.burst = s->accept ? 200 : 20;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- if (s->trigger_limit.burst == UINT_MAX) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- if (s->accept)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- s->trigger_limit.burst = 200;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- else
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- s->trigger_limit.burst = 20;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- }
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (s->poll_limit_interval == USEC_INFINITY)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ s->poll_limit_interval = 2 * USEC_PER_SEC;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (s->poll_limit_burst == UINT_MAX)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ s->poll_limit_burst = s->accept ? 150 : 15;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (have_non_accept_socket(s)) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -770,9 +776,13 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
fprintf(f,
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"%sTriggerLimitIntervalSec: %s\n"
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- "%sTriggerLimitBurst: %u\n",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "%sTriggerLimitBurst: %u\n"
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "%sPollLimitIntervalSec: %s\n"
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "%sPollLimitBurst: %u\n",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
prefix, FORMAT_TIMESPAN(s->trigger_limit.interval, USEC_PER_SEC),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- prefix, s->trigger_limit.burst);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ prefix, s->trigger_limit.burst,
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ prefix, FORMAT_TIMESPAN(s->poll_limit_interval, USEC_PER_SEC),
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ prefix, s->poll_limit_burst);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
str = ip_protocol_to_name(s->socket_protocol);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (str)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -1765,6 +1775,10 @@ static int socket_watch_fds(Socket *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
(void) sd_event_source_set_description(p->event_source, "socket-port-io");
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
}
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ r = sd_event_source_set_ratelimit(p->event_source, s->poll_limit_interval, s->poll_limit_burst);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ log_unit_debug_errno(UNIT(s), r, "Failed to set poll limit on I/O event source, ignoring: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
}
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
diff --git a/src/core/socket.h b/src/core/socket.h
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
index 191d27f46d..b03a291e4a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
--- a/src/core/socket.h
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+++ b/src/core/socket.h
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -158,6 +158,8 @@ struct Socket {
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
char *fdname;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
RateLimit trigger_limit;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ usec_t poll_limit_interval;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ unsigned poll_limit_burst;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
};
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
SocketPeer *socket_peer_ref(SocketPeer *p);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
index e7b44cc39b..9f0f37488d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
--- a/src/shared/bus-unit-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+++ b/src/shared/bus-unit-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -2170,10 +2170,10 @@ static int bus_append_path_property(sd_bus_message *m, const char *field, const
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return 1;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
}
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- if (streq(field, "TriggerLimitBurst"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (STR_IN_SET(field, "TriggerLimitBurst", "PollLimitBurst"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_append_safe_atou(m, field, eq);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- if (streq(field, "TriggerLimitIntervalSec"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ if (STR_IN_SET(field, "TriggerLimitIntervalSec", "PollLimitIntervalSec"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_append_parse_sec_rename(m, field, eq);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -2382,7 +2382,8 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"MaxConnections",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"MaxConnectionsPerSource",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"KeepAliveProbes",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- "TriggerLimitBurst"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "TriggerLimitBurst",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "PollLimitBurst"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_append_safe_atou(m, field, eq);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (STR_IN_SET(field, "SocketMode",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
@@ -2397,7 +2398,8 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"KeepAliveTimeSec",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"KeepAliveIntervalSec",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
"DeferAcceptSec",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
- "TriggerLimitIntervalSec"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "TriggerLimitIntervalSec",
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
+ "PollLimitIntervalSec"))
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
return bus_append_parse_sec_rename(m, field, eq);
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
|
|
Zbigniew Jędrzejewski-Szmek |
bb2f5f |
if (STR_IN_SET(field, "ReceiveBuffer",
|