On Fri, 2017-02-24 at 08:12 +0000, Jose Blanquicet wrote:
Or, maybe better, why ConnMan needs to access the file that early?
Shouldn't it be done when service goes into CONFIGURATION state or
READY state for new services? If it does not break any statistics
feature, I would suggest to completely remove that piece of code from
service_connect():
- if (__connman_stats_service_register(service) == 0) {
- __connman_stats_get(service, false,
- &service-
>stats.data);
- __connman_stats_get(service, true,
- &service-
>stats_roaming.data);
- }
What do yo think?
ConnMan statistics should count all the bytes sent via that service,
successful or not. Configuration state sounds about right, as then all
the bytes in the messages doing authentication are accounted for as
well. Unfortunately I think ethernet was skipping this state (or then
it was Associating, can't remember right now), but that should be
trivial to fix. We do want to have all bytes counted, as this is
especially important with oFono and cellular.
Unfortunately accounting is a bit broken at the moment. Stopping it
does not properly store the bytes seen and the only way to have ConnMan
account properly is to set up an external application to ask for
statistics. So the main part of the file writing is ok, but the logic
in service.c should be rewritte, it's now about two parts of the stats
code that push each other around. So the interaction should first be
cleared up from a service point of view, add simpler helper functions
capable of starting and stopping stat accounting. It may or may not be
beneficial to have the stats file created/opened and closed separately
from writing statistics values to it.
To fix this one, I'd start by verifying that Configuration is the
proper state to start accounting and all drivers follow this. Stopping
should happen when going back to Idle or Failure. Here the interface
going away triggers the service to stop, so something a bit smarter
needs to be done in order to pick up the last bytes sent. Same thing
happens when ConnMan is terminating, in addition the (idle) timeouts
are (currently) just removed when stopping.
Once that is done and is reliable, we'd need to upgrade to 64 bit stats
values. This is ok to change as the interface is marked experimental...
It would be very nice if you (or someone else) had the time to work on
this. I hacked a bit on this once upon a time, but realized twice that
it needs a bit more time to be solved nicely than I had on both
occasions.
Cheers,
Patrik