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 c31c796f86a68427d03e083687685a08a17046d9
Author: Cedric BAIL <[email protected]>
AuthorDate: Thu Nov 19 18:52:26 2026 -0600
backlog_store: rename termd_backlog for use outside tymuxd
A later change keeps the scrollback of every terminal in the page store,
not only that of a tymuxd session. Give the store a name that does not
tie it to the daemon, so that the history of the move stays apart from
the change in behaviour.
---
DESIGN.md | 2 +-
src/bin/{termd_backlog.c => backlog_store.c} | 618 +++++++++++++--------------
src/bin/{termd_backlog.h => backlog_store.h} | 28 +-
src/bin/meson.build | 4 +-
src/bin/termd_tymux.c | 32 +-
src/bin/tytest.c | 12 +-
src/bin/unit_tests.h | 12 +-
7 files changed, 354 insertions(+), 354 deletions(-)
diff --git a/DESIGN.md b/DESIGN.md
index 34c0dc4f..f0ca4b73 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -3,6 +3,7 @@ A simple documentation to navigate through the C files:
* `src/bin/about.c` handles the About widget
* `src/bin/backlog.c`: backlog handling
* `src/bin/backlog_compress.c`: compresses backlog pages with zlib through Emile
+* `src/bin/backlog_store.c`: the scrollback of a `tymuxd` session, in memfd pages its clients map
* `src/bin/col.c` is about the colors handled by the terminal
* `src/bin/config.c`: how the configuration is saved/loaded/updated
* `src/bin/controls.c`: the widget when a right-click is done on a terminal
@@ -27,7 +28,6 @@ A simple documentation to navigate through the C files:
* `src/bin/options_wallpaper.c`: the settings panel to configure a wallpaper
* `src/bin/sel.c`: the tab selector
* `src/bin/termcmd.c` handles custom terminology commands
-* `src/bin/termd_backlog.c`: the scrollback of a `tymuxd` session, in memfd pages its clients map
* `src/bin/termd_tymux.c`: publishes a terminal running in `tymuxd` to its clients
* `src/bin/termio.c`: the core term widget with the textgrid
* `src/bin/termiolink.c`: link detection in the terminal
diff --git a/src/bin/termd_backlog.c b/src/bin/backlog_store.c
similarity index 65%
rename from src/bin/termd_backlog.c
rename to src/bin/backlog_store.c
index 45b2d6e4..3f9f34e1 100644
--- a/src/bin/termd_backlog.c
+++ b/src/bin/backlog_store.c
@@ -9,7 +9,7 @@
#include <Elementary.h>
#include "termpty.h"
#include "termsrv.h"
-#include "termd_backlog.h"
+#include "backlog_store.h"
#include "backlog_compress.h"
/* A sealed page nobody holds is compressed once it has been idle this
@@ -37,7 +37,7 @@ typedef enum
PAGE_RAW,
PAGE_COMPRESSING,
PAGE_COMPRESSED
-} TermDBacklogPageState;
+} BacklogStorePageState;
/* A RAW or COMPRESSING page is a mapping of fd. A COMPRESSED page has let
* go of both: header is a private copy of the page header, and the cells
@@ -52,7 +52,7 @@ typedef struct
uint32_t last_w;
int fd;
uint32_t refs;
- TermDBacklogPageState state;
+ BacklogStorePageState state;
/* when the page was sealed, or last held or sent: it is compressed or
* its export dropped once that is old enough */
double idle_since;
@@ -60,21 +60,21 @@ typedef struct
size_t cells_size; /* the bytes of cells in use */
Eina_Binbuf *blob;
int export_fd;
-} TermDBacklogPage;
+} BacklogStorePage;
typedef struct
{
- TermDBacklog *bl; /* NULL once the store is gone */
+ BacklogStore *bs; /* NULL once the store is gone */
uint32_t page_id;
int fd; /* a duplicate of the page memfd, the worker's own */
size_t cells_size;
Eina_Binbuf *blob;
-} TermDBacklogJob;
+} BacklogStoreJob;
-struct tag_TermDBacklog
+struct tag_BacklogStore
{
const char *name;
- TermDBacklogPage *pages; /* oldest first, the head last */
+ BacklogStorePage *pages; /* oldest first, the head last */
uint32_t count;
uint32_t alloc;
uint32_t first_id;
@@ -91,18 +91,18 @@ _page_cells(TermSrvBacklogPage *header)
((unsigned char *)header + TERMSRV_BACKLOG_HEADER_SIZE);
}
-static TermDBacklogPage *
-_page_find(TermDBacklog *bl, uint32_t page_id)
+static BacklogStorePage *
+_page_find(BacklogStore *bs, uint32_t page_id)
{
- uint32_t idx = page_id - bl->first_id;
+ uint32_t idx = page_id - bs->first_id;
- if (idx >= bl->count)
+ if (idx >= bs->count)
return NULL;
- return &bl->pages[idx];
+ return &bs->pages[idx];
}
static void
-_page_export_drop(TermDBacklogPage *page)
+_page_export_drop(BacklogStorePage *page)
{
if (page->export_fd >= 0)
close(page->export_fd);
@@ -110,7 +110,7 @@ _page_export_drop(TermDBacklogPage *page)
}
static void
-_page_close(TermDBacklogPage *page)
+_page_close(BacklogStorePage *page)
{
if (page->state == PAGE_COMPRESSED)
{
@@ -138,7 +138,7 @@ _page_gain(size_t cells_size, size_t blob_len)
* blob of its cells. Returns EINA_FALSE, and changes nothing, if the copy
* cannot be made. */
static Eina_Bool
-_page_compressed_set(TermDBacklogPage *page, Eina_Binbuf *blob)
+_page_compressed_set(BacklogStorePage *page, Eina_Binbuf *blob)
{
TermSrvBacklogPage *copy = malloc(sizeof(*copy));
@@ -155,29 +155,29 @@ _page_compressed_set(TermDBacklogPage *page, Eina_Binbuf *blob)
}
static TermSrvBacklogPage *
-_page_add(TermDBacklog *bl)
+_page_add(BacklogStore *bs)
{
- TermDBacklogPage *page;
+ BacklogStorePage *page;
char memfd_name[128];
- uint32_t page_id = bl->first_id + bl->count;
+ uint32_t page_id = bs->first_id + bs->count;
int fd;
- if (bl->count == bl->alloc)
+ if (bs->count == bs->alloc)
{
- uint32_t alloc = bl->alloc ? bl->alloc * 2 : 4;
- TermDBacklogPage *pages = realloc(bl->pages, alloc * sizeof(*pages));
+ uint32_t alloc = bs->alloc ? bs->alloc * 2 : 4;
+ BacklogStorePage *pages = realloc(bs->pages, alloc * sizeof(*pages));
if (!pages)
{
- ERR("cannot grow the backlog page table of '%s'", bl->name);
+ ERR("cannot grow the backlog page table of '%s'", bs->name);
return NULL;
}
- bl->pages = pages;
- bl->alloc = alloc;
+ bs->pages = pages;
+ bs->alloc = alloc;
}
snprintf(memfd_name, sizeof(memfd_name), "ty-backlog-%s-%u",
- bl->name, page_id);
+ bs->name, page_id);
fd = memfd_create(memfd_name, MFD_CLOEXEC);
if (fd < 0)
{
@@ -190,7 +190,7 @@ _page_add(TermDBacklog *bl)
close(fd);
return NULL;
}
- page = &bl->pages[bl->count];
+ page = &bs->pages[bs->count];
memset(page, 0, sizeof(*page));
page->export_fd = -1;
page->header = mmap(NULL, TERMSRV_BACKLOG_PAGE_SIZE,
@@ -202,91 +202,91 @@ _page_add(TermDBacklog *bl)
return NULL;
}
page->fd = fd;
- if (bl->count > 0)
+ if (bs->count > 0)
{
- bl->pages[bl->count - 1].idle_since = ecore_time_get();
- bl->pages[bl->count - 1].cells_size =
- bl->head_cells * sizeof(TermSrvCell);
+ bs->pages[bs->count - 1].idle_since = ecore_time_get();
+ bs->pages[bs->count - 1].cells_size =
+ bs->head_cells * sizeof(TermSrvCell);
}
page->header->magic = TERMSRV_BACKLOG_MAGIC;
page->header->version = TERMSRV_BACKLOG_VERSION;
page->header->page_id = page_id;
- bl->count++;
- bl->head_cells = 0;
+ bs->count++;
+ bs->head_cells = 0;
return page->header;
}
static void
-_evict(TermDBacklog *bl)
+_evict(BacklogStore *bs)
{
- while (bl->count > 1)
+ while (bs->count > 1)
{
- uint32_t oldest = bl->pages[0].entries;
+ uint32_t oldest = bs->pages[0].entries;
/* the job still reads it; its end evicts again */
- if (bl->pages[0].state == PAGE_COMPRESSING)
+ if (bs->pages[0].state == PAGE_COMPRESSING)
return;
- if (bl->total_entries - oldest < bl->max_entries)
+ if (bs->total_entries - oldest < bs->max_entries)
return;
- _page_close(&bl->pages[0]);
- bl->count--;
- memmove(&bl->pages[0], &bl->pages[1],
- bl->count * sizeof(bl->pages[0]));
- bl->first_id++;
- bl->total_entries -= oldest;
+ _page_close(&bs->pages[0]);
+ bs->count--;
+ memmove(&bs->pages[0], &bs->pages[1],
+ bs->count * sizeof(bs->pages[0]));
+ bs->first_id++;
+ bs->total_entries -= oldest;
}
}
-TermDBacklog *
-termd_backlog_new(const char *name, uint32_t max_entries)
+BacklogStore *
+backlog_store_new(const char *name, uint32_t max_entries)
{
- TermDBacklog *bl;
+ BacklogStore *bs;
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
- bl = calloc(1, sizeof(*bl));
- if (!bl)
+ bs = calloc(1, sizeof(*bs));
+ if (!bs)
return NULL;
- bl->name = eina_stringshare_add(name);
- bl->max_entries = max_entries;
- return bl;
+ bs->name = eina_stringshare_add(name);
+ bs->max_entries = max_entries;
+ return bs;
}
void
-termd_backlog_free(TermDBacklog *bl)
+backlog_store_free(BacklogStore *bs)
{
- TermDBacklogJob *job;
+ BacklogStoreJob *job;
uint32_t i;
- if (!bl)
+ if (!bs)
return;
/* the workers have duplicates of what they read, and their end
* callbacks must find that nothing is left to update */
- EINA_LIST_FREE(bl->jobs, job)
- job->bl = NULL;
- for (i = 0; i < bl->count; i++)
- _page_close(&bl->pages[i]);
- free(bl->pages);
- eina_stringshare_del(bl->name);
- free(bl);
+ EINA_LIST_FREE(bs->jobs, job)
+ job->bs = NULL;
+ for (i = 0; i < bs->count; i++)
+ _page_close(&bs->pages[i]);
+ free(bs->pages);
+ eina_stringshare_del(bs->name);
+ free(bs);
}
/* Clients follow the head through its atomics without a lock: the cells
* are written before the width that covers them is published, and a new
* entry's offset and width before num_entries counts it. */
Eina_Bool
-termd_backlog_append(TermDBacklog *bl, const Termcell *cells, ssize_t w,
+backlog_store_append(BacklogStore *bs, const Termcell *cells, ssize_t w,
Eina_Bool extends)
{
TermSrvBacklogPage *head = NULL;
- TermDBacklogPage *head_page = NULL;
+ BacklogStorePage *head_page = NULL;
uint32_t n = 0, cur_w, add;
- EINA_SAFETY_ON_NULL_RETURN_VAL(bl, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bs, EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL(w < 0 || (w > 0 && !cells), EINA_FALSE);
- if (bl->count)
+ if (bs->count)
{
- head_page = &bl->pages[bl->count - 1];
+ head_page = &bs->pages[bs->count - 1];
head = head_page->header;
n = head_page->entries;
}
@@ -297,58 +297,58 @@ termd_backlog_append(TermDBacklog *bl, const Termcell *cells, ssize_t w,
add = MIN((size_t)w, TERMSRV_BACKLOG_ENTRY_MAX_CELLS - cur_w);
if (add == 0)
return EINA_TRUE;
- memcpy(_page_cells(head) + bl->head_cells, cells,
+ memcpy(_page_cells(head) + bs->head_cells, cells,
add * sizeof(Termcell));
atomic_store_explicit(&head->entry_w[n - 1], cur_w + add,
memory_order_release);
head_page->last_w = cur_w + add;
- bl->head_cells += add;
+ bs->head_cells += add;
return EINA_TRUE;
}
if (!head || n >= TERMSRV_BACKLOG_PAGE_ENTRIES ||
- bl->head_cells >= TERMSRV_BACKLOG_PAGE_SEAL_CELLS)
+ bs->head_cells >= TERMSRV_BACKLOG_PAGE_SEAL_CELLS)
{
- head = _page_add(bl);
+ head = _page_add(bs);
if (!head)
return EINA_FALSE;
- head_page = &bl->pages[bl->count - 1];
+ head_page = &bs->pages[bs->count - 1];
n = 0;
}
add = MIN((size_t)w, TERMSRV_BACKLOG_ENTRY_MAX_CELLS);
if (add > 0)
- memcpy(_page_cells(head) + bl->head_cells, cells,
+ memcpy(_page_cells(head) + bs->head_cells, cells,
add * sizeof(Termcell));
- head->entry_off[n] = bl->head_cells;
+ head->entry_off[n] = bs->head_cells;
atomic_store_explicit(&head->entry_w[n], add, memory_order_release);
atomic_store_explicit(&head->num_entries, n + 1, memory_order_release);
head_page->entries = n + 1;
head_page->last_w = add;
- bl->head_cells += add;
- bl->total_entries++;
- _evict(bl);
+ bs->head_cells += add;
+ bs->total_entries++;
+ _evict(bs);
return EINA_TRUE;
}
uint32_t
-termd_backlog_first_id(const TermDBacklog *bl)
+backlog_store_first_id(const BacklogStore *bs)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(bl, 0);
- return bl->first_id;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bs, 0);
+ return bs->first_id;
}
uint32_t
-termd_backlog_count(const TermDBacklog *bl)
+backlog_store_count(const BacklogStore *bs)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(bl, 0);
- return bl->count;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bs, 0);
+ return bs->count;
}
/* Rebuild a COMPRESSED page into a memfd of the layout it had. It
* expands on the calling thread: up to TERMSRV_BACKLOG_PAGE_SEAL_CELLS
* cells, which takes some milliseconds. */
static int
-_page_export(const TermDBacklog *bl, TermDBacklogPage *page)
+_page_export(const BacklogStore *bs, BacklogStorePage *page)
{
char memfd_name[128];
unsigned char *map;
@@ -357,7 +357,7 @@ _page_export(const TermDBacklog *bl, TermDBacklogPage *page)
int fd;
snprintf(memfd_name, sizeof(memfd_name), "ty-export-%s-%u",
- bl->name, page->header->page_id);
+ bs->name, page->header->page_id);
fd = memfd_create(memfd_name, MFD_CLOEXEC);
if (fd < 0)
{
@@ -384,7 +384,7 @@ _page_export(const TermDBacklog *bl, TermDBacklogPage *page)
if (!ok)
{
ERR("cannot rebuild page %u of '%s'", page->header->page_id,
- bl->name);
+ bs->name);
close(fd);
return -1;
}
@@ -393,12 +393,12 @@ _page_export(const TermDBacklog *bl, TermDBacklogPage *page)
}
int
-termd_backlog_page_fd(TermDBacklog *bl, uint32_t page_id)
+backlog_store_page_fd(BacklogStore *bs, uint32_t page_id)
{
- TermDBacklogPage *page;
+ BacklogStorePage *page;
- EINA_SAFETY_ON_NULL_RETURN_VAL(bl, -1);
- page = _page_find(bl, page_id);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bs, -1);
+ page = _page_find(bs, page_id);
if (!page)
return -1;
page->idle_since = ecore_time_get();
@@ -406,34 +406,34 @@ termd_backlog_page_fd(TermDBacklog *bl, uint32_t page_id)
return page->fd;
if (page->export_fd >= 0)
return page->export_fd;
- return _page_export(bl, page);
+ return _page_export(bs, page);
}
Eina_Bool
-termd_backlog_page_exists(TermDBacklog *bl, uint32_t page_id)
+backlog_store_page_exists(BacklogStore *bs, uint32_t page_id)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(bl, EINA_FALSE);
- return _page_find(bl, page_id) != NULL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bs, EINA_FALSE);
+ return _page_find(bs, page_id) != NULL;
}
void
-termd_backlog_hold(TermDBacklog *bl, uint32_t page_id)
+backlog_store_hold(BacklogStore *bs, uint32_t page_id)
{
- TermDBacklogPage *page;
+ BacklogStorePage *page;
- EINA_SAFETY_ON_NULL_RETURN(bl);
- page = _page_find(bl, page_id);
+ EINA_SAFETY_ON_NULL_RETURN(bs);
+ page = _page_find(bs, page_id);
if (page)
page->refs++;
}
void
-termd_backlog_release(TermDBacklog *bl, uint32_t page_id)
+backlog_store_release(BacklogStore *bs, uint32_t page_id)
{
- TermDBacklogPage *page;
+ BacklogStorePage *page;
- EINA_SAFETY_ON_NULL_RETURN(bl);
- page = _page_find(bl, page_id);
+ EINA_SAFETY_ON_NULL_RETURN(bs);
+ page = _page_find(bs, page_id);
if (page && page->refs > 0)
{
page->refs--;
@@ -444,7 +444,7 @@ termd_backlog_release(TermDBacklog *bl, uint32_t page_id)
static void
_job_worker(void *data, Ecore_Thread *thread EINA_UNUSED)
{
- TermDBacklogJob *job = data;
+ BacklogStoreJob *job = data;
void *cells;
cells = mmap(NULL, job->cells_size, PROT_READ, MAP_SHARED, job->fd,
@@ -461,14 +461,14 @@ _job_worker(void *data, Ecore_Thread *thread EINA_UNUSED)
static void
_job_end(void *data, Ecore_Thread *thread EINA_UNUSED)
{
- TermDBacklogJob *job = data;
- TermDBacklog *bl = job->bl;
+ BacklogStoreJob *job = data;
+ BacklogStore *bs = job->bs;
- if (bl)
+ if (bs)
{
- TermDBacklogPage *page = _page_find(bl, job->page_id);
+ BacklogStorePage *page = _page_find(bs, job->page_id);
- bl->jobs = eina_list_remove(bl->jobs, job);
+ bs->jobs = eina_list_remove(bs->jobs, job);
if (page && page->state == PAGE_COMPRESSING)
{
Eina_Bool worthwhile = job->blob &&
@@ -492,7 +492,7 @@ _job_end(void *data, Ecore_Thread *thread EINA_UNUSED)
page->attempts++;
}
}
- _evict(bl);
+ _evict(bs);
}
if (job->blob)
eina_binbuf_free(job->blob);
@@ -504,14 +504,14 @@ _job_end(void *data, Ecore_Thread *thread EINA_UNUSED)
static void
_job_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
{
- TermDBacklogJob *job = data;
- TermDBacklog *bl = job->bl;
+ BacklogStoreJob *job = data;
+ BacklogStore *bs = job->bs;
- if (bl)
+ if (bs)
{
- TermDBacklogPage *page = _page_find(bl, job->page_id);
+ BacklogStorePage *page = _page_find(bs, job->page_id);
- bl->jobs = eina_list_remove(bl->jobs, job);
+ bs->jobs = eina_list_remove(bs->jobs, job);
if (page && page->state == PAGE_COMPRESSING)
{
page->state = PAGE_RAW;
@@ -526,9 +526,9 @@ _job_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
}
static void
-_job_start(TermDBacklog *bl, TermDBacklogPage *page)
+_job_start(BacklogStore *bs, BacklogStorePage *page)
{
- TermDBacklogJob *job;
+ BacklogStoreJob *job;
/* even a blob of nothing could not free enough */
if (_page_gain(page->cells_size, 0) < (ssize_t)COMPRESS_GAIN_MIN)
@@ -549,61 +549,61 @@ _job_start(TermDBacklog *bl, TermDBacklogPage *page)
free(job);
return;
}
- job->bl = bl;
+ job->bs = bs;
job->page_id = page->header->page_id;
job->cells_size = page->cells_size;
page->state = PAGE_COMPRESSING;
- bl->jobs = eina_list_append(bl->jobs, job);
+ bs->jobs = eina_list_append(bs->jobs, job);
ecore_thread_run(_job_worker, _job_end, _job_cancel, job);
}
void
-termd_backlog_maintain(TermDBacklog *bl, double now)
+backlog_store_maintain(BacklogStore *bs, double now)
{
uint32_t i;
- EINA_SAFETY_ON_NULL_RETURN(bl);
- for (i = 0; i < bl->count; i++)
+ EINA_SAFETY_ON_NULL_RETURN(bs);
+ for (i = 0; i < bs->count; i++)
{
- TermDBacklogPage *page = &bl->pages[i];
+ BacklogStorePage *page = &bs->pages[i];
if (page->export_fd >= 0 && page->refs == 0 &&
now - page->idle_since >= EXPORT_STALE_SECONDS)
_page_export_drop(page);
}
/* the head is still written to */
- for (i = 0; i + 1 < bl->count &&
- eina_list_count(bl->jobs) < COMPRESS_JOBS_MAX; i++)
+ for (i = 0; i + 1 < bs->count &&
+ eina_list_count(bs->jobs) < COMPRESS_JOBS_MAX; i++)
{
- TermDBacklogPage *page = &bl->pages[i];
+ BacklogStorePage *page = &bs->pages[i];
if (page->state == PAGE_RAW && page->refs == 0 &&
page->attempts < COMPRESS_ATTEMPTS_MAX &&
now - page->idle_since >= COMPRESS_IDLE_SECONDS)
- _job_start(bl, page);
+ _job_start(bs, page);
}
}
uint32_t
-termd_backlog_map_write(TermDBacklog *bl, uint32_t first, uint32_t count,
+backlog_store_map_write(BacklogStore *bs, uint32_t first, uint32_t count,
void *buf, uint32_t bufsz)
{
TermSrvMsgBacklogMapReq echo = { .first_page_id = first, .count = 0 };
uint64_t page_id, end;
uint32_t off = sizeof(echo);
- EINA_SAFETY_ON_NULL_RETURN_VAL(bl, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bs, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(buf, 0);
if (bufsz < sizeof(echo))
return 0;
- page_id = MAX(first, bl->first_id);
- end = MIN((uint64_t)first + count, (uint64_t)bl->first_id + bl->count);
+ page_id = MAX(first, bs->first_id);
+ end = MIN((uint64_t)first + count, (uint64_t)bs->first_id + bs->count);
if (page_id < end)
echo.first_page_id = page_id;
for (; page_id < end; page_id++)
{
- const TermDBacklogPage *page = &bl->pages[page_id - bl->first_id];
+ const BacklogStorePage *page = &bs->pages[page_id - bs->first_id];
if (termsrv_backlog_map_page_append(buf, bufsz, &off, page_id,
page->entries,
@@ -629,10 +629,10 @@ _test_row_fill(Termcell *cells, int w, Eina_Unicode first)
}
static const TermSrvBacklogPage *
-_test_page_map(TermDBacklog *bl, uint32_t page_id)
+_test_page_map(BacklogStore *bs, uint32_t page_id)
{
const TermSrvBacklogPage *page;
- int fd = termd_backlog_page_fd(bl, page_id);
+ int fd = backlog_store_page_fd(bs, page_id);
assert(fd >= 0);
page = mmap(NULL, TERMSRV_BACKLOG_PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
@@ -662,33 +662,33 @@ _test_page_unmap(const TermSrvBacklogPage *page)
* an entry stops growing at TERMSRV_BACKLOG_ENTRY_MAX_CELLS, and extends
* with nothing to extend starts an entry. */
int
-tytest_termd_backlog_pages(void)
+tytest_backlog_store_pages(void)
{
const TermSrvBacklogPage *page;
const TermSrvCell *page_cells;
- TermDBacklog *bl;
+ BacklogStore *bs;
Termcell row[10], *big;
uint32_t i, last;
- bl = termd_backlog_new("test", 100000);
- assert(bl);
- assert(termd_backlog_count(bl) == 0);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
+ assert(backlog_store_count(bs) == 0);
for (i = 0; i < 600; i++)
{
_test_row_fill(row, 1, i);
- assert(termd_backlog_append(bl, row, 1, EINA_FALSE));
+ assert(backlog_store_append(bs, row, 1, EINA_FALSE));
}
- assert(termd_backlog_count(bl) == 3);
- assert(termd_backlog_first_id(bl) == 0);
- page = _test_page_map(bl, 2);
+ assert(backlog_store_count(bs) == 3);
+ assert(backlog_store_first_id(bs) == 0);
+ page = _test_page_map(bs, 2);
assert(atomic_load(&page->num_entries) == 600 - 2 * 256);
for (i = 0; i < 3; i++)
{
_test_row_fill(row, 10, 'a' + 10 * i);
- assert(termd_backlog_append(bl, row, 10, i > 0));
+ assert(backlog_store_append(bs, row, 10, i > 0));
}
- assert(termd_backlog_count(bl) == 3);
+ assert(backlog_store_count(bs) == 3);
assert(atomic_load(&page->num_entries) == 600 - 2 * 256 + 1);
last = atomic_load(&page->num_entries) - 1;
assert(page->entry_off[last] == 600 - 2 * 256);
@@ -705,36 +705,36 @@ tytest_termd_backlog_pages(void)
{
TermSrvBacklogPage *rw = mmap(NULL, TERMSRV_BACKLOG_PAGE_SIZE,
PROT_READ | PROT_WRITE, MAP_SHARED,
- termd_backlog_page_fd(bl, 2), 0);
+ backlog_store_page_fd(bs, 2), 0);
assert(rw != MAP_FAILED);
atomic_store(&rw->num_entries, 0x7fffffff);
atomic_store(&rw->entry_w[last], 0xffffffff);
_test_row_fill(row, 10, 'a');
- assert(termd_backlog_append(bl, row, 10, EINA_TRUE));
+ assert(backlog_store_append(bs, row, 10, EINA_TRUE));
assert(atomic_load(&rw->entry_w[last]) == 40);
- assert(termd_backlog_append(bl, row, 10, EINA_FALSE));
+ assert(backlog_store_append(bs, row, 10, EINA_FALSE));
assert(atomic_load(&rw->num_entries) == last + 2);
munmap(rw, TERMSRV_BACKLOG_PAGE_SIZE);
}
- assert(termd_backlog_page_fd(bl, 3) < 0);
- assert(termd_backlog_page_exists(bl, 2));
- assert(!termd_backlog_page_exists(bl, 3));
- termd_backlog_hold(bl, 3);
- termd_backlog_release(bl, 3);
- termd_backlog_free(bl);
+ assert(backlog_store_page_fd(bs, 3) < 0);
+ assert(backlog_store_page_exists(bs, 2));
+ assert(!backlog_store_page_exists(bs, 3));
+ backlog_store_hold(bs, 3);
+ backlog_store_release(bs, 3);
+ backlog_store_free(bs);
big = calloc(TERMSRV_BACKLOG_ENTRY_MAX_CELLS, sizeof(Termcell));
assert(big);
big[0].codepoint = 'x';
- bl = termd_backlog_new("test", 100000);
- assert(bl);
- assert(termd_backlog_append(bl, big, TERMSRV_BACKLOG_ENTRY_MAX_CELLS - 5,
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
+ assert(backlog_store_append(bs, big, TERMSRV_BACKLOG_ENTRY_MAX_CELLS - 5,
EINA_TRUE));
_test_row_fill(row, 10, 'a');
- assert(termd_backlog_append(bl, row, 10, EINA_TRUE));
- page = _test_page_map(bl, 0);
+ assert(backlog_store_append(bs, row, 10, EINA_TRUE));
+ page = _test_page_map(bs, 0);
assert(atomic_load(&page->num_entries) == 1);
assert(atomic_load(&page->entry_w[0]) == TERMSRV_BACKLOG_ENTRY_MAX_CELLS);
page_cells = _test_page_cells(page);
@@ -742,14 +742,14 @@ tytest_termd_backlog_pages(void)
assert(page_cells[TERMSRV_BACKLOG_ENTRY_MAX_CELLS - 1].codepoint == 'e');
_test_page_unmap(page);
- assert(termd_backlog_append(bl, row, 1, EINA_FALSE));
- assert(termd_backlog_count(bl) == 2);
- page = _test_page_map(bl, 1);
+ assert(backlog_store_append(bs, row, 1, EINA_FALSE));
+ assert(backlog_store_count(bs) == 2);
+ page = _test_page_map(bs, 1);
assert(atomic_load(&page->num_entries) == 1);
assert(page->entry_off[0] == 0);
assert(_test_page_cells(page)[0].codepoint == 'a');
_test_page_unmap(page);
- termd_backlog_free(bl);
+ backlog_store_free(bs);
free(big);
return 0;
}
@@ -757,42 +757,42 @@ tytest_termd_backlog_pages(void)
/* Test: the oldest pages go once the newer ones hold max_entries, held or
* not, and a client that got a page's memfd before can still read it. */
int
-tytest_termd_backlog_evict(void)
+tytest_backlog_store_evict(void)
{
const TermSrvBacklogPage *page;
- TermDBacklog *bl;
+ BacklogStore *bs;
Termcell row[1];
uint32_t i, kept = 0, buf[64];
TermSrvMsgBacklogMapReq *echo = (TermSrvMsgBacklogMapReq *)buf;
int page0_fd;
- bl = termd_backlog_new("test", 300);
- assert(bl);
+ bs = backlog_store_new("test", 300);
+ assert(bs);
_test_row_fill(row, 1, 0);
- assert(termd_backlog_append(bl, row, 1, EINA_FALSE));
- page0_fd = dup(termd_backlog_page_fd(bl, 0));
+ assert(backlog_store_append(bs, row, 1, EINA_FALSE));
+ page0_fd = dup(backlog_store_page_fd(bs, 0));
assert(page0_fd >= 0);
- termd_backlog_hold(bl, 0);
+ backlog_store_hold(bs, 0);
for (i = 1; i < 1000; i++)
{
_test_row_fill(row, 1, i);
- assert(termd_backlog_append(bl, row, 1, EINA_FALSE));
+ assert(backlog_store_append(bs, row, 1, EINA_FALSE));
}
- assert(termd_backlog_first_id(bl) > 0);
- assert(termd_backlog_page_fd(bl, 0) < 0);
- for (i = 0; i < termd_backlog_count(bl); i++)
+ assert(backlog_store_first_id(bs) > 0);
+ assert(backlog_store_page_fd(bs, 0) < 0);
+ for (i = 0; i < backlog_store_count(bs); i++)
{
- page = _test_page_map(bl, termd_backlog_first_id(bl) + i);
+ page = _test_page_map(bs, backlog_store_first_id(bs) + i);
kept += atomic_load(&page->num_entries);
_test_page_unmap(page);
}
assert(kept >= 300 && kept < 300 + TERMSRV_BACKLOG_PAGE_ENTRIES);
- termd_backlog_release(bl, 0);
+ backlog_store_release(bs, 0);
- assert(termd_backlog_map_write(bl, 0, 100, buf, sizeof(buf)) >=
+ assert(backlog_store_map_write(bs, 0, 100, buf, sizeof(buf)) >=
sizeof(*echo));
- assert(echo->first_page_id == termd_backlog_first_id(bl));
+ assert(echo->first_page_id == backlog_store_first_id(bs));
page = mmap(NULL, TERMSRV_BACKLOG_PAGE_SIZE, PROT_READ, MAP_SHARED,
page0_fd, 0);
@@ -803,7 +803,7 @@ tytest_termd_backlog_evict(void)
TERMSRV_BACKLOG_PAGE_ENTRIES - 1);
_test_page_unmap(page);
close(page0_fd);
- termd_backlog_free(bl);
+ backlog_store_free(bs);
return 0;
}
@@ -813,26 +813,26 @@ _test_map_width(uint32_t page_id, uint32_t entry)
return (page_id * TERMSRV_BACKLOG_PAGE_ENTRIES + entry) % 7;
}
-/* Test: termd_backlog_map_write() lists the widths of the pages asked for
+/* Test: backlog_store_map_write() lists the widths of the pages asked for
* that exist, as many as fit, and echoes the range it covers. */
int
-tytest_termd_backlog_map(void)
+tytest_backlog_store_map(void)
{
static uint32_t buf[TERMSRV_MAX_MSG_PAYLOAD / sizeof(uint32_t)];
TermSrvMsgBacklogMapReq *echo = (TermSrvMsgBacklogMapReq *)buf;
const uint32_t *widths;
- TermDBacklog *bl;
+ BacklogStore *bs;
Termcell row[7];
uint32_t i, j, len, off, page_id, num_entries, two_pages;
- bl = termd_backlog_new("test", 100000);
- assert(bl);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
_test_row_fill(row, 7, 'a');
for (i = 0; i < 600; i++)
- assert(termd_backlog_append(bl, row, i % 7, EINA_FALSE));
- assert(termd_backlog_count(bl) == 3);
+ assert(backlog_store_append(bs, row, i % 7, EINA_FALSE));
+ assert(backlog_store_count(bs) == 3);
- len = termd_backlog_map_write(bl, 0, 100, buf, sizeof(buf));
+ len = backlog_store_map_write(bs, 0, 100, buf, sizeof(buf));
assert(echo->first_page_id == 0 && echo->count == 3);
off = sizeof(*echo);
for (i = 0; i < 3; i++)
@@ -850,28 +850,28 @@ tytest_termd_backlog_map(void)
two_pages = sizeof(*echo) +
2 * (2 + TERMSRV_BACKLOG_PAGE_ENTRIES) * sizeof(uint32_t);
- len = termd_backlog_map_write(bl, 0, 3, buf, two_pages + 4);
+ len = backlog_store_map_write(bs, 0, 3, buf, two_pages + 4);
assert(len == two_pages);
assert(echo->first_page_id == 0 && echo->count == 2);
- len = termd_backlog_map_write(bl, 1, UINT32_MAX, buf, sizeof(buf));
+ len = backlog_store_map_write(bs, 1, UINT32_MAX, buf, sizeof(buf));
assert(echo->first_page_id == 1 && echo->count == 2);
off = sizeof(*echo);
assert(termsrv_backlog_map_page_next(buf, len, &off, &page_id,
&num_entries, &widths) == 1);
assert(page_id == 1);
- len = termd_backlog_map_write(bl, 3, 5, buf, sizeof(buf));
+ len = backlog_store_map_write(bs, 3, 5, buf, sizeof(buf));
assert(len == sizeof(*echo) && echo->count == 0);
- len = termd_backlog_map_write(bl, 0, 0, buf, sizeof(buf));
+ len = backlog_store_map_write(bs, 0, 0, buf, sizeof(buf));
assert(len == sizeof(*echo) && echo->count == 0);
- assert(termd_backlog_map_write(bl, 0, 3, buf, sizeof(*echo) - 1) == 0);
- termd_backlog_free(bl);
+ assert(backlog_store_map_write(bs, 0, 3, buf, sizeof(*echo) - 1) == 0);
+ backlog_store_free(bs);
return 0;
}
typedef struct
{
- TermDBacklog *bl;
+ BacklogStore *bs;
Eina_Bool timed_out;
} Test_Wait;
@@ -880,7 +880,7 @@ _test_jobs_poll_cb(void *data)
{
Test_Wait *wait = data;
- if (eina_list_count(wait->bl->jobs) == 0)
+ if (eina_list_count(wait->bs->jobs) == 0)
ecore_main_loop_quit();
return ECORE_CALLBACK_RENEW;
}
@@ -897,9 +897,9 @@ _test_timeout_cb(void *data)
/* Run the main loop until no compression job is left. */
static void
-_test_jobs_wait(TermDBacklog *bl)
+_test_jobs_wait(BacklogStore *bs)
{
- Test_Wait wait = { bl, EINA_FALSE };
+ Test_Wait wait = { bs, EINA_FALSE };
Ecore_Timer *poll = ecore_timer_add(0.005, _test_jobs_poll_cb, &wait);
Ecore_Timer *timeout = ecore_timer_add(20.0, _test_timeout_cb, &wait);
@@ -923,7 +923,7 @@ _test_loop_run(double seconds)
#define TEST_ROW_W 8
static void
-_test_pages_fill(TermDBacklog *bl, uint32_t first, uint32_t count)
+_test_pages_fill(BacklogStore *bs, uint32_t first, uint32_t count)
{
Termcell row[TEST_ROW_W];
uint32_t i;
@@ -931,16 +931,16 @@ _test_pages_fill(TermDBacklog *bl, uint32_t first, uint32_t count)
for (i = first; i < first + count; i++)
{
_test_row_fill(row, TEST_ROW_W, 'a' + i % 26);
- assert(termd_backlog_append(bl, row, TEST_ROW_W, EINA_FALSE));
+ assert(backlog_store_append(bs, row, TEST_ROW_W, EINA_FALSE));
}
}
/* Compare page_id as a client would read it with the rows
* _test_pages_fill() stored. */
static void
-_test_page_check(TermDBacklog *bl, uint32_t page_id)
+_test_page_check(BacklogStore *bs, uint32_t page_id)
{
- const TermSrvBacklogPage *page = _test_page_map(bl, page_id);
+ const TermSrvBacklogPage *page = _test_page_map(bs, page_id);
const TermSrvCell *cells = _test_page_cells(page);
uint32_t i, j, n = atomic_load(&page->num_entries);
Termcell row[TEST_ROW_W];
@@ -967,104 +967,104 @@ _test_page_check(TermDBacklog *bl, uint32_t page_id)
* compressed is not evicted before its job ends, and the store can be
* freed with jobs in flight. */
int
-tytest_termd_backlog_compress(void)
+tytest_backlog_store_compress(void)
{
- TermDBacklog *bl;
- TermDBacklogPage *page;
+ BacklogStore *bs;
+ BacklogStorePage *page;
const TermSrvBacklogPage *client_page;
double now;
int fd, client_fd, raw_fd;
ecore_init();
- bl = termd_backlog_new("test", 100000);
- assert(bl);
- _test_pages_fill(bl, 0, 600);
- assert(termd_backlog_count(bl) == 3);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
+ _test_pages_fill(bs, 0, 600);
+ assert(backlog_store_count(bs) == 3);
now = ecore_time_get();
- termd_backlog_maintain(bl, now + 1.0);
- assert(eina_list_count(bl->jobs) == 0);
- termd_backlog_maintain(bl, now + 6.0);
- assert(eina_list_count(bl->jobs) == 2);
- _test_jobs_wait(bl);
- assert(_page_find(bl, 0)->state == PAGE_COMPRESSED);
- assert(_page_find(bl, 1)->state == PAGE_COMPRESSED);
- assert(_page_find(bl, 2)->state == PAGE_RAW);
- termd_backlog_maintain(bl, now + 600.0);
- assert(eina_list_count(bl->jobs) == 0);
- assert(_page_find(bl, 2)->state == PAGE_RAW);
+ backlog_store_maintain(bs, now + 1.0);
+ assert(eina_list_count(bs->jobs) == 0);
+ backlog_store_maintain(bs, now + 6.0);
+ assert(eina_list_count(bs->jobs) == 2);
+ _test_jobs_wait(bs);
+ assert(_page_find(bs, 0)->state == PAGE_COMPRESSED);
+ assert(_page_find(bs, 1)->state == PAGE_COMPRESSED);
+ assert(_page_find(bs, 2)->state == PAGE_RAW);
+ backlog_store_maintain(bs, now + 600.0);
+ assert(eina_list_count(bs->jobs) == 0);
+ assert(_page_find(bs, 2)->state == PAGE_RAW);
- assert(_page_find(bl, 0)->export_fd < 0);
- _test_page_check(bl, 0);
- _test_page_check(bl, 1);
- fd = termd_backlog_page_fd(bl, 0);
- assert(fd == _page_find(bl, 0)->export_fd);
- assert(termd_backlog_page_fd(bl, 0) == fd);
+ assert(_page_find(bs, 0)->export_fd < 0);
+ _test_page_check(bs, 0);
+ _test_page_check(bs, 1);
+ fd = backlog_store_page_fd(bs, 0);
+ assert(fd == _page_find(bs, 0)->export_fd);
+ assert(backlog_store_page_fd(bs, 0) == fd);
client_fd = dup(fd);
assert(client_fd >= 0);
- termd_backlog_hold(bl, 0);
- termd_backlog_maintain(bl, ecore_time_get() + 600.0);
- assert(_page_find(bl, 0)->export_fd == fd);
- termd_backlog_release(bl, 0);
- termd_backlog_maintain(bl, ecore_time_get() + 30.0);
- assert(_page_find(bl, 0)->export_fd == fd);
- termd_backlog_maintain(bl, ecore_time_get() + 600.0);
- assert(_page_find(bl, 0)->export_fd < 0);
+ backlog_store_hold(bs, 0);
+ backlog_store_maintain(bs, ecore_time_get() + 600.0);
+ assert(_page_find(bs, 0)->export_fd == fd);
+ backlog_store_release(bs, 0);
+ backlog_store_maintain(bs, ecore_time_get() + 30.0);
+ assert(_page_find(bs, 0)->export_fd == fd);
+ backlog_store_maintain(bs, ecore_time_get() + 600.0);
+ assert(_page_find(bs, 0)->export_fd < 0);
client_page = mmap(NULL, TERMSRV_BACKLOG_PAGE_SIZE, PROT_READ,
MAP_SHARED, client_fd, 0);
assert(client_page != MAP_FAILED);
assert(client_page->page_id == 0);
_test_page_unmap(client_page);
close(client_fd);
- _test_page_check(bl, 0);
- termd_backlog_free(bl);
+ _test_page_check(bs, 0);
+ backlog_store_free(bs);
/* a held page stays raw */
- bl = termd_backlog_new("test", 100000);
- assert(bl);
- _test_pages_fill(bl, 0, 600);
- termd_backlog_hold(bl, 0);
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- assert(eina_list_count(bl->jobs) == 1);
- _test_jobs_wait(bl);
- assert(_page_find(bl, 0)->state == PAGE_RAW);
- assert(_page_find(bl, 1)->state == PAGE_COMPRESSED);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
+ _test_pages_fill(bs, 0, 600);
+ backlog_store_hold(bs, 0);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ assert(eina_list_count(bs->jobs) == 1);
+ _test_jobs_wait(bs);
+ assert(_page_find(bs, 0)->state == PAGE_RAW);
+ assert(_page_find(bs, 1)->state == PAGE_COMPRESSED);
/* a page that a client takes while it is compressed stays raw */
- termd_backlog_release(bl, 0);
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- page = _page_find(bl, 0);
+ backlog_store_release(bs, 0);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ page = _page_find(bs, 0);
assert(page->state == PAGE_COMPRESSING);
- raw_fd = termd_backlog_page_fd(bl, 0);
+ raw_fd = backlog_store_page_fd(bs, 0);
assert(raw_fd == page->fd);
- termd_backlog_hold(bl, 0);
- _test_jobs_wait(bl);
- page = _page_find(bl, 0);
+ backlog_store_hold(bs, 0);
+ _test_jobs_wait(bs);
+ page = _page_find(bs, 0);
assert(page->state == PAGE_RAW && page->fd == raw_fd);
assert(page->attempts == 0);
- _test_page_check(bl, 0);
- termd_backlog_free(bl);
+ _test_page_check(bs, 0);
+ backlog_store_free(bs);
/* the oldest page is not evicted while it is compressed */
- bl = termd_backlog_new("test", 300);
- assert(bl);
- _test_pages_fill(bl, 0, 300);
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- assert(_page_find(bl, 0)->state == PAGE_COMPRESSING);
- _test_pages_fill(bl, 300, 300);
- assert(termd_backlog_first_id(bl) == 0);
- _test_jobs_wait(bl);
- assert(termd_backlog_first_id(bl) == 1);
- assert(termd_backlog_page_fd(bl, 0) < 0);
- termd_backlog_free(bl);
+ bs = backlog_store_new("test", 300);
+ assert(bs);
+ _test_pages_fill(bs, 0, 300);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ assert(_page_find(bs, 0)->state == PAGE_COMPRESSING);
+ _test_pages_fill(bs, 300, 300);
+ assert(backlog_store_first_id(bs) == 0);
+ _test_jobs_wait(bs);
+ assert(backlog_store_first_id(bs) == 1);
+ assert(backlog_store_page_fd(bs, 0) < 0);
+ backlog_store_free(bs);
/* the end of a job finds its store gone */
- bl = termd_backlog_new("test", 100000);
- assert(bl);
- _test_pages_fill(bl, 0, 600);
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- assert(eina_list_count(bl->jobs) == 2);
- termd_backlog_free(bl);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
+ _test_pages_fill(bs, 0, 600);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ assert(eina_list_count(bs->jobs) == 2);
+ backlog_store_free(bs);
_test_loop_run(0.3);
ecore_shutdown();
return 0;
@@ -1079,9 +1079,9 @@ _test_varying_w(uint32_t entry)
* page header and cells of page_id, as a client reads them, with what was
* stored. */
static void
-_test_varying_check(TermDBacklog *bl, uint32_t page_id)
+_test_varying_check(BacklogStore *bs, uint32_t page_id)
{
- const TermSrvBacklogPage *page = _test_page_map(bl, page_id);
+ const TermSrvBacklogPage *page = _test_page_map(bs, page_id);
const TermSrvCell *cells = _test_page_cells(page);
Termcell row[70];
uint32_t i, off = 0, n = atomic_load(&page->num_entries);
@@ -1103,15 +1103,15 @@ _test_varying_check(TermDBacklog *bl, uint32_t page_id)
/* Test: pages that compression cannot help are left alone for good. */
int
-tytest_termd_backlog_compress_skip(void)
+tytest_backlog_store_compress_skip(void)
{
- TermDBacklog *bl;
+ BacklogStore *bs;
Termcell row[TEST_ROW_W];
uint32_t i, seed = 12345;
ecore_init();
- bl = termd_backlog_new("test", 100000);
- assert(bl);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
/* page 0: noise, a blob that is not smaller than 85% of the cells */
for (i = 0; i < 300; i++)
{
@@ -1123,63 +1123,63 @@ tytest_termd_backlog_compress_skip(void)
seed = seed * 1664525u + 1013904223u;
bytes[j] = seed >> 24;
}
- assert(termd_backlog_append(bl, row, TEST_ROW_W, EINA_FALSE));
+ assert(backlog_store_append(bs, row, TEST_ROW_W, EINA_FALSE));
}
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- assert(eina_list_count(bl->jobs) == 1);
- _test_jobs_wait(bl);
- assert(_page_find(bl, 0)->state == PAGE_RAW);
- assert(_page_find(bl, 0)->attempts == 3);
- termd_backlog_maintain(bl, ecore_time_get() + 600.0);
- assert(eina_list_count(bl->jobs) == 0);
- termd_backlog_free(bl);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ assert(eina_list_count(bs->jobs) == 1);
+ _test_jobs_wait(bs);
+ assert(_page_find(bs, 0)->state == PAGE_RAW);
+ assert(_page_find(bs, 0)->attempts == 3);
+ backlog_store_maintain(bs, ecore_time_get() + 600.0);
+ assert(eina_list_count(bs->jobs) == 0);
+ backlog_store_free(bs);
/* pages too small to free memory, and pages without any cell */
- bl = termd_backlog_new("test", 100000);
- assert(bl);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
for (i = 0; i < 256; i++)
- assert(termd_backlog_append(bl, NULL, 0, EINA_FALSE));
+ assert(backlog_store_append(bs, NULL, 0, EINA_FALSE));
_test_row_fill(row, 1, 'a');
for (i = 0; i < 257; i++)
- assert(termd_backlog_append(bl, row, 1, EINA_FALSE));
- assert(termd_backlog_count(bl) == 3);
- assert(_page_find(bl, 0)->cells_size == 0);
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- assert(eina_list_count(bl->jobs) == 0);
- assert(_page_find(bl, 0)->state == PAGE_RAW);
- assert(_page_find(bl, 0)->attempts == 3);
- assert(_page_find(bl, 1)->state == PAGE_RAW);
- assert(_page_find(bl, 1)->attempts == 3);
- termd_backlog_free(bl);
+ assert(backlog_store_append(bs, row, 1, EINA_FALSE));
+ assert(backlog_store_count(bs) == 3);
+ assert(_page_find(bs, 0)->cells_size == 0);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ assert(eina_list_count(bs->jobs) == 0);
+ assert(_page_find(bs, 0)->state == PAGE_RAW);
+ assert(_page_find(bs, 0)->attempts == 3);
+ assert(_page_find(bs, 1)->state == PAGE_RAW);
+ assert(_page_find(bs, 1)->attempts == 3);
+ backlog_store_free(bs);
ecore_shutdown();
return 0;
}
/* Test: a rebuilt page has the entries it had, of any width. */
int
-tytest_termd_backlog_compress_widths(void)
+tytest_backlog_store_compress_widths(void)
{
- TermDBacklog *bl;
+ BacklogStore *bs;
Termcell row[70];
uint32_t i;
ecore_init();
- bl = termd_backlog_new("test", 100000);
- assert(bl);
+ bs = backlog_store_new("test", 100000);
+ assert(bs);
for (i = 0; i < 600; i++)
{
uint32_t w = _test_varying_w(i);
_test_row_fill(row, w, 'a' + i % 26);
- assert(termd_backlog_append(bl, row, w, EINA_FALSE));
+ assert(backlog_store_append(bs, row, w, EINA_FALSE));
}
- termd_backlog_maintain(bl, ecore_time_get() + 6.0);
- _test_jobs_wait(bl);
- assert(_page_find(bl, 0)->state == PAGE_COMPRESSED);
- assert(_page_find(bl, 1)->state == PAGE_COMPRESSED);
- _test_varying_check(bl, 0);
- _test_varying_check(bl, 1);
- termd_backlog_free(bl);
+ backlog_store_maintain(bs, ecore_time_get() + 6.0);
+ _test_jobs_wait(bs);
+ assert(_page_find(bs, 0)->state == PAGE_COMPRESSED);
+ assert(_page_find(bs, 1)->state == PAGE_COMPRESSED);
+ _test_varying_check(bs, 0);
+ _test_varying_check(bs, 1);
+ backlog_store_free(bs);
ecore_shutdown();
return 0;
}
diff --git a/src/bin/termd_backlog.h b/src/bin/backlog_store.h
similarity index 74%
rename from src/bin/termd_backlog.h
rename to src/bin/backlog_store.h
index cf7c1c46..c5d293ae 100644
--- a/src/bin/termd_backlog.h
+++ b/src/bin/backlog_store.h
@@ -1,44 +1,44 @@
-#ifndef TERMINOLOGY_TERMD_BACKLOG_H_
-#define TERMINOLOGY_TERMD_BACKLOG_H_ 1
+#ifndef TERMINOLOGY_BACKLOG_STORE_H_
+#define TERMINOLOGY_BACKLOG_STORE_H_ 1
/* The scrollback of a tymuxd session, kept once in memfd pages that its
* clients map read-only (see TermSrvBacklogPage in termsrv.h). Pages are
* identified by an id that only grows; the last page is the head, the only
* one still written to. Include termpty.h and termsrv.h first. */
-typedef struct tag_TermDBacklog TermDBacklog;
+typedef struct tag_BacklogStore BacklogStore;
/* A store whose memfds are named "ty-backlog-<name>-<id>", that evicts its
* oldest pages once the others still hold max_entries entries. Returns NULL
* on failure. */
-TermDBacklog *termd_backlog_new(const char *name, uint32_t max_entries);
+BacklogStore *backlog_store_new(const char *name, uint32_t max_entries);
-void termd_backlog_free(TermDBacklog *bl);
+void backlog_store_free(BacklogStore *bs);
/* Store a row of w cells that left the screen. If extends, the row
* continues the last entry (clamped to TERMSRV_BACKLOG_ENTRY_MAX_CELLS),
* otherwise it starts a new one. Returns EINA_FALSE if the row could not be
* stored. */
-Eina_Bool termd_backlog_append(TermDBacklog *bl, const Termcell *cells,
+Eina_Bool backlog_store_append(BacklogStore *bs, const Termcell *cells,
ssize_t w, Eina_Bool extends);
/* The id of the oldest page, and how many pages there are up to the head. */
-uint32_t termd_backlog_first_id(const TermDBacklog *bl);
-uint32_t termd_backlog_count(const TermDBacklog *bl);
+uint32_t backlog_store_first_id(const BacklogStore *bs);
+uint32_t backlog_store_count(const BacklogStore *bs);
/* The memfd of page_id, owned by the store: send it, do not close it, and
* do not use it past the next call into the store, which may close it. A
* compressed page is rebuilt into a new memfd, named "ty-export-", and a
* client that was sent a duplicate keeps it. Returns -1 for an unknown or
* evicted page, or if the rebuild fails. */
-int termd_backlog_page_fd(TermDBacklog *bl, uint32_t page_id);
+int backlog_store_page_fd(BacklogStore *bs, uint32_t page_id);
/* Whether page_id is held, whatever state it is in. */
-Eina_Bool termd_backlog_page_exists(TermDBacklog *bl, uint32_t page_id);
+Eina_Bool backlog_store_page_exists(BacklogStore *bs, uint32_t page_id);
/* Count a client holding page_id, or one letting go of it. Unknown ids are
* ignored. */
-void termd_backlog_hold(TermDBacklog *bl, uint32_t page_id);
-void termd_backlog_release(TermDBacklog *bl, uint32_t page_id);
+void backlog_store_hold(BacklogStore *bs, uint32_t page_id);
+void backlog_store_release(BacklogStore *bs, uint32_t page_id);
/* To be called about once a second, with the ecore_time_get() clock.
* Compresses, on up to two threads, the sealed pages that no client holds
@@ -47,14 +47,14 @@ void termd_backlog_release(TermDBacklog *bl, uint32_t page_id);
* rebuilt pages that were not used for 60 seconds. A job still running
* when the store is freed is left to finish by itself. The main loop must
* run for the jobs to complete. */
-void termd_backlog_maintain(TermDBacklog *bl, double now);
+void backlog_store_maintain(BacklogStore *bs, double now);
/* Write a TSRV_MSG_BACKLOG_MAP payload into buf for the pages in
* [first, first + count): the TermSrvMsgBacklogMapReq echo of the range
* covered, clipped to the pages that exist and to what fits in bufsz, then
* those pages. Returns the bytes written, 0 if bufsz cannot hold the
* echo. */
-uint32_t termd_backlog_map_write(TermDBacklog *bl, uint32_t first,
+uint32_t backlog_store_map_write(BacklogStore *bs, uint32_t first,
uint32_t count, void *buf, uint32_t bufsz);
#endif
diff --git a/src/bin/meson.build b/src/bin/meson.build
index bb6f4f16..0ff936cf 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -167,7 +167,7 @@ tybench_sources = [color_names,
if host_os == 'linux'
tytest_sources += ['termsrv.c', 'termsrv.h', 'termtymux.c', 'termtymux.h',
- 'termd_backlog.c', 'termd_backlog.h',
+ 'backlog_store.c', 'backlog_store.h',
'backlog_compress.c', 'backlog_compress.h',
'tytest_tymux.c', 'tytest_tymux.h']
endif
@@ -219,7 +219,7 @@ if host_os == 'linux'
'tymuxd_stubs.c',
'color_names.h', color_names,
'termd_tymux.c', 'termd_tymux.h',
- 'termd_backlog.c', 'termd_backlog.h',
+ 'backlog_store.c', 'backlog_store.h',
'backlog_compress.c', 'backlog_compress.h',
'termsrv.c', 'termsrv.h',
'termpty.c', 'termpty.h',
diff --git a/src/bin/termd_tymux.c b/src/bin/termd_tymux.c
index 3257eaca..dfba985e 100644
--- a/src/bin/termd_tymux.c
+++ b/src/bin/termd_tymux.c
@@ -11,7 +11,7 @@
#include "config.h"
#include "termpty.h"
#include "termsrv.h"
-#include "termd_backlog.h"
+#include "backlog_store.h"
#include "termd_tymux.h"
_Static_assert(sizeof(Termcell) == sizeof(TermSrvCell),
@@ -62,7 +62,7 @@ typedef struct
struct tag_TermDTymux
{
Termpty *pty;
- TermDBacklog *backlog;
+ BacklogStore *backlog;
Config *config;
int shm_fd;
TermSrvShmHeader *shm;
@@ -255,8 +255,8 @@ _flush_and_notify(TermDTymux *td)
td->notify_anim = NULL;
}
- notify.first_page_id = termd_backlog_first_id(td->backlog);
- notify.page_count = termd_backlog_count(td->backlog);
+ notify.first_page_id = backlog_store_first_id(td->backlog);
+ notify.page_count = backlog_store_count(td->backlog);
EINA_LIST_FOREACH(td->clients, l, client)
_client_pages_prune(client);
@@ -300,7 +300,7 @@ _cb_pty_backlog(void *data, Termpty *ty EINA_UNUSED, const Termcell *cells, ssiz
{
TermDTymux *td = data;
- if (!termd_backlog_append(td->backlog, cells, w, extends) &&
+ if (!backlog_store_append(td->backlog, cells, w, extends) &&
!td->backlog_append_failed)
{
ERR("cannot store the backlog in pages");
@@ -367,8 +367,8 @@ _client_attach(Client *client, TermSrvAttachMode mode)
if (termsrv_send_attached(client->fd, td->shm_fd, ty->w, ty->h,
ty->pid > 0 ? ty->pid : -1,
- termd_backlog_first_id(td->backlog),
- termd_backlog_count(td->backlog)) < 0)
+ backlog_store_first_id(td->backlog),
+ backlog_store_count(td->backlog)) < 0)
{
_client_del(client);
return;
@@ -426,7 +426,7 @@ _client_page_held(const Client *client, uint32_t page_id)
static void
_client_pages_prune(Client *client)
{
- uint32_t first = termd_backlog_first_id(client->td->backlog);
+ uint32_t first = backlog_store_first_id(client->td->backlog);
while (client->held_pages &&
(uintptr_t)eina_list_data_get(client->held_pages) < first)
@@ -464,9 +464,9 @@ _client_page_send(Client *client, uint32_t page_id)
QueuedFd *queued;
_client_pages_prune(client);
- if (!termd_backlog_page_exists(td->backlog, page_id))
+ if (!backlog_store_page_exists(td->backlog, page_id))
return;
- page_fd = termd_backlog_page_fd(td->backlog, page_id);
+ page_fd = backlog_store_page_fd(td->backlog, page_id);
if (page_fd < 0)
{
_client_page_refuse(client, &reply);
@@ -514,7 +514,7 @@ _client_page_send(Client *client, uint32_t page_id)
client->held_pages = eina_list_sorted_insert(client->held_pages,
_page_id_cmp,
(void *)(uintptr_t)page_id);
- termd_backlog_hold(td->backlog, page_id);
+ backlog_store_hold(td->backlog, page_id);
}
static void
@@ -524,14 +524,14 @@ _client_page_release(Client *client, uint32_t page_id)
return;
client->held_pages = eina_list_remove(client->held_pages,
(void *)(uintptr_t)page_id);
- termd_backlog_release(client->td->backlog, page_id);
+ backlog_store_release(client->td->backlog, page_id);
}
static void
_client_map_send(Client *client, const TermSrvMsgBacklogMapReq *req)
{
unsigned char buf[TERMSRV_MAX_MSG_PAYLOAD];
- uint32_t len = termd_backlog_map_write(client->td->backlog,
+ uint32_t len = backlog_store_map_write(client->td->backlog,
req->first_page_id, req->count,
buf, sizeof(buf));
@@ -713,7 +713,7 @@ _cb_backlog_timer(void *data)
{
TermDTymux *td = data;
- termd_backlog_maintain(td->backlog, ecore_time_get());
+ backlog_store_maintain(td->backlog, ecore_time_get());
return ECORE_CALLBACK_RENEW;
}
@@ -734,7 +734,7 @@ termd_tymux_new(const char *name, const char *cmd)
td->config->scrollback = TERMD_TYMUX_PTY_BACKLOG;
td->config->term_type = TERM_TYPE_XTERM_256COLOR;
- td->backlog = termd_backlog_new(name, TERMD_TYMUX_SCROLLBACK);
+ td->backlog = backlog_store_new(name, TERMD_TYMUX_SCROLLBACK);
if (!td->backlog)
goto err;
td->backlog_timer = ecore_timer_add(BACKLOG_MAINTAIN_SECONDS,
@@ -818,7 +818,7 @@ termd_tymux_free(TermDTymux *td)
munmap(td->shm, TERMSRV_SHM_TOTAL_SIZE);
if (td->shm_fd >= 0)
close(td->shm_fd);
- termd_backlog_free(td->backlog);
+ backlog_store_free(td->backlog);
free(td->config);
free(td);
}
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 54337ca2..730eacce 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -179,12 +179,12 @@ static struct {
{ "termsrv_cell_layout", tytest_termsrv_cell_layout},
{ "termsrv_backlog_page_fd", tytest_termsrv_backlog_page_fd},
{ "termsrv_backlog_map", tytest_termsrv_backlog_map},
- { "termd_backlog_pages", tytest_termd_backlog_pages},
- { "termd_backlog_evict", tytest_termd_backlog_evict},
- { "termd_backlog_map", tytest_termd_backlog_map},
- { "termd_backlog_compress", tytest_termd_backlog_compress},
- { "termd_backlog_compress_skip", tytest_termd_backlog_compress_skip},
- { "termd_backlog_compress_widths", tytest_termd_backlog_compress_widths},
+ { "backlog_store_pages", tytest_backlog_store_pages},
+ { "backlog_store_evict", tytest_backlog_store_evict},
+ { "backlog_store_map", tytest_backlog_store_map},
+ { "backlog_store_compress", tytest_backlog_store_compress},
+ { "backlog_store_compress_skip", tytest_backlog_store_compress_skip},
+ { "backlog_store_compress_widths", tytest_backlog_store_compress_widths},
{ "backlog_compress", tytest_backlog_compress},
{ "termtymux_frame_apply_same_size", tytest_termtymux_frame_apply_same_size},
{ "termtymux_frame_apply_resize", tytest_termtymux_frame_apply_resize},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index f72b9814..43e0c9c9 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -134,12 +134,12 @@ int tytest_termsrv_attached(void);
int tytest_termsrv_cell_layout(void);
int tytest_termsrv_backlog_page_fd(void);
int tytest_termsrv_backlog_map(void);
-int tytest_termd_backlog_pages(void);
-int tytest_termd_backlog_evict(void);
-int tytest_termd_backlog_map(void);
-int tytest_termd_backlog_compress(void);
-int tytest_termd_backlog_compress_skip(void);
-int tytest_termd_backlog_compress_widths(void);
+int tytest_backlog_store_pages(void);
+int tytest_backlog_store_evict(void);
+int tytest_backlog_store_map(void);
+int tytest_backlog_store_compress(void);
+int tytest_backlog_store_compress_skip(void);
+int tytest_backlog_store_compress_widths(void);
int tytest_backlog_compress(void);
int tytest_termtymux_frame_apply_same_size(void);
int tytest_termtymux_frame_apply_resize(void);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.