diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2010-07-09 10:10:09 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-07-09 05:14:03 -0300 |
commit | cfd8c99cccccd6bdb121f77bd8bf8eeb05b522ec (patch) | |
tree | ec58019b345a66fe8ddbfe860c8980acb7bb67e1 | |
parent | e9d553694c5863a89121ca9458ce95cdb478f3f1 (diff) | |
download | connman-cfd8c99cccccd6bdb121f77bd8bf8eeb05b522ec.tar.gz connman-cfd8c99cccccd6bdb121f77bd8bf8eeb05b522ec.tar.bz2 connman-cfd8c99cccccd6bdb121f77bd8bf8eeb05b522ec.zip |
Keep start/stop state of statistic timers
When starting a ethernet device the sequence of the
device state (UP, LOWER_UP) from RTNL is different then
by a WiFi device.
For an ethernet device the entering UP and LOWER_UP
arrives together. Whereas for WiFi device we get
a entering UP and leaving LOWER_UP. This results in
a call on lower_down first.
Unfortunatly, the stats_start and stats_stop should
be called in the right order. This fix tracks the
statistics enabled/disabled state.
-rw-r--r-- | src/service.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/service.c b/src/service.c index c76a9ee7..af8f2c42 100644 --- a/src/service.c +++ b/src/service.c @@ -38,6 +38,7 @@ static GHashTable *service_hash = NULL; struct connman_stats { connman_bool_t valid; + connman_bool_t enabled; unsigned int rx_packets_last; unsigned int tx_packets_last; unsigned int rx_packets; @@ -380,6 +381,8 @@ static void __connman_service_stats_start(struct connman_service *service) if (service->stats.timer == NULL) return; + service->stats.enabled = TRUE; + service->stats.time_start = service->stats.time; g_timer_start(service->stats.timer); @@ -396,12 +399,17 @@ static void __connman_service_stats_stop(struct connman_service *service) if (service->stats.timer == NULL) return; + if (service->stats.enabled == FALSE) + return; + __connman_counter_remove_service(service); g_timer_stop(service->stats.timer); seconds = g_timer_elapsed(service->stats.timer, NULL); service->stats.time = service->stats.time_start + seconds; + + service->stats.enabled = FALSE; } static int __connman_service_stats_load(struct connman_service *service, @@ -1843,6 +1851,7 @@ static void __connman_service_initialize(struct connman_service *service) service->order = 0; service->stats.valid = FALSE; + service->stats.enabled = FALSE; service->stats.timer = g_timer_new(); } |