[tracker-miners/wip/carlosg/parallel-installable: 4/37] tracker-miner-fs: Set cpu/io/nice settings before glib/gio usage



commit 083f019864473aadc1e5234159184d7cff1f2c58
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Feb 19 18:27:21 2020 +0100

    tracker-miner-fs: Set cpu/io/nice settings before glib/gio usage
    
    This was happening late enough during main() that there were already
    non-exclusive threadpools/threads created with regular scheduler
    settings. Those settings would be cached in recent glib, creating
    disparities that it will g_error() out on later. Those created threads
    might however be reused later on by different code (eg. metadata
    extraction, directly or indirectly), with the regular scheduling
    priorities set.
    
    Given that even accessing GSettings will result in threads being
    spawned underneath, there's no better choice than doing this always.
    This means the 'sched-idle' setting is ineffective. But this default
    should avoid fingers from pointing at us.

 src/miners/fs/tracker-main.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 1c6a2e9c0..990bada58 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -272,14 +272,10 @@ initialize_signal_handler (void)
 }
 
 static void
-initialize_priority_and_scheduling (TrackerSchedIdle sched_idle,
-                                    gboolean         first_time_index)
+initialize_priority_and_scheduling (void)
 {
        /* Set CPU priority */
-       if (sched_idle == TRACKER_SCHED_IDLE_ALWAYS ||
-           (sched_idle == TRACKER_SCHED_IDLE_FIRST_INDEX && first_time_index)) {
-               tracker_sched_idle ();
-       }
+       tracker_sched_idle ();
 
        /* Set disk IO priority and scheduling */
        tracker_ioprio_init ();
@@ -877,6 +873,9 @@ main (gint argc, gchar *argv[])
                return EXIT_FAILURE;
        }
 
+       /* This makes sure we don't steal all the system's resources */
+       initialize_priority_and_scheduling ();
+
        connection = g_bus_get_sync (TRACKER_IPC_BUS, NULL, &error);
        if (error) {
                g_critical ("Could not create DBus connection: %s\n",
@@ -905,10 +904,6 @@ main (gint argc, gchar *argv[])
 
        sanity_check_option_values (config);
 
-       /* This makes sure we don't steal all the system's resources */
-       initialize_priority_and_scheduling (tracker_config_get_sched_idle (config),
-                                           tracker_miner_files_get_first_index_done () == FALSE);
-
        main_loop = g_main_loop_new (NULL, FALSE);
 
        if (domain_ontology && domain_ontology_name) {


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