Bug 68712 - connectivity code is far too complicated
Summary: connectivity code is far too complicated
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: mission-control (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on: 56635
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-29 16:04 UTC by Simon McVittie
Modified: 2013-09-04 12:55 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
01/16] McdMaster: use modern idiom for priv (7.25 KB, patch)
2013-08-29 16:04 UTC, Simon McVittie
Details | Splinter Review
02/16] mcd_master_create_manager: unvirtualize (2.31 KB, patch)
2013-08-29 16:04 UTC, Simon McVittie
Details | Splinter Review
Remove various useless virtual method padding (2.62 KB, patch)
2013-08-29 16:05 UTC, Simon McVittie
Details | Splinter Review
mcd_operation_take_mission, _remove_mission: do not be virtual (3.06 KB, patch)
2013-08-29 16:05 UTC, Simon McVittie
Details | Splinter Review
05/16] Remove support for checking conditions on accounts (5.41 KB, patch)
2013-08-29 16:05 UTC, Simon McVittie
Details | Splinter Review
06/16] McdMaster: remove support for writing account-manager property (1.76 KB, patch)
2013-08-29 16:06 UTC, Simon McVittie
Details | Splinter Review
07/16] McdConnectivityMonitor: take responsibility for monitoring use-conn (2.86 KB, patch)
2013-08-29 16:06 UTC, Simon McVittie
Details | Splinter Review
08/16] Remove the concept of binding accounts to transports (8.31 KB, patch)
2013-08-29 16:06 UTC, Simon McVittie
Details | Splinter Review
09/16] Put the connectivity monitor in the McdAccountManager (5.31 KB, patch)
2013-08-29 16:07 UTC, Simon McVittie
Details | Splinter Review
10/16] McdAccount: have a reference to the connectivity monitor (5.36 KB, patch)
2013-08-29 16:07 UTC, Simon McVittie
Details | Splinter Review
11/16] Move "waiting for connectivity" functionality into McdAccount (12.37 KB, patch)
2013-08-29 16:07 UTC, Simon McVittie
Details | Splinter Review
12/16] McdAccount: respond to connectivity status changes (8.08 KB, patch)
2013-08-29 16:08 UTC, Simon McVittie
Details | Splinter Review
13/16] mcd_master_connect_automatic_accounts: move to McdAccountManager (2.57 KB, patch)
2013-08-29 16:08 UTC, Simon McVittie
Details | Splinter Review
14/16] _mcd_master_account_replace_transport: inline into caller and simplify (7.31 KB, patch)
2013-08-29 16:08 UTC, Simon McVittie
Details | Splinter Review
15/16] Remove the remains of McdTransportPlugin (24.49 KB, patch)
2013-08-29 16:08 UTC, Simon McVittie
Details | Splinter Review
16/16] Remove unused signal McdAccount::connection-process (2.67 KB, patch)
2013-08-29 16:09 UTC, Simon McVittie
Details | Splinter Review
[08/16 v2] Put the connectivity monitor in the McdAccountManager (5.64 KB, patch)
2013-09-03 17:58 UTC, Simon McVittie
Details | Splinter Review
[09/16 v2] McdAccount: have a reference to the connectivity monitor (5.69 KB, patch)
2013-09-03 17:58 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2013-08-29 16:04:00 UTC
In theory, Mission Control used to support multiple connectivity backends with pluggability and and and. (In practice, I don't think it ever worked.)

Now that I have a branch (Bug #56635) to use GNetworkMonitor (which is also pluggable), it seems like a good time to cut the complexity:

 src/Makefile.am              |   7 +-
 src/connectivity-monitor.c   |  21 ++-
 src/kludge-transport.c       | 268 --------------------------------
 src/kludge-transport.h       |  61 --------
 src/mcd-account-connection.c |  70 ++++-----
 src/mcd-account-manager.c    |  23 ++-
 src/mcd-account-manager.h    |   4 +
 src/mcd-account-priv.h       |   3 -
 src/mcd-account.c            | 175 +++++++++++++--------
 src/mcd-account.h            |  15 +-
 src/mcd-channel.c            |   1 -
 src/mcd-channel.h            |   7 -
 src/mcd-connection-plugin.h  |  50 ------
 src/mcd-dispatcher.h         |  15 --
 src/mcd-manager.h            |   6 -
 src/mcd-master-priv.h        |   6 -
 src/mcd-master.c             | 361 ++-----------------------------------------
 src/mcd-master.h             |  23 +--
 src/mcd-operation.c          |  39 ++---
 src/mcd-transport.c          | 188 ----------------------
 src/mcd-transport.h          |  83 ----------
 21 files changed, 231 insertions(+), 1195 deletions(-)

(Admittedly, that figure includes some other refactoring on the way.)
Comment 1 Simon McVittie 2013-08-29 16:04:33 UTC
Created attachment 84850 [details] [review]
01/16] McdMaster: use modern idiom for priv
Comment 2 Simon McVittie 2013-08-29 16:04:59 UTC
Created attachment 84851 [details] [review]
02/16] mcd_master_create_manager: unvirtualize


There's no point in this being virtual: there are no subclasses,
and it isn't API any more.
Comment 3 Simon McVittie 2013-08-29 16:05:11 UTC
Created attachment 84852 [details] [review]
Remove various useless virtual method padding

This part of Mission Control is no longer API.
Comment 4 Simon McVittie 2013-08-29 16:05:26 UTC
Created attachment 84853 [details] [review]
mcd_operation_take_mission, _remove_mission: do not be  virtual


Nothing overrides them, they're no longer API, and one day I'd like to
get rid of McdOperation entirely.
Comment 5 Simon McVittie 2013-08-29 16:05:56 UTC
Created attachment 84854 [details] [review]
05/16] Remove support for checking conditions on accounts

We no longer have API for external transport providers, and we've never
defined any conditions on the transport provider we do have.

---

I haven't removed the Account.Conditions interface yet, but I probably will.
Comment 6 Simon McVittie 2013-08-29 16:06:07 UTC
Created attachment 84855 [details] [review]
06/16] McdMaster: remove support for writing account-manager  property

Nothing constructs a McdMaster with a non-default McdAccountManager.
Comment 7 Simon McVittie 2013-08-29 16:06:20 UTC
Created attachment 84856 [details] [review]
07/16] McdConnectivityMonitor: take responsibility for  monitoring use-conn

I want to get rid of the kludge-transport.
Comment 8 Simon McVittie 2013-08-29 16:06:45 UTC
Created attachment 84857 [details] [review]
08/16] Remove the concept of binding accounts to transports

We only have one transport now, so there are two options: either the
account is a special one that "needs dispatch" and also bypasses the
transport check (in practice this means cellular accounts), or it is
connected via the Internet.

Binding accounts to transports never made a vast amount of sense. If we
have many parallel Internet connections (e.g. wired + wifi + cellular +
VPN), Mission Control can't know which one a Connection is relying on -
only the connection manager can know that - so we have to err on the
side of disconnecting everything on a connectivity change anyway.

A possible refinement in future Tp versions would be a way for a CM
to tell MC "this connection does its own connectivity-monitoring,
so don't kick it when we get disconnected". For now, we assume that
everything needs the Internet, unless it's one of the accounts that
wouldn't previously have been bound to a connection (i.e.
_mcd_account_needs_dispatch() returns FALSE).
Comment 9 Simon McVittie 2013-08-29 16:07:22 UTC
Created attachment 84858 [details] [review]
09/16] Put the connectivity monitor in the McdAccountManager

---

Minor technical debt, repaid later in the patch series:

+  McdKludgeTransport *self = g_object_new (MCD_TYPE_KLUDGE_TRANSPORT, NULL);
+
+  /* Strictly speaking this should be done with properties, but I'm
+   * going to delete this class soon anyway. */
+  self->priv->minotaur = connectivity_monitor;
+  tp_g_signal_connect_object (self->priv->minotaur, "state-change",
+      (GCallback) monitor_state_changed_cb, self, 0);
Comment 10 Simon McVittie 2013-08-29 16:07:34 UTC
Created attachment 84859 [details] [review]
10/16] McdAccount: have a reference to the connectivity  monitor
Comment 11 Simon McVittie 2013-08-29 16:07:47 UTC
Created attachment 84860 [details] [review]
11/16] Move "waiting for connectivity" functionality into  McdAccount
Comment 12 Simon McVittie 2013-08-29 16:08:04 UTC
Created attachment 84861 [details] [review]
12/16] McdAccount: respond to connectivity status changes

Instead of proxying through the transport plugin and the McdMaster, just
watch the McdConnectivityMonitor. Much simpler!
Comment 13 Simon McVittie 2013-08-29 16:08:18 UTC
Created attachment 84862 [details] [review]
13/16] mcd_master_connect_automatic_accounts: move to  McdAccountManager

Iterating over all accounts? Looks like a job for the account manager.
Comment 14 Simon McVittie 2013-08-29 16:08:36 UTC
Created attachment 84863 [details] [review]
14/16] _mcd_master_account_replace_transport: inline into  caller and simplify

There's only one transport plugin, it only has one transport, and
its state is basically boolean, so we can delete a lot of code.
Comment 15 Simon McVittie 2013-08-29 16:08:48 UTC
Created attachment 84864 [details] [review]
15/16] Remove the remains of McdTransportPlugin
Comment 16 Simon McVittie 2013-08-29 16:09:01 UTC
Created attachment 84865 [details] [review]
16/16] Remove unused signal McdAccount::connection-process
Comment 17 Guillaume Desmottes 2013-08-30 09:09:17 UTC
Comment on attachment 84850 [details] [review]
01/16] McdMaster: use modern idiom for priv

Review of attachment 84850 [details] [review]:
-----------------------------------------------------------------

++
Comment 18 Guillaume Desmottes 2013-08-30 09:11:32 UTC
Comment on attachment 84851 [details] [review]
02/16] mcd_master_create_manager: unvirtualize

Review of attachment 84851 [details] [review]:
-----------------------------------------------------------------

++
Comment 19 Guillaume Desmottes 2013-08-30 09:11:50 UTC
Comment on attachment 84852 [details] [review]
Remove various useless virtual method padding

Review of attachment 84852 [details] [review]:
-----------------------------------------------------------------

++
Comment 20 Guillaume Desmottes 2013-08-30 09:13:33 UTC
Comment on attachment 84853 [details] [review]
mcd_operation_take_mission, _remove_mission: do not be  virtual

Review of attachment 84853 [details] [review]:
-----------------------------------------------------------------

you didn't remove those from the .h file as well?
Comment 21 Guillaume Desmottes 2013-08-30 09:14:17 UTC
Comment on attachment 84854 [details] [review]
05/16] Remove support for checking conditions on accounts

Review of attachment 84854 [details] [review]:
-----------------------------------------------------------------

++
Comment 22 Guillaume Desmottes 2013-08-30 09:14:44 UTC
Comment on attachment 84855 [details] [review]
06/16] McdMaster: remove support for writing account-manager  property

Review of attachment 84855 [details] [review]:
-----------------------------------------------------------------

++
Comment 23 Guillaume Desmottes 2013-08-30 09:15:24 UTC
Comment on attachment 84856 [details] [review]
07/16] McdConnectivityMonitor: take responsibility for  monitoring use-conn

Review of attachment 84856 [details] [review]:
-----------------------------------------------------------------

++
Comment 24 Guillaume Desmottes 2013-08-30 09:25:11 UTC
Comment on attachment 84857 [details] [review]
08/16] Remove the concept of binding accounts to transports

Review of attachment 84857 [details] [review]:
-----------------------------------------------------------------

Patch looks ok but that means we'll have to WONTFIX bug #41148
Comment 25 Guillaume Desmottes 2013-08-30 09:26:42 UTC
Comment on attachment 84858 [details] [review]
09/16] Put the connectivity monitor in the McdAccountManager

Review of attachment 84858 [details] [review]:
-----------------------------------------------------------------

::: src/mcd-account-manager.c
@@ +1657,4 @@
>  
>      DEBUG ("");
>  
> +    priv->minotaur = mcd_connectivity_monitor_new ();

shouldn't you unref it when disposing?
Comment 26 Guillaume Desmottes 2013-08-30 09:27:43 UTC
Comment on attachment 84859 [details] [review]
10/16] McdAccount: have a reference to the connectivity  monitor

Review of attachment 84859 [details] [review]:
-----------------------------------------------------------------

++
Comment 27 Guillaume Desmottes 2013-08-30 09:29:12 UTC
Comment on attachment 84860 [details] [review]
11/16] Move "waiting for connectivity" functionality into  McdAccount

Review of attachment 84860 [details] [review]:
-----------------------------------------------------------------

++
Comment 28 Guillaume Desmottes 2013-08-30 09:30:22 UTC
Comment on attachment 84861 [details] [review]
12/16] McdAccount: respond to connectivity status changes

Review of attachment 84861 [details] [review]:
-----------------------------------------------------------------

++
Comment 29 Guillaume Desmottes 2013-08-30 09:30:51 UTC
Comment on attachment 84862 [details] [review]
13/16] mcd_master_connect_automatic_accounts: move to  McdAccountManager

Review of attachment 84862 [details] [review]:
-----------------------------------------------------------------

++
Comment 30 Guillaume Desmottes 2013-08-30 09:34:53 UTC
Comment on attachment 84863 [details] [review]
14/16] _mcd_master_account_replace_transport: inline into  caller and simplify

Review of attachment 84863 [details] [review]:
-----------------------------------------------------------------

++
Comment 31 Guillaume Desmottes 2013-08-30 09:39:04 UTC
Comment on attachment 84864 [details] [review]
15/16] Remove the remains of McdTransportPlugin

Review of attachment 84864 [details] [review]:
-----------------------------------------------------------------

++ nice cleaning!
Comment 32 Guillaume Desmottes 2013-08-30 09:39:19 UTC
Comment on attachment 84865 [details] [review]
16/16] Remove unused signal McdAccount::connection-process

Review of attachment 84865 [details] [review]:
-----------------------------------------------------------------

++
Comment 33 Simon McVittie 2013-08-30 12:31:31 UTC
(In reply to comment #20)
> mcd_operation_take_mission, _remove_mission: do not be  virtual
> 
> you didn't remove those from the .h file as well?

Will do.

(In reply to comment #24)
> 08/16] Remove the concept of binding accounts to transports
> 
> Patch looks ok but that means we'll have to WONTFIX bug #41148

I'm not sure that having MC try to understand account/transport binding ever made sense. I'll reply on that bug.

I could see whether I can make MC disconnect and reconnect everything when the default route changes, if that would help? That'd be a good first approximation (and is what this transport API was meant to do, except I'm not sure it worked like that even on Maemo, and it certainly didn't work for our NM/ConnMan support).

(In reply to comment #25)
> 09/16] Put the connectivity monitor in the McdAccountManager
>
> shouldn't you unref it when disposing?

Maybe. I'll check.
Comment 34 Simon McVittie 2013-09-03 15:09:58 UTC
(In reply to comment #20)
> mcd_operation_take_mission, _remove_mission: do not be  virtual
> you didn't remove those from the .h file as well?

No, that's correct. The functions still exist, and are called from elsewhere - they're just not virtual.

(I deleted the current extern mcd_..._mission wrappers, renamed the static base-class implementations from _mcd_..._mission to mcd_..._mission and made them extern.)
Comment 35 Simon McVittie 2013-09-03 17:56:29 UTC
> (In reply to comment #24)
> > 08/16] Remove the concept of binding accounts to transports
> > 
> > Patch looks ok but that means we'll have to WONTFIX bug #41148
> 
> I'm not sure that having MC try to understand account/transport binding ever
> made sense. I'll reply on that bug.

Are you convinced by Will's and my reasoning?

> (In reply to comment #25)
> > 09/16] Put the connectivity monitor in the McdAccountManager
> >
> > shouldn't you unref it when disposing?
> 
> Maybe. I'll check.

Yes, and I should also have unreffed it when a McdAccount is disposed. Fixed that...
Comment 36 Simon McVittie 2013-09-03 17:58:03 UTC
Created attachment 85130 [details] [review]
[08/16 v2] Put the connectivity monitor in the McdAccountManager

---

v2: unref it in dispose.
Comment 37 Simon McVittie 2013-09-03 17:58:44 UTC
Created attachment 85131 [details] [review]
[09/16 v2] McdAccount: have a reference to the connectivity  monitor

---

v2: unref it in dispose.
Comment 38 Guillaume Desmottes 2013-09-04 07:55:20 UTC
Comment on attachment 85130 [details] [review]
[08/16 v2] Put the connectivity monitor in the McdAccountManager

Review of attachment 85130 [details] [review]:
-----------------------------------------------------------------

++
Comment 39 Guillaume Desmottes 2013-09-04 07:55:23 UTC
Comment on attachment 85131 [details] [review]
[09/16 v2] McdAccount: have a reference to the connectivity  monitor

Review of attachment 85131 [details] [review]:
-----------------------------------------------------------------

++
Comment 40 Guillaume Desmottes 2013-09-04 07:59:42 UTC
(In reply to comment #35)
> > (In reply to comment #24)
> > > 08/16] Remove the concept of binding accounts to transports
> > > 
> > > Patch looks ok but that means we'll have to WONTFIX bug #41148
> > 
> > I'm not sure that having MC try to understand account/transport binding ever
> > made sense. I'll reply on that bug.
> 
> Are you convinced by Will's and my reasoning?

Yep; I closed the bug.

Feel free to merge your patches.
Comment 41 Simon McVittie 2013-09-04 12:55:50 UTC
Merged \o/


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.