After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 745861 - RemoteSearch: don't complete a search that was cancelled
RemoteSearch: don't complete a search that was cancelled
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: search
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2015-03-08 22:39 UTC by Giovanni Campagna
Modified: 2015-03-11 20:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
RemoteSearch: don't complete a search that was cancelled (2.14 KB, patch)
2015-03-08 22:39 UTC, Giovanni Campagna
committed Details | Review
Search: be resilient against buggy search providers (1.11 KB, patch)
2015-03-08 23:35 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2015-03-08 22:39:13 UTC
This closes a race between setTerms and a slow GetInitialResultSet.
The bug manifests as follows:
- initial search for a short string
- previous results === undefined, call GetInitialResultSet
- user types more, cancel previous search in setTerms()
- mainloop, then _gotResults([])
- previous results === [], !!previous results === true
- therefore call GetSubsearchResultSet with an empty list of results
- _gotResults() from GetSubsearchResultSet is empty
- much later, return from GetInitialResultSet is discarded by
  cancellable
- user unhappy because what he searched for is not there

After this fix, the flow is:
- initial search for a short string
- previous results === undefined, call GetInitialResultSet
- user types more, cancel previous search in setTerms()
- mainloop, but no _gotResults
- previous results === undefined, call GetInitialResultSet again with
  longer string
- some time later, return from first GetInitialResultSet is discarded
  by cancellable
- soon after, return from second GetInitialResultSet comes with good
  results
- user happy
Comment 1 Giovanni Campagna 2015-03-08 22:39:16 UTC
Created attachment 298840 [details] [review]
RemoteSearch: don't complete a search that was cancelled
Comment 2 Giovanni Campagna 2015-03-08 23:35:20 UTC
Created attachment 298844 [details] [review]
Search: be resilient against buggy search providers

If a search provider returns a meta without a name, don't crash
constructing the actor.
Comment 3 Rui Matos 2015-03-11 16:26:38 UTC
Review of attachment 298844 [details] [review]:

fair enough
Comment 4 Rui Matos 2015-03-11 16:31:25 UTC
Review of attachment 298840 [details] [review]:

The code looks fine and makes sense.

But your description confuses me:

...
- mainloop, then _gotResults([])
...
- much later, return from GetInitialResultSet is discarded by
  cancellable
..

Isn't the _gotResults([]) step the result of the cancellable being cancelled? Why do you say that much later the GetInitialResultSet return is discarded? Didn't that happen already when _gotResults([]) ?
Comment 5 Giovanni Campagna 2015-03-11 20:47:19 UTC
(In reply to Rui Matos from comment #4)
> Review of attachment 298840 [details] [review] [review]:
> 
> The code looks fine and makes sense.
> 
> But your description confuses me:
> 
> ...
> - mainloop, then _gotResults([])
> ...
> - much later, return from GetInitialResultSet is discarded by
>   cancellable
> ..
> 
> Isn't the _gotResults([]) step the result of the cancellable being
> cancelled? Why do you say that much later the GetInitialResultSet return is
> discarded? Didn't that happen already when _gotResults([]) ?

If you cancel a cancellable associated with the dbus call, you don't actually cancel the call remotely. _gotResults([]) is called at the next mainloop iteration, but some time later you will still get a method_reply dbus message, and that will be discarded by the gdbus code (because the associated call was cancelled)
Comment 6 Giovanni Campagna 2015-03-11 20:48:31 UTC
Attachment 298840 [details] pushed as b0be6b8 - RemoteSearch: don't complete a search that was cancelled
Attachment 298844 [details] pushed as 8b5a44e - Search: be resilient against buggy search providers