This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-10-quiet-head
in repository terminology.
View the commit online.
commit 4d9dfe670a1d1a360d05e5316cb853214661ba54
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 20 03:36:10 2026 -0600
tytest: check the busy page reply really waits in the queue
tymux_live_pages_busy passed without ever checking that the PAGE reply
queued behind unsent output. On a host with a larger socket buffer the
flood would fit in it and the test would stop exercising the queue.
tymuxd now appends how many bytes a PAGE reply waits behind to the file
named by TYMUXD_PAGE_QUEUE_LOG, if set, and the test requires at least
64 KiB. A file, because the daemon has no stderr and a BINARY_TYTEST
counter in tymuxd cannot be read by tytest. The client cannot tell
queued bytes from those in the socket buffer, so the daemon has to say.
The test floods and asks again, round after round, until the daemon logs
64 KiB, so it does not depend on the host socket buffer size. Without
the floods the daemon logs 0 and the test fails. Shrinking the client
SO_RCVBUF made no difference (unix stream sockets are limited by the
sender's buffer), so the test does not set it.
---
DEV.md | 8 ++++++
src/bin/termd_tymux.c | 32 ++++++++++++++++++++++++
src/bin/tytest_tymux.c | 67 ++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 100 insertions(+), 7 deletions(-)
diff --git a/DEV.md b/DEV.md
index d3eb4a08..da1ba55f 100644
--- a/DEV.md
+++ b/DEV.md
@@ -54,3 +54,11 @@ The shot engine can only be chosen through `ELM_ENGINE`. `ELM_DISPLAY`
names a display system (`x11`, `wl`, `fb`, `buffer`) rather than a
renderer; `ELM_DISPLAY=buffer` renders off-screen but writes no image.
Elementary ignores `ECORE_EVAS_ENGINE`.
+
+# Page reply queue log
+
+If `TYMUXD_PAGE_QUEUE_LOG` names a file, tymuxd appends a line `page queued
+behind N` to it for each PAGE reply it queues, N being the bytes of output
+already waiting for that client. It exists only for the live tests, which
+use it to check that a reply really waits in the queue. Do not set it
+otherwise.
diff --git a/src/bin/termd_tymux.c b/src/bin/termd_tymux.c
index 94bda4e5..f13f68d1 100644
--- a/src/bin/termd_tymux.c
+++ b/src/bin/termd_tymux.c
@@ -458,6 +458,37 @@ _client_page_hold(Client *client, uint32_t page_id)
static void _client_page_release(Client *client, uint32_t page_id);
+/* If TYMUXD_PAGE_QUEUE_LOG names a file, append to it how many bytes of
+ * output a PAGE reply waits behind. The daemon has no stderr to log to, and
+ * the live tests have to see that a reply really queued, which no client
+ * can tell from the bytes it receives: the socket buffer holds some of
+ * them too. */
+static void
+_client_page_queue_log(size_t bytes_ahead)
+{
+ static const char *path;
+ static Eina_Bool looked_up;
+ char line[48];
+ int fd, len;
+
+ if (!looked_up)
+ {
+ path = getenv("TYMUXD_PAGE_QUEUE_LOG");
+ looked_up = EINA_TRUE;
+ }
+
+ if (!path)
+ return;
+ fd = open(path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0600);
+ if (fd < 0)
+ return;
+ len = snprintf(line, sizeof(line), "page queued behind %zu\n",
+ bytes_ahead);
+ if (write(fd, line, len) < 0)
+ WRN("could not write '%s': %s", path, strerror(errno));
+ close(fd);
+}
+
/* Queue the reply in the output, ahead of what comes later, with a duplicate
* of the page memfd that _client_flush() passes along with it, so that a
* full socket only delays the page. Returns EINA_FALSE if it was not
@@ -499,6 +530,7 @@ _client_page_fd_send(Client *client, const TermSrvMsgBacklogPageId *reply,
* queued may be gone when that returns */
queued->offset = eina_binbuf_length_get(client->out);
queued->length = length;
+ _client_page_queue_log(queued->offset);
client->queued_fds = eina_list_append(client->queued_fds, queued);
if (!_client_send(client, TSRV_MSG_BACKLOG_PAGE, reply, sizeof(*reply)))
{
diff --git a/src/bin/tytest_tymux.c b/src/bin/tytest_tymux.c
index 6b6b7910..3c6fcd35 100644
--- a/src/bin/tytest_tymux.c
+++ b/src/bin/tytest_tymux.c
@@ -27,6 +27,7 @@
#define RUNTIME_DIR_TEMPLATE "/tmp/tytest-tymux-XXXXXX"
static char _runtime_dir[] = RUNTIME_DIR_TEMPLATE;
+static char _page_queue_log[sizeof(_runtime_dir) + sizeof("/page-queue.log")];
static Config *_config = NULL;
static double
@@ -78,6 +79,9 @@ _environment_setup(void)
setenv("SHELL", "/bin/sh", 1);
setenv("PS1", "$ ", 1);
setenv("TERM", "xterm-256color", 1);
+ snprintf(_page_queue_log, sizeof(_page_queue_log), "%s/page-queue.log",
+ _runtime_dir);
+ setenv("TYMUXD_PAGE_QUEUE_LOG", _page_queue_log, 1);
_rc_file_write();
}
@@ -823,6 +827,38 @@ _never_done(void *data EINA_UNUSED)
"T=$(printf '%04000d' 0); for i in $(seq 1 " #COUNT "); do " \
"printf '\\033]0;%s\\007' \"$T\"; done\n"
+#define PAGE_QUEUED_BEHIND_MIN (64 * 1024)
+#define FLOOD_SECONDS_MAX 15.0
+
+/* The most output a PAGE reply waited behind in the daemon's queue, as the
+ * daemon logged it, or -1 if it logged nothing. */
+static long
+_page_queue_log_max(void)
+{
+ FILE *f = fopen(_page_queue_log, "r");
+ long ahead, max = -1;
+
+ if (!f)
+ return -1;
+ while (fscanf(f, "page queued behind %ld\n", &ahead) == 1)
+ if (ahead > max)
+ max = ahead;
+ fclose(f);
+ return max;
+}
+
+static void
+_page_queue_log_check(long ahead)
+{
+ if (ahead < 0)
+ fprintf(stderr, "no page queue log '%s': is tymuxd older than the "
+ "tests, without TYMUXD_PAGE_QUEUE_LOG?\n", _page_queue_log);
+ else if (ahead < PAGE_QUEUED_BEHIND_MIN)
+ fprintf(stderr, "the page reply queued behind only %ld bytes, "
+ "%d wanted\n", ahead, PAGE_QUEUED_BEHIND_MIN);
+ assert(ahead >= PAGE_QUEUED_BEHIND_MIN);
+}
+
/* A client that does not read while a flood goes by has a full socket and
* a growing queue in the daemon: a page it asks for then must wait in that
* queue, with its memfd, and still arrive when the client reads again. */
@@ -841,6 +877,7 @@ _live_pages_busy_body(void)
struct stat st;
uint8_t mode = TSRV_ATTACH_READONLY;
size_t after_page = 0;
+ double end;
assert(tytest_tymux_start(SESSION, 80, 24, &ts, &ty));
termtymux_resize(ts, 80, SCREEN_ROWS);
@@ -853,18 +890,30 @@ _live_pages_busy_body(void)
assert(termsrv_recv_attached(fd, &shm_fd, &attached) == 0);
close(shm_fd);
+ unlink(_page_queue_log);
/* fd is not read from now on, until the flood is over */
assert(tytest_tymux_type(ts, ty, "seq 1 4000\n"));
- assert(tytest_tymux_type(ts, ty, TITLE_FLOOD(100)));
- tytest_tymux_wait(_never_done, NULL, 3.0);
+ /* flood, then ask, until the daemon says the reply queued: how much the
+ * kernel takes of the flood depends on the host socket buffers. A round
+ * adds less than the daemon queue limit, 1 MiB, and the whole loop is
+ * bounded to stay well within the alarm of the test. */
req.page_id = attached.first_page_id;
- assert(termsrv_msg_send(fd, TSRV_MSG_BACKLOG_PAGE_REQ, &req,
- sizeof(req)) == 0);
+ end = _now() + FLOOD_SECONDS_MAX;
+ do
+ {
+ assert(tytest_tymux_type(ts, ty, TITLE_FLOOD(150)));
+ tytest_tymux_wait(_never_done, NULL, 0.3);
+ assert(termsrv_msg_send(fd, TSRV_MSG_BACKLOG_PAGE_REQ, &req,
+ sizeof(req)) == 0);
+ tytest_tymux_wait(_never_done, NULL, 0.3);
+ }
+ while (_page_queue_log_max() < PAGE_QUEUED_BEHIND_MIN && _now() < end);
/* more messages, which queue behind the page in the daemon: more than
* the 4096 bytes a read takes, so that a read that picks up the page
* memfd ends well after the page message */
assert(tytest_tymux_type(ts, ty, TITLE_FLOOD(10)));
- tytest_tymux_wait(_never_done, NULL, 3.0);
+ tytest_tymux_wait(_never_done, NULL, 1.0);
+ _page_queue_log_check(_page_queue_log_max());
for (;;)
{
@@ -877,8 +926,12 @@ _live_pages_busy_body(void)
free(payload);
if (type == TSRV_MSG_BACKLOG_PAGE)
{
- assert(page_fd < 0 && msg_fd >= 0);
- page_fd = msg_fd;
+ /* one reply per round that asked */
+ assert(msg_fd >= 0);
+ if (page_fd < 0)
+ page_fd = msg_fd;
+ else
+ close(msg_fd);
continue;
}
/* no other message has a memfd */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.