From: Alan T. DeKok Date: Wed, 2 May 2012 17:23:49 +0000 (+0200) Subject: delete means release, too X-Git-Tag: release_3_0_0_beta0~203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=268bca14ec66b470aceb5cac4b2ec44d44f99bca;p=thirdparty%2Ffreeradius-server.git delete means release, too --- diff --git a/src/main/connection.c b/src/main/connection.c index 01382b562f2..bd265515a44 100644 --- a/src/main/connection.c +++ b/src/main/connection.c @@ -33,6 +33,8 @@ RCSID("$Id$") typedef struct fr_connection_t fr_connection_t; +static int fr_connection_pool_check(fr_connection_pool_t *fc); + struct fr_connection_t { fr_connection_t *prev, *next; @@ -277,6 +279,8 @@ static void fr_connection_close(fr_connection_pool_t *fc, rad_assert(this->used == FALSE); + DEBUG("%s: Closing connection (%i)", fc->log_prefix, this->number); + fr_connection_unlink(fc, this); fc->delete(fc->ctx, this->connection); rad_assert(fc->num > 0); @@ -318,13 +322,19 @@ int fr_connection_del(fr_connection_pool_t *fc, void *conn) this = fr_connection_find(fc, conn); if (!this) return 0; + /* + * If it's used, release it. + */ if (this->used) { - pthread_mutex_unlock(&fc->mutex); - return 0; + rad_assert(this->used == TRUE); + this->used = FALSE; + + rad_assert(fc->active > 0); + fc->active--; } fr_connection_close(fc, this); - pthread_mutex_unlock(&fc->mutex); + fr_connection_pool_check(fc); return 1; } @@ -333,6 +343,8 @@ void fr_connection_pool_delete(fr_connection_pool_t *fc) { fr_connection_t *this, *next; + if (!fc) return; + DEBUG("%s: Removing connection pool", fc->log_prefix); pthread_mutex_lock(&fc->mutex);