From: Zbigniew Jędrzejewski-Szmek Date: Wed, 29 Apr 2026 09:00:00 +0000 (+0200) Subject: sd-varlink: reduce size of varlink structs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=242fca7516eeedb3157be47be83f608d56592a46;p=thirdparty%2Fsystemd.git sd-varlink: reduce size of varlink structs struct sd_varlink: - /* size: 448, cachelines: 7, members: 21 */ + /* size: 432, cachelines: 7, members: 21 */ struct sd_varlink_server: - /* size: 160, cachelines: 3, members: 21 */ + /* size: 152, cachelines: 3, members: 21 */ --- diff --git a/src/libsystemd/sd-varlink/varlink-internal.h b/src/libsystemd/sd-varlink/varlink-internal.h index ff359852f48..32d6d5983a7 100644 --- a/src/libsystemd/sd-varlink/varlink-internal.h +++ b/src/libsystemd/sd-varlink/varlink-internal.h @@ -74,9 +74,8 @@ typedef enum VarlinkState { typedef struct sd_varlink { unsigned n_ref; - sd_varlink_server *server; - VarlinkState state; + sd_varlink_server *server; /* Transport layer: input/output buffers, fd passing, output queue, read/write/parse * step functions, sd-event integration (input/output/time event sources, idle @@ -87,6 +86,13 @@ typedef struct sd_varlink { unsigned n_pending; + /* Per-call protocol-upgrade marker: set when the *current* method call carries the + * SD_VARLINK_METHOD_UPGRADE flag. Validated by sd_varlink_reply_and_upgrade() to + * ensure the caller's contract is honored. The transport-layer "stop reading at the + * next message boundary" behavior is governed independently by the JsonStream's + * bounded_reads flag. */ + bool protocol_upgrade; + sd_varlink_reply_t reply_callback; sd_json_variant *current; @@ -102,13 +108,6 @@ typedef struct sd_varlink { size_t n_previous_fds; char *sentinel; - /* Per-call protocol-upgrade marker: set when the *current* method call carries the - * SD_VARLINK_METHOD_UPGRADE flag. Validated by sd_varlink_reply_and_upgrade() to - * ensure the caller's contract is honored. The transport-layer "stop reading at the - * next message boundary" behavior is governed independently by the JsonStream's - * bounded_reads flag. */ - bool protocol_upgrade; - void *userdata; sd_event_source *quit_event_source; @@ -145,8 +144,12 @@ typedef struct sd_varlink_server { sd_event *event; int64_t event_priority; - unsigned n_connections; Hashmap *by_uid; /* UID_TO_PTR(uid) → UINT_TO_PTR(n_connections) */ + unsigned n_connections; + unsigned connections_max; + unsigned connections_per_uid_max; + + bool exit_on_idle; void *userdata; @@ -155,11 +158,6 @@ typedef struct sd_varlink_server { char *product; char *version; char *url; - - unsigned connections_max; - unsigned connections_per_uid_max; - - bool exit_on_idle; } sd_varlink_server; #define varlink_log_errno(v, error, fmt, ...) \