/* Instant death for (urgent) connections above limit */
timeout = 0;
} else {
+ unsigned int idle_slots_avail;
+ double idle_time_per_slot;
+
/* Kill duplicate connections quicker;
linearly based on the number of connections */
- timeout = ((max - idle_count) *
- (set->max_idle_time_msecs / max));
+ idle_slots_avail = max - idle_count;
+ idle_time_per_slot = (double)set->max_idle_time_msecs / max;
+ timeout = (unsigned int)(idle_time_per_slot * idle_slots_avail);
+ if (timeout < HTTP_CLIENT_MIN_IDLE_TIMEOUT_MSECS)
+ timeout = HTTP_CLIENT_MIN_IDLE_TIMEOUT_MSECS;
}
conn->to_idle = timeout_add_to(
#define HTTP_CLIENT_DEFAULT_BACKOFF_TIME_MSECS (100)
#define HTTP_CLIENT_DEFAULT_BACKOFF_MAX_TIME_MSECS (1000*60)
#define HTTP_CLIENT_DEFAULT_DNS_TTL_MSECS (1000*60*30)
+#define HTTP_CLIENT_MIN_IDLE_TIMEOUT_MSECS 50
/*
* Types