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 695379 - Folks Tp backend never finishes preparing if unable to connect to D-Bus
Folks Tp backend never finishes preparing if unable to connect to D-Bus
Status: RESOLVED OBSOLETE
Product: folks
Classification: Platform
Component: Telepathy backend
0.9.x
Other Linux
: Normal normal
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2013-03-07 18:25 UTC by Simon McVittie
Modified: 2018-09-21 16:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
TpBackend: properly fail to prepare if unable to connect to D-Bus (1.60 KB, patch)
2013-03-07 18:25 UTC, Simon McVittie
needs-work Details | Review

Description Simon McVittie 2013-03-07 18:25:50 UTC
Created attachment 238329 [details] [review]
TpBackend: properly fail to prepare if unable to connect to D-Bus

---

If you don't have a valid $DBUS_SESSION_BUS_ADDRESS, Tp.Backend.prepare() should raise a GError asynchronously. Instead, it criticals and prepare() never completes.
Comment 1 Philip Withnall 2013-03-07 19:50:34 UTC
Review of attachment 238329 [details] [review]:

::: backends/telepathy/tp-backend.vala
@@ +86,2 @@
       /* First handle adding any missing persona stores. */
+      GLib.List<unowned Account> accounts = null;

This should have type ‘GLib.List<unowned Account>?’, since it’s nullable.

@@ +170,3 @@
         {
           this._prepare_pending = true;
           this._account_manager = AccountManager.dup ();

If AccountManager.dup() can return null, the type of Tp.Backend._account_manager needs to be made nullable. Might be useful to add a comment to its declaration which specifies it’s null iff prepare() failed.

@@ +174,3 @@
+          if (this._account_manager == null)
+            {
+              throw new TelepathyGLib.Error.NOT_AVAILABLE ("Unable to connect to D-Bus");

Throwing a tp-glib error seems a bit odd. Would it better to wrap it in a new folks Backend error domain?
Comment 2 Simon McVittie 2013-03-08 14:30:18 UTC
(In reply to comment #1)
> This should have type ‘GLib.List<unowned Account>?’, since it’s nullable.

Fair enough, I'd assumed the compiler would have told me if I got this wrong. (I basically only learned Vala this week :-)

> If AccountManager.dup() can return null, the type of
> Tp.Backend._account_manager needs to be made nullable. Might be useful to add a
> comment to its declaration which specifies it’s null iff prepare() failed.

Sure.

> Throwing a tp-glib error seems a bit odd. Would it better to wrap it in a new
> folks Backend error domain?

I'd been going for "this is basically a workaround for tp_account_manager_dup() not raising a GError, so use a GError that it might conceivably have raised". After all, the same function will throw a Tp error if we *can* get a TpAccountManager, but its prepare_async() fails.

I suppose one possibility would be to call tp_dbus_daemon_dup() first (which currently throws a dbus-glib error, but will be a GDBus error if we ever port Telepathy to GDBus). If tp_dbus_daemon_dup() worked, then tp_account_manager_dup() can't fail - telepathy-glib doesn't explicitly document this, but it could.
Comment 3 Philip Withnall 2013-03-08 19:59:38 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > This should have type ‘GLib.List<unowned Account>?’, since it’s nullable.
> 
> Fair enough, I'd assumed the compiler would have told me if I got this wrong.
> (I basically only learned Vala this week :-)

You want to pass ‘--enable-experimental-non-null’ for that. It’s not enabled by default because there are sufficiently many bugs in the bindings that it gets too noisy. I did some work to make folks null-safe a while ago, but we’ve probably regressed quite a bit since then. I think if I were to do more work on that I’d want to improve valac to be a bit cleverer about tracking nullability in implicitly-typed variables first.

> > Throwing a tp-glib error seems a bit odd. Would it better to wrap it in a new
> > folks Backend error domain?
> 
> I'd been going for "this is basically a workaround for tp_account_manager_dup()
> not raising a GError, so use a GError that it might conceivably have raised".
> After all, the same function will throw a Tp error if we *can* get a
> TpAccountManager, but its prepare_async() fails.

Ah, if the existing code already throws a Tp error, then that’s enough justification for me to leave the patch as it is in this respect.

> I suppose one possibility would be to call tp_dbus_daemon_dup() first (which
> currently throws a dbus-glib error, but will be a GDBus error if we ever port
> Telepathy to GDBus). If tp_dbus_daemon_dup() worked, then
> tp_account_manager_dup() can't fail - telepathy-glib doesn't explicitly
> document this, but it could.

I don’t see that as any better than throwing a Tp error — it’s still a non-folks error.
Comment 4 GNOME Infrastructure Team 2018-09-21 16:01:12 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/folks/issues/55.