int num_uses;
int used;
- int number; /* unique ID */
+ int number; /* unique ID */
void *connection;
};
int spare;
int cleanup_delay;
- int num;
- int active;
+ unsigned int count; /* num connections spawned */
+ int num; /* num connections in pool */
+ int active; /* num connections active */
time_t last_checked;
time_t last_spawned;
}
}
-
static fr_connection_t *fr_connection_spawn(fr_connection_pool_t *fc,
time_t now)
{
this->start = now;
this->connection = conn;
+ this->number = fc->count;
fr_connection_link(fc, this);
+ fc->count++;
fc->num++;
return this;
{
int i;
fr_connection_pool_t *fc;
+ fr_connection_t *this;
CONF_SECTION *cs;
if (!parent || !ctx || !c || !a || !d) return NULL;
*/
for (i = 0; i < fc->start; i++) {
time_t now = time(NULL);
-
- if (!fr_connection_spawn(fc, now)) {
+
+ this = fr_connection_spawn(fc, now);
+
+ if (!this) {
error:
fr_connection_pool_delete(fc);
return NULL;
}
+
+ /*
+ * If we don't set last_used here, the connection will be closed as
+ * idle, the first time get_connecton is called.
+ */
+ this->last_used = now;
}
return fc;
}
if ((fc->lifetime > 0) && ((this->start + fc->lifetime) < now))
- goto do_delete;
+ goto do_delete;
if ((fc->idle_timeout > 0) && ((this->last_used + fc->idle_timeout) < now))
- goto do_delete;
+ goto do_delete;
return 1;
}