Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Background helpers yield to the desktop: mail sync at nice 19 and idle I/O

Federico Pereirad7b3521c97c6
diff --git a/server/src/mail/maild.c b/server/src/mail/maild.c
index f84f76e..be394ec 100644
--- a/server/src/mail/maild.c
+++ b/server/src/mail/maild.c
@@ -624,6 +624,11 @@ static void enter_sandbox(void) {
.ro_dir_fds = NULL,
.rw_dir_fds = rw,
};
+ /* syncing is background work: it must not compete with the desktop and its sound right after
+ * login (0.8.1; the first full sync starts at once). nice 19 and idle I/O, set before the
+ * sandbox, whose seccomp filter doesn't allow ioprio_set */
+ setpriority(PRIO_PROCESS, 0, 19);
+ syscall(SYS_ioprio_set, 1, 0, 3 << 13); /* IOPRIO_WHO_PROCESS, this process, IOPRIO_CLASS_IDLE */
int mask = sandbox_apply_helper(&cfg);
dbg("sandbox mask %#x", (unsigned)mask);
}
diff --git a/server/src/media/helper/lm_main.c b/server/src/media/helper/lm_main.c
index d7c88ce..ba62b21 100644
--- a/server/src/media/helper/lm_main.c
+++ b/server/src/media/helper/lm_main.c
@@ -69,11 +69,14 @@ int main(int argc, char **argv) {
if (m.v[0] == MK_CAMERA) ioctls |= SANDBOX_IOCTL_V4L2 | (fds[1] >= 0 ? SANDBOX_IOCTL_DRM | SANDBOX_IOCTL_DMABUF : 0);
SandboxHelperCfg cfg = { .name = "app-lordos-media", .ro_paths = ro, .extra_syscalls = extra, .allow_ioctl_classes = ioctls,
.mem_max_mb = m.v[0] == MK_WORKER ? 1024 : 1536 };
+ if (m.v[0] == MK_WORKER) { /* thumbnails and probes: in the background (before the sandbox) */
+ setpriority(PRIO_PROCESS, 0, 10);
+ syscall(SYS_ioprio_set, 1, 0, (2 << 13) | 7); /* IOPRIO_WHO_PROCESS, this process, best effort, lowest */
+ }
sandbox_apply_helper(&cfg);
switch (m.v[0]) {
case MK_PLAY: lm_player(payload, fds[0], fds[1], fds[2]); break;
case MK_WORKER:
- setpriority(PRIO_PROCESS, 0, 10); /* thumbnails and probes: in the background */
lm_worker();
break;
case MK_SCREENREC: lm_screenrec(payload, fds[0], fds[1], fds[2]); break;