- if (timeout <= 0) {
-
- /* I wake up every 'p' seconds to check for
- * timeouts on some more peers. I try to check
- * every connection 'n' times within the global
- * minimum of all keepalive and timeout intervals,
- * to ensure I attend to every connection within
- * (n+1)/n times its timeout intervals. */
-
- const int p = 1;
- const int n = 3;
- unsigned long min_timeout;
- int chunk;
-
- if (kranal_data.kra_new_min_timeout != MAX_SCHEDULE_TIMEOUT) {
- /* new min timeout set: restart min timeout scan */
- next_min_timeout = MAX_SCHEDULE_TIMEOUT;
- base_index = conn_index - 1;
- if (base_index < 0)
- base_index = conn_entries - 1;
-
- if (kranal_data.kra_new_min_timeout < current_min_timeout) {
- current_min_timeout = kranal_data.kra_new_min_timeout;
- CWARN("Set new min timeout %ld\n",
- current_min_timeout);
- }
-
- kranal_data.kra_new_min_timeout = MAX_SCHEDULE_TIMEOUT;
- }
- min_timeout = current_min_timeout;
-
- spin_unlock_irqrestore(&kranal_data.kra_reaper_lock,
- flags);
-
- LASSERT (min_timeout > 0);
-
- /* Compute how many table entries to check now so I
- * get round the whole table fast enough (NB I do
- * this at fixed intervals of 'p' seconds) */
- chunk = conn_entries;
- if (min_timeout > n * p)
- chunk = (chunk * n * p) / min_timeout;
- if (chunk == 0)
- chunk = 1;
-
- for (i = 0; i < chunk; i++) {
- kranal_reaper_check(conn_index,
- &next_min_timeout);
- conn_index = (conn_index + 1) % conn_entries;
- }