Max in flight requests set to 8
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 22 Mar 2017 17:10:30 +0000 (17:10 +0000)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 23 Mar 2017 13:42:43 +0000 (14:42 +0100)
Change-Id: If2acf83a0f01741c90cab15e10188b2aeffd88b3

src/diagnostic/diagnostic-manager.cpp

index 151c78e..fcfd199 100644 (file)
@@ -25,6 +25,8 @@
 
 #define MAX_RECURRING_DIAGNOSTIC_FREQUENCY_HZ 10
 #define MAX_SIMULTANEOUS_DIAG_REQUESTS 50
+// There are only 8 slots of in flight diagnostic requests
+#define MAX_SIMULTANEOUS_IN_FLIGHT_REQUESTS 8
 #define TIMERFD_ACCURACY 0
 #define MICRO 1000000
 
@@ -412,17 +414,25 @@ bool diagnostic_manager_t::conflicting(active_diagnostic_request_t* request, act
 /// @brief Returns true if there are no other active requests to the same arbitration ID.
 bool diagnostic_manager_t::clear_to_send(active_diagnostic_request_t* request) const
 {
+       int total_in_flight = 0;
        for ( auto entry : non_recurring_requests_)
        {
                if(conflicting(request, entry))
                        return false;
+               if(entry->get_in_flight())
+                       total_in_flight++;
        }
 
        for ( auto entry : recurring_requests_)
        {
                if(conflicting(request, entry))
                        return false;
+               if(entry->get_in_flight())
+                       total_in_flight++;
        }
+
+       if(total_in_flight > MAX_SIMULTANEOUS_IN_FLIGHT_REQUESTS)
+               return false;
        return true;
 }