More conversion to FR_CONF_OFFSET
authorAlan T. DeKok <aland@freeradius.org>
Thu, 29 May 2014 17:47:49 +0000 (13:47 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 29 May 2014 17:48:11 +0000 (13:48 -0400)
and fix up the various dependent data types

src/main/connection.c

index b158c03..68d4549 100644 (file)
@@ -55,16 +55,16 @@ struct fr_connection {
        time_t          last_used;      //!< Last time the connection was
                                        //!< reserved.
 
-       uint64_t        num_uses;       //!< Number of times the connection
+       uint32_t        num_uses;       //!< Number of times the connection
                                        //!< has been reserved.
-       int             in_use;         //!< Whether the connection is currently
-                                       //!< reserved.
        uint64_t        number;         //!< Unique ID assigned when the
                                        //!< connection is created, these will
                                        //!< monotonically increase over the
                                        //!< lifetime of the connection pool.
        void            *connection;    //!< Pointer to whatever the module
                                        //!< uses for a connection handle.
+       bool            in_use;         //!< Whether the connection is currently
+                                       //!< reserved.
 #ifdef PTHREAD_DEBUG
        pthread_t       pthread_id;     //!< When 'in_use == true'
 #endif
@@ -80,15 +80,15 @@ struct fr_connection {
  * @see fr_connection
  */
 struct fr_connection_pool_t {
-       int             start;          //!< Number of initial connections
-       int             min;            //!< Minimum number of concurrent
+       uint32_t        start;          //!< Number of initial connections
+       uint32_t        min;            //!< Minimum number of concurrent
                                        //!< connections to keep open.
-       int             max;            //!< Maximum number of concurrent
+       uint32_t        max;            //!< Maximum number of concurrent
                                        //!< connections to allow.
-       int             spare;          //!< Number of spare connections to try
+       uint32_t        spare;          //!< Number of spare connections to try
        int             retry_delay;    //!< seconds to delay re-open
                                        //!< after a failed open.
-       int             cleanup_interval; //!< Initial timer for how
+       uint32_t        cleanup_interval; //!< Initial timer for how
                                          //!< often we sweep the pool
                                          //!< for free connections.
                                          //!< (0 is infinite).
@@ -100,13 +100,13 @@ struct fr_connection_pool_t {
                                        //!< cleanup.  Initialized to
                                        //!< cleanup_interval, and decays
                                        //!< from there.
-       uint64_t        max_uses;       //!< Maximum number of times a
+       uint32_t        max_uses;       //!< Maximum number of times a
                                        //!< connection can be used before being
                                        //!< closed.
-       int             lifetime;       //!< How long a connection can be open
+       uint32_t        lifetime;       //!< How long a connection can be open
                                        //!< before being closed (irrespective
                                        //!< of whether it's idle or not).
-       int             idle_timeout;   //!< How long a connection can be idle
+       uint32_t        idle_timeout;   //!< How long a connection can be idle
                                        //!< before being closed.
 
        bool            trigger;        //!< If true execute connection triggers
@@ -132,7 +132,7 @@ struct fr_connection_pool_t {
 
        uint64_t        count;          //!< Number of connections spawned over
                                        //!< the lifetime of the pool.
-       int             num;            //!< Number of connections in the pool.
+       uint32_t        num;            //!< Number of connections in the pool.
        int             active;         //!< Number of currently reserved
                                        //!< connections.
 
@@ -173,8 +173,7 @@ struct fr_connection_pool_t {
 #endif
 
 static const CONF_PARSER connection_config[] = {
-       { "start",    PW_TYPE_INTEGER, offsetof(fr_connection_pool_t, start),
-         0, "5" },
+       { "start",    FR_CONF_OFFSET(PW_TYPE_INTEGER, fr_connection_pool_t, start), "5" },
        { "min",      PW_TYPE_INTEGER, offsetof(fr_connection_pool_t, min),
          0, "5" },
        { "max",      PW_TYPE_INTEGER, offsetof(fr_connection_pool_t, max),
@@ -585,7 +584,7 @@ fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *parent,
                                              fr_connection_delete_t d,
                                              char const *prefix)
 {
-       int i;
+       uint32_t i;
        fr_connection_pool_t *pool;
        fr_connection_t *this;
        CONF_SECTION *modules;
@@ -678,10 +677,6 @@ fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *parent,
                pool->idle_timeout = 0;
        }
 
-       if (pool->cleanup_interval < 0) {
-               pool->cleanup_interval = 30;
-       }
-
        if ((pool->idle_timeout > 0) && (pool->cleanup_interval > pool->idle_timeout)) {
                pool->cleanup_interval = pool->idle_timeout;
        }
@@ -785,7 +780,7 @@ static int fr_connection_manage(fr_connection_pool_t *pool,
  */
 static int fr_connection_pool_check(fr_connection_pool_t *pool)
 {
-       int spawn, idle, extra;
+       uint32_t spawn, idle, extra;
        time_t now = time(NULL);
        fr_connection_t *this, *next;