{
fr_connection_t *this;
+ if (!fc || !conn) return NULL;
+
pthread_mutex_lock(&fc->mutex);
/*
{
fr_connection_t *this;
- if (!fc || !conn) return 0;
-
this = fr_connection_find(fc, conn);
- if (!this) {
- return 0;
- }
+ if (!this) return 0;
if (this->used) {
pthread_mutex_unlock(&fc->mutex);
}
+/*
+ * Called with the mutex held. Releases it.
+ */
static int fr_connection_pool_check(fr_connection_pool_t *fc)
{
int spare, spawn;
time_t now = time(NULL);
fr_connection_t *this, *next;
- if (fc->last_checked == now) return 1;
-
- pthread_mutex_lock(&fc->mutex);
+ if (fc->last_checked == now) {
+ pthread_mutex_unlock(&fc->mutex);
+ return 1;
+ }
spare = fc->num - fc->active;
if (spawn) {
pthread_mutex_unlock(&fc->mutex);
fr_connection_spawn(fc, now); /* ignore return code */
+ pthread_mutex_lock(&fc->mutex);
}
}
if (!fc) return 1;
- if (!conn) return fr_connection_pool_check(fc);
-
now = time(NULL);
pthread_mutex_lock(&fc->mutex);
+ if (!conn) return fr_connection_pool_check(fc);
+
for (this = fc->head; this != NULL; this = this->next) {
if (this->connection == conn) {
fr_connection_manage(fc, conn, now);
{
fr_connection_t *this;
- if (!fc || !conn) return;
-
this = fr_connection_find(fc, conn);
- if (!this) {
- return;
- }
+ if (!this) return;
rad_assert(this->used == TRUE);
this->used = FALSE;