[gnome-software/1185-search-sometimes-fails-to-search] gs-search-page: Disable timeout for the search job



commit 08c23fd01e35566e035186d35df1af0c66da0497
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 30 15:20:24 2021 +0200

    gs-search-page: Disable timeout for the search job
    
    The search job can starve while other jobs are being processed, thus rather
    than time out the job after 10 seconds, let it take as long as it needs to.
    After all, it's a user action, he/she can cancel it anytime.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1185

 lib/gs-plugin-loader.c | 10 ++++++----
 src/gs-search-page.c   | 12 +++++++++++-
 2 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 2643615ff..0543f40d9 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3767,10 +3767,12 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
        case GS_PLUGIN_ACTION_SEARCH:
        case GS_PLUGIN_ACTION_SEARCH_FILES:
        case GS_PLUGIN_ACTION_SEARCH_PROVIDES:
-               helper->timeout_id =
-                       g_timeout_add_seconds (gs_plugin_job_get_timeout (plugin_job),
-                                              gs_plugin_loader_job_timeout_cb,
-                                              helper);
+               if (gs_plugin_job_get_timeout (plugin_job) > 0) {
+                       helper->timeout_id =
+                               g_timeout_add_seconds (gs_plugin_job_get_timeout (plugin_job),
+                                                      gs_plugin_loader_job_timeout_cb,
+                                                      helper);
+               }
                break;
        default:
                break;
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index a44758d39..bcb28e140 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -252,7 +252,7 @@ gs_search_page_load (GsSearchPage *self)
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
                                         "search", self->value,
                                         "max-results", self->max_results,
-                                        "timeout", 10,
+                                        "timeout", 0, /* This is a user action, let it take as long as it 
needs to */
                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
                                                         GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY |
@@ -370,6 +370,15 @@ gs_search_page_switch_to (GsPage *page, gboolean scroll_up)
                gs_search_page_load (self);
 }
 
+static void
+gs_search_page_switch_from (GsPage *page)
+{
+       GsSearchPage *self = GS_SEARCH_PAGE (page);
+
+       g_cancellable_cancel (self->search_cancellable);
+       g_clear_object (&self->search_cancellable);
+}
+
 static void
 gs_search_page_list_header_func (GtkListBoxRow *row,
                                  GtkListBoxRow *before,
@@ -484,6 +493,7 @@ gs_search_page_class_init (GsSearchPageClass *klass)
        page_class->app_installed = gs_search_page_app_installed;
        page_class->app_removed = gs_search_page_app_removed;
        page_class->switch_to = gs_search_page_switch_to;
+       page_class->switch_from = gs_search_page_switch_from;
        page_class->reload = gs_search_page_reload;
        page_class->setup = gs_search_page_setup;
 


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