Thanks very much for validating my patch so quickly, Beniamino. I'm happy I
can roll this out quickly, because this would have caused us a lot of
issues. I'll make a Ubuntu bug report and hopefully try to get this merged
into Ubuntu trusty hopefully.

Simon

On Wed, Aug 10, 2016 at 2:37 PM, Beniamino Galvani <bgalv...@redhat.com>
wrote:

> On Wed, Aug 10, 2016 at 01:50:53PM +0200, Simon Wydooghe wrote:
> > This is the patch I made to nm-device.c:
> >
> > --- nm-device.c 2016-08-10 13:45:09.000000000 +0200
> > +++ nm-device_patched.c 2016-08-10 13:46:30.408878875 +0200
> > @@ -1267,7 +1267,7 @@
> >                 s_con = nm_connection_get_setting_connection
> (connection);
> >                 g_assert (s_con);
> >                 if (nm_setting_connection_get_autoconnect (s_con))
> > -                       available_conns = g_slist_prepend
> (available_conns,
> > connection);
> > +                       available_conns = g_slist_append
> (available_conns,
> > connection);
> >         }
> >
> >         if (!available_conns)
> >
>
> This seems correct, as auto_activate_device() calls
> nm_settings_get_connections() which sorts connections by decreasing
> timestamp and thus @connections in
> nm_device_get_best_auto_connection() are already in the 'right' order;
> while looping through the elements we must maintain the same order
> also in @available_conns.
>
> As appending to a GSList in a loop becomes O(n^2), you could instead
> add a:
>
>  available_conns = g_slist_reverse (available_conns);
>
> after
>         if (!available_conns)
>                 return NULL;
>
> to make it a bit more efficient [1]. But probably the improvement is
> non-existent for small connection numbers, so either way is fine.
>
> Beniamino
>
> [1] https://developer.gnome.org/glib/stable/glib-Singly-
> Linked-Lists.html#g-slist-append
>
_______________________________________________
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to