fr_trunk_connection_t *tconn; //!< Connection this request belongs to.
- uint8_t requeued; //!< How many times this request has been re-enqueued.
-
void *preq; //!< Data for the muxer to write to the connection.
void *rctx; //!< Resume ctx of the module.
bool signalled_inactive; //!< Connection marked full because of signal.
///< Will not automatically be marked active if
///< the number of requests associated with it
- ///< falls below max_requests_per_conn.
+ ///< falls below max_req_per_conn.
bool freeing; //!< Conn is being freed, cancel_sent state should
///< be skipped.
* number of connections, and maximum
* number of requests per connection.
*/
- if (trunk->conf->max_requests_per_conn > 0) {
+ if (trunk->conf->max_req_per_conn > 0) {
uint64_t total_reqs;
total_reqs = fr_trunk_request_count_by_state(trunk, FR_TRUNK_CONN_ALL, FR_TRUNK_REQUEST_ALL) + 1;
- limit = trunk->conf->max_connections * (uint64_t)trunk->conf->max_requests_per_conn;
+ limit = trunk->conf->max_connections * (uint64_t)trunk->conf->max_req_per_conn;
if ((limit > 0) && (total_reqs > limit)) {
ROPTIONAL(RWARN, WARN, "Refusing to enqueue requests - "
"Limit of %"PRIu64" requests reached", limit);
fr_trunk_t *trunk = tconn->trunk;
uint32_t count;
- if (!trunk->conf->max_requests_per_conn ||
+ if (!trunk->conf->max_req_per_conn ||
tconn->signalled_inactive ||
(tconn->state != FR_TRUNK_CONN_ACTIVE)) return;
count = fr_trunk_request_count_by_connection(tconn, FR_TRUNK_REQUEST_ALL);
- if (count >= trunk->conf->max_requests_per_conn) trunk_connection_enter_inactive(tconn);
+ if (count >= trunk->conf->max_req_per_conn) trunk_connection_enter_inactive(tconn);
}
/** Automatically mark a connection as active
(tconn->state != FR_TRUNK_CONN_INACTIVE)) return;
count = fr_trunk_request_count_by_connection(tconn, FR_TRUNK_REQUEST_ALL);
- if ((trunk->conf->max_requests_per_conn == 0) || (count < trunk->conf->max_requests_per_conn)) {
+ if ((trunk->conf->max_req_per_conn == 0) || (count < trunk->conf->max_req_per_conn)) {
trunk_connection_enter_active(tconn);
}
}
*/
if (conn_count > 0) {
average = req_count / (conn_count + 1);
- if (average < trunk->conf->req_per_conn_target) {
+ if (average < trunk->conf->target_req_per_conn) {
DEBUG4("Not opening connection - Would leave us below our target req per conn "
- "(%u vs %u)", average, trunk->conf->req_per_conn_target);
+ "(%u vs %u)", average, trunk->conf->target_req_per_conn);
goto done;
}
}
* will that take us above our target threshold.
*/
average = req_count / (conn_count - 1);
- if (average > trunk->conf->req_per_conn_target) {
+ if (average > trunk->conf->target_req_per_conn) {
DEBUG4("Not closing connection - Would leave us above our target req per conn "
- "(%u vs %u)", average, trunk->conf->req_per_conn_target);
+ "(%u vs %u)", average, trunk->conf->target_req_per_conn);
goto done;
}
* No connections, but we do have requests
*/
if (conn_count == 0) {
- if ((req_count > 0) && (trunk->conf->req_per_conn_target > 0)) goto above_target;
+ if ((req_count > 0) && (trunk->conf->target_req_per_conn > 0)) goto above_target;
goto done;
}
if (req_count == 0) {
- if (trunk->conf->req_per_conn_target > 0) goto below_target;
+ if (trunk->conf->target_req_per_conn > 0) goto below_target;
goto done;
}
* Calculate the average
*/
average = req_count / conn_count;
- if (average > trunk->conf->req_per_conn_target) {
+ if (average > trunk->conf->target_req_per_conn) {
above_target:
/*
* Edge - Below target to above target (too many requests per conn)
*/
if (trunk->last_above_target >= trunk->last_below_target) trunk->last_above_target = now;
- } else if (average < trunk->conf->req_per_conn_target) {
+ } else if (average < trunk->conf->target_req_per_conn) {
below_target:
/*
* Edge - Above target to below target (too few requests per conn)
uint16_t max_connections; //!< Maximum number of connections in the trunk.
- uint32_t req_per_conn_target; //!< How many pending requests should ideally be
+ uint32_t target_req_per_conn; //!< How many pending requests should ideally be
///< running on each connection. Averaged across
///< the 'active' set of connections.
+ uint32_t max_req_per_conn; //!< Maximum connections per request.
+ ///< Used to determine if we need to create new connections.
+
fr_time_delta_t open_delay; //!< How long we must be above target utilisation
///< to spawn a new connection.
fr_time_delta_t manage_interval; //!< How often we run the management algorithm to
///< open/close connections.
- uint32_t max_requests_per_conn; //!< Maximum connections per request.
- ///< Used to determine if we need to create new connections.
-
bool always_writable; //!< Set to true, if our ability to write requests to
///< a connection handle is not dependant on the state
///< of the underlying connection, i.e. if the library
///< used to implement the connection can always receive
- ///< and buffer new requests, irrespective of the state
+ ///< and buffer new requests irrespective of the state
///< of the underlying socket.
///< If this is true, #fr_trunk_connection_signal_writable
///< does not need to be called, and requests will be
TEST_CHECK(fr_trunk_connection_count_by_state(trunk, FR_TRUNK_CONN_CONNECTING) == 1);
- TEST_CASE("C1 connecting, !max_requests_per_conn - Enqueue MUST NOT spawn");
+ TEST_CASE("C1 connecting, !max_req_per_conn - Enqueue MUST NOT spawn");
fr_trunk_request_enqueue(&treq_b, trunk, request, preq, NULL);
TEST_CHECK(fr_trunk_connection_count_by_state(trunk, FR_TRUNK_CONN_CONNECTING) == 1);
TEST_CHECK(fr_trunk_connection_count_by_state(trunk, FR_TRUNK_CONN_ACTIVE) == 1);
- TEST_CASE("C1 active, !max_requests_per_conn - Enqueue MUST NOT spawn");
+ TEST_CASE("C1 active, !max_req_per_conn - Enqueue MUST NOT spawn");
fr_trunk_request_enqueue(&treq_c, trunk, request, preq, NULL);
TEST_CHECK(fr_trunk_connection_count_by_state(trunk, FR_TRUNK_CONN_ACTIVE) == 1);
fr_trunk_conf_t conf = {
.min_connections = 0, /* No connections on start */
.max_connections = 2,
- .max_requests_per_conn = 2,
- .req_per_conn_target = 2, /* One request per connection */
+ .max_req_per_conn = 2,
+ .target_req_per_conn = 2, /* One request per connection */
.manage_interval = NSEC * 0.5
};
test_proto_request_t *preq_a, *preq_b, *preq_c, *preq_d, *preq_e;