Skip to content

Commit

Permalink
Expose connection pool state as a separate const'd struct
Browse files Browse the repository at this point in the history
Writing getters and setters is dumb
  • Loading branch information
arr2036 committed Jul 22, 2015
1 parent 295e72c commit a3fdb8d
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 90 deletions.
32 changes: 29 additions & 3 deletions src/include/connection.h
Expand Up @@ -35,6 +35,30 @@ extern "C" {

typedef struct fr_connection_pool_t fr_connection_pool_t;

typedef struct fr_connection_pool_state {
uint32_t pending; //!< Number of pending open connections.
time_t last_checked; //!< Last time we pruned the connection pool.
time_t last_spawned; //!< Last time we spawned a connection.
time_t last_failed; //!< Last time we tried to spawn a connection but failed.
time_t last_throttled; //!< Last time we refused to spawn a connection because
//!< the last connection failed, or we were already spawning
//!< a connection.
time_t last_at_max; //!< Last time we hit the maximum number of allowed
//!< connections.
struct timeval last_released; //!< Last time a connection was released.
struct timeval last_closed; //!< Last time a connection was closed.

int next_delay; //!< The next delay time. cleanup. Initialized to
//!< cleanup_interval, and decays from there.

uint64_t count; //!< Number of connections spawned over the lifetime
//!< of the pool.
uint32_t num; //!< Number of connections in the pool.
uint32_t active; //!< Number of currently reserved connections.

bool reconnecting; //!< We are currently reconnecting the pool.
} fr_connection_pool_state_t;

/** Alter the opaque data of a connection pool during reconnection event
*
* This function will be called whenever we have been signalled to
Expand Down Expand Up @@ -112,11 +136,13 @@ fr_connection_pool_t *fr_connection_pool_copy(TALLOC_CTX *ctx, fr_connection_poo
/*
* Pool get/set
*/
int fr_connection_pool_get_num(fr_connection_pool_t *pool);
struct timeval fr_connection_pool_timeout(fr_connection_pool_t *pool);

void const *fr_connection_pool_opaque(fr_connection_pool_t *pool);

struct timeval const *fr_connection_pool_get_timeout(fr_connection_pool_t *pool);
fr_connection_pool_state_t const *fr_connection_pool_state(fr_connection_pool_t *pool);

void fr_connection_pool_set_reconnect(fr_connection_pool_t *pool, fr_connection_pool_reconnect_t reconnect);
void fr_connection_pool_reconnect_func(fr_connection_pool_t *pool, fr_connection_pool_reconnect_t reconnect);

/*
* Pool management
Expand Down

0 comments on commit a3fdb8d

Please sign in to comment.