/********* END VARIABLES ************/
- static void circuit_expire_old_circuits(time_t now);
+ static void circuit_expire_old_circuits_clientside(time_t now);
static void circuit_increment_failure_count(void);
+long int lround(double x);
+
/** Return 1 if <b>circ</b> could be returned by circuit_get_best().
* Else return 0.
*/
* for too long and has no streams on it: mark it for close.
*/
static void
- circuit_expire_old_circuits(time_t now)
+ circuit_expire_old_circuits_clientside(time_t now)
{
circuit_t *circ;
- time_t cutoff = now - get_options()->CircuitIdleTimeout;
+ time_t cutoff;
+
+ if (circuit_build_times_needs_circuits(&circ_times)) {
+ /* Circuits should be shorter lived if we need more of them
+ * for learning a good build timeout */
+ cutoff = now - IDLE_TIMEOUT_WHILE_LEARNING;
+ } else {
+ cutoff = now - get_options()->CircuitIdleTimeout;
+ }
for (circ = global_circuitlist; circ; circ = circ->next) {
if (circ->marked_for_close || ! CIRCUIT_IS_ORIGIN(circ))