aboutsummaryrefslogtreecommitdiffstats
path: root/src/wayland-client-core.h
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2021-09-25 22:34:44 -0400
committerSimon Ser <contact@emersion.fr>2024-04-08 14:05:32 +0000
commitd074d52902633d8700ce06b484508db0f8fba02b (patch)
tree49015264f1a2cbf3b766f6d0802fae3be80378b6 /src/wayland-client-core.h
parentutil: convert macros to inline functions (diff)
downloadwayland-d074d52902633d8700ce06b484508db0f8fba02b.tar
wayland-d074d52902633d8700ce06b484508db0f8fba02b.tar.gz
wayland-d074d52902633d8700ce06b484508db0f8fba02b.tar.bz2
wayland-d074d52902633d8700ce06b484508db0f8fba02b.tar.lz
wayland-d074d52902633d8700ce06b484508db0f8fba02b.tar.xz
wayland-d074d52902633d8700ce06b484508db0f8fba02b.tar.zst
wayland-d074d52902633d8700ce06b484508db0f8fba02b.zip
connection: Dynamically resize connection buffers
When using fixed size connection buffers, if either the client or the server is sending requests faster than the other end can cope with, the connection buffers will fill up, eventually killing the connection. This can be a problem for example with Xwayland mapping a lot of windows, faster than the Wayland compositor can cope with, or a high-rate mouse flooding the Wayland client with pointer events. To avoid the issue, resize the connection buffers dynamically when they get full. Both data and fd buffers are resized on demand. The default max buffer size is controlled via the wl_display interface while each client's connection buffer size is adjustable for finer control. The purpose is to explicitly have larger connection buffers for specific clients such as Xwayland, or set a larger buffer size for the client with pointer focus to deal with a higher input events rate. v0: Manuel: Dynamically resize connection buffers - Both data and fd buffers are resized on demand. v1: Olivier 1. Add support for unbounded buffers on the client side and growable (yet limited) connection buffers on the server side. 2. Add the API to set the default maximum size and a limit for a given client. 3. Add tests for growable connection buffers and adjustable limits. v2: Additional fixes by John: 1. Fix the size calculation in ring_buffer_check_space() 2. Fix wl_connection_read() to return gracefully once it has read up to the max buffer size, rather than returning an error. 3. If wl_connection_flush() fails with EAGAIN but the transmit ring-buffer has space remaining (or can be expanded), wl_connection_queue() should store the message rather than returning an error. 4. When the receive ring-buffer is at capacity but more data is available to be read, wl_connection_read() should attempt to expand the ring-buffer in order to read the remaining data. v3: Thomas Lukaszewicz <tluk@chromium.org> Add a test for unbounded buffers v4: Add a client API as well to force bounded buffers (unbounded by default (Olivier) v5: Simplify ring_buffer_ensure_space() (Sebastian) Co-authored-by: Olivier Fourdan <ofourdan@redhat.com> Co-authored-by: John Lindgren <john@jlindgren.net> Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net> Signed-off-by: Manuel Stoeckl <code@mstoeckl.com> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: John Lindgren <john@jlindgren.net> Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net> Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/237
Diffstat (limited to 'src/wayland-client-core.h')
-rw-r--r--src/wayland-client-core.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/wayland-client-core.h b/src/wayland-client-core.h
index 20b2a3b..a9d620e 100644
--- a/src/wayland-client-core.h
+++ b/src/wayland-client-core.h
@@ -298,6 +298,10 @@ wl_display_read_events(struct wl_display *display);
void
wl_log_set_handler_client(wl_log_func_t handler);
+void
+wl_display_set_max_buffer_size(struct wl_display *display,
+ size_t max_buffer_size);
+
#ifdef __cplusplus
}
#endif