aboutsummaryrefslogtreecommitdiffstats
path: root/src/diagnostic/diagnostic-manager.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-30 17:23:02 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-04-11 12:41:42 +0200
commit0ebc7362ff32637ac839b0b5adf9678277c9c332 (patch)
tree0fd259a41aaca72aa32208af9b1964bfa1ab6dfb /src/diagnostic/diagnostic-manager.cpp
parent46d396e04947a76756739576a29c8369f8cd0c50 (diff)
Handle simultaneous subscription to diagnostic messages.
Delay new recurring requests if there are already existing in flight and cleanup active request to correctly set in_flight_ flag to false else new request can't be launched as there is always an old one considered running... Modify a little bit DEBUG message and cleanup useless code. Change-Id: I39f865bbc6d00188d3cddd1d81437b9e3ca51269 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/diagnostic/diagnostic-manager.cpp')
-rw-r--r--src/diagnostic/diagnostic-manager.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/diagnostic/diagnostic-manager.cpp b/src/diagnostic/diagnostic-manager.cpp
index 89999f4f..5834c35d 100644
--- a/src/diagnostic/diagnostic-manager.cpp
+++ b/src/diagnostic/diagnostic-manager.cpp
@@ -369,18 +369,24 @@ bool diagnostic_manager_t::add_recurring_request(DiagnosticRequest* request, con
wait_for_multiple_responses, decoder, callback, frequencyHz);
entry->set_handle(shims_, request);
- char request_string[128] = {0};
- diagnostic_request_to_string(&entry->get_handle()->request, request_string,
- sizeof(request_string));
+ //start_diagnostic_request(&shims_, entry->get_handle());
+ //char request_string[128] = {0};
+ //diagnostic_request_to_string(&entry->get_handle()->request, request_string,
+ // sizeof(request_string));
uint64_t usec;
sd_event_now(afb_daemon_get_event_loop(binder_interface->daemon), CLOCK_BOOTTIME, &usec);
+ if(recurring_requests_.size() > 0)
+ {
+ DEBUG(binder_interface, "add_recurring_request: Added 100ms to usec to stagger sending requests");
+ usec += 100000;
+ }
- DEBUG(binder_interface, "add_recurring_request: Added recurring diagnostic request (freq: %f) on bus %s: (%s) at %ld",
+ DEBUG(binder_interface, "add_recurring_request: Added recurring diagnostic request (freq: %f) on bus %s at %ld. Event loop state: %d",
frequencyHz,
bus_.c_str(),
- request_string,
- usec);
+ usec,
+ sd_event_get_state(afb_daemon_get_event_loop(binder_interface->daemon)));
if(sd_event_add_time(afb_daemon_get_event_loop(binder_interface->daemon), &source,
CLOCK_BOOTTIME, usec, TIMERFD_ACCURACY, send_request, request) < 0)
@@ -468,6 +474,7 @@ int diagnostic_manager_t::send_request(sd_event_source *s, uint64_t usec, void *
DiagnosticRequest* request = (DiagnosticRequest*)userdata;
active_diagnostic_request_t* adr = dm.find_recurring_request(request);
+ dm.cleanup_active_requests(false);
if(adr != nullptr && adr->get_can_bus_dev() == dm.get_can_bus_dev() && adr->should_send() &&
dm.clear_to_send(adr))
{