summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-08-25 13:08:09 +0200
committerBastien Nocera <hadess@hadess.net>2020-08-25 13:10:57 +0200
commitc69f9c258e89d03de59e031677ed41005f157378 (patch)
tree9f2d81d2af536084d8d64fb1dfca2fc35cca9071
parente2d3c47c34eca15e7c8ed285cb7af92378d9069f (diff)
downloadtotem-c69f9c258e89d03de59e031677ed41005f157378.tar.gz
thumbnailer: Fix thread related warnings
When running, totem-video-thumbnailer would throw loads of warnings related to not being able to set the scheduler settings. (totem-video-thumbnailer:4797): GLib-CRITICAL **: 22:45:48.120: Failed to set scheduler settings: Operation not permitted (totem-video-thumbnailer:4797): GLib-CRITICAL **: 22:45:48.239: Failed to set scheduler settings: Operation not permitted (totem-video-thumbnailer:4797): GLib-CRITICAL **: 22:45:48.242: Failed to set scheduler settings: Operation not permitted (totem-video-thumbnailer:4797): GLib-CRITICAL **: 22:45:48.605: Failed to set scheduler settings: Operation not permitted (totem-video-thumbnailer:4797): GLib-CRITICAL **: 22:45:48.706: Failed to set scheduler settings: Operation not permitted This is caused by the global shared GThreadPool being spawned by gst_init() through options parsing, before totem-video-thumbnailer drops the nice value to 20. The few spare GThreadPool threads are using a nice value of 0, and will try to apply it to the new threads. But they're spawned from the main thread which has a nice of 0, so the code will try to change the nice value to match, which isn't allowed by kernel policies. Work-around this by running nice(20) before the thread pool is created. See: https://gitlab.gnome.org/GNOME/glib/-/issues/2191 Closes: #394
-rw-r--r--src/totem-video-thumbnailer.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index 5f0d4ab75..ec2c5c4af 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -606,6 +606,11 @@ int main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
+ /* Call before the global thread pool is setup */
+ errno = 0;
+ if (nice (20) != 20 && errno != 0)
+ g_warning ("Couldn't change nice value of process.");
+
context = g_option_context_new ("Thumbnail movies");
options = gst_init_get_option_group ();
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
@@ -617,14 +622,6 @@ int main (int argc, char *argv[])
return 1;
}
-#ifdef G_OS_UNIX
- if (time_limit != FALSE) {
- errno = 0;
- if (nice (20) != 20 && errno != 0)
- g_warning ("Couldn't change nice value of process.");
- }
-#endif
-
if (print_progress) {
fcntl (fileno (stdout), F_SETFL, O_NONBLOCK);
setbuf (stdout, NULL);