On Tue, Dec 10, 2019 at 04:08:10PM +0200, Jussi Laakkonen wrote:
This change improves the saving of the VPN provider values to disk
immediately after the value has been changed on a property. To avoid
unnecessary writes to disk the changes are not written when a property
change, or clearing a property, does not introduce a change to its
value. Thus, PropertyChanged signal is emitted only when the property
value has been changed.
With any other than UserRoutes property simple value comparison is done.
If the UserRoutes are changed these are read from D-Bus message into
sorted list that is compared against the sorted list of saved
UserRoutes. Having the lists sorted will increase performance when
comparing them, especially if the lists are long. For this a
compare_route() is implemented to support sorting the rules by 1) IP
protocol type, 2) network addresses, 3) netmask addresses and 4) gateway
The set_string() is amended to return -EALREADY when there is no change
in the property value. In case the property value is changed 0 is
returned. Handling of the return value is added to set_property() and
clear_property() functions registered to VPN provider D-Bus interface.
In both of these writing the changes to disk depends on the success of
the change. Both, set_property() and clear_property() functions now
return also PermissionDenied as error if immutable property is attempted
to be changed.
This change has the effect of not reseting errors and not setting the
VPN provider to idle if it is in error state when a single property is
attempted to saved without change, or an immutable value is attempted
to be cleared. In order to have the state changed and errors cleared, a
property value has to be changed.