[totem/wip/hadess/fix-thread-thumb-warnings] thumbnailer: Fix thread related warnings




commit c69f9c258e89d03de59e031677ed41005f157378
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Aug 25 13:08:09 2020 +0200

    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

 src/totem-video-thumbnailer.c | 13 +++++--------
 1 file 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]