Ensure that we unlock the pool as appropriate
authorAlan T. DeKok <aland@freeradius.org>
Fri, 24 Jan 2014 15:59:55 +0000 (10:59 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 24 Jan 2014 15:59:55 +0000 (10:59 -0500)
src/main/connection.c

index 38edfbc..4464a49 100644 (file)
@@ -1043,6 +1043,9 @@ void *fr_connection_reconnect(fr_connection_pool_t *pool, void *conn)
        this = fr_connection_find(pool, conn);
        if (!this) return NULL;
 
+       /*
+        *      The pool is now locked.
+        */
        conn_number = this->number;
 
        DEBUG("%s: Reconnecting (%" PRIu64 ")", pool->log_prefix, conn_number);
@@ -1070,13 +1073,13 @@ void *fr_connection_reconnect(fr_connection_pool_t *pool, void *conn)
                        pool->active--;
 
                        fr_connection_close(pool, this);
-                       pthread_mutex_unlock(&pool->mutex);
                }
 
                /*
                 *      We failed to create a new socket.
                 *      Try to grab an existing one.
                 */
+               pthread_mutex_unlock(&pool->mutex);
                new_conn = fr_connection_get(pool);
                if (new_conn) return new_conn;