* for and if/else usage.
*/
static inline int may_dequeue_tasks(const struct server *s, const struct proxy *p) {
- return (s && (s->queue.length || (p->queue.length && srv_currently_usable(s))) &&
+ return (s && (s->queueslength || (p->queueslength && srv_currently_usable(s))) &&
(!s->maxconn || s->cur_sess < srv_dynamic_maxconn(s)));
}
* the backend's queue instead.
*/
if (curr &&
- (curr->queue.length || (curr->maxconn && curr->served >= srv_dynamic_maxconn(curr))))
+ (curr->queueslength || (curr->maxconn && curr->served >= srv_dynamic_maxconn(curr))))
curr = NULL;
return curr;
((s->sess->flags & SESS_FL_PREFER_LAST) ||
(!s->be->max_ka_queue ||
server_has_room(tmpsrv) || (
- tmpsrv->queue.length + 1 < s->be->max_ka_queue))) &&
+ tmpsrv->queueslength + 1 < s->be->max_ka_queue))) &&
srv_currently_usable(tmpsrv)) {
list_for_each_entry(conn, &pconns->conn_list, sess_el) {
if (!(conn->flags & CO_FL_WAIT_XPRT)) {
/* if there's some queue on the backend, with certain algos we
* know it's because all servers are full.
*/
- if (s->be->queue.length && s->be->served && s->be->queue.length != s->be->beconn &&
+ if (s->be->queueslength && s->be->served && s->be->queueslength != s->be->beconn &&
(((s->be->lbprm.algo & (BE_LB_KIND|BE_LB_NEED|BE_LB_PARM)) == BE_LB_ALGO_FAS)|| // first
((s->be->lbprm.algo & (BE_LB_KIND|BE_LB_NEED|BE_LB_PARM)) == BE_LB_ALGO_RR) || // roundrobin
((s->be->lbprm.algo & (BE_LB_KIND|BE_LB_NEED|BE_LB_PARM)) == BE_LB_ALGO_SRR))) { // static-rr
__ha_cpu_relax());
}
if (!got_it) {
- if (srv->maxqueue > 0 && srv->queue.length >= srv->maxqueue)
+ if (srv->maxqueue > 0 && srv->queueslength >= srv->maxqueue)
return SRV_STATUS_FULL;
p = pendconn_add(s);
}
smp->data.u.sint += (iterator->maxconn - iterator->cur_sess)
- + (iterator->maxqueue - iterator->queue.length);
+ + (iterator->maxqueue - iterator->queueslength);
}
return 1;
{
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = args->data.srv->queue.length;
+ smp->data.u.sint = args->data.srv->queueslength;
return 1;
}
return 0;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = srv->queue.length;
+ smp->data.u.sint = srv->queueslength;
return 1;
}
global.node,
(s->cur_eweight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,
(s->proxy->lbprm.tot_weight * s->proxy->lbprm.wmult + s->proxy->lbprm.wdiv - 1) / s->proxy->lbprm.wdiv,
- s->cur_sess, s->proxy->beconn - s->proxy->queue.length,
- s->queue.length);
+ s->cur_sess, s->proxy->beconn - s->proxy->queueslength,
+ s->queueslength);
if ((s->cur_state == SRV_ST_STARTING) &&
ns_to_sec(now_ns) < s->counters.last_change + s->slowstart &&
"SIGHUP: Server %s/%s is %s. Conn: %d act, %d pend, %lld tot.",
p->id, s->id,
(s->cur_state != SRV_ST_STOPPED) ? "UP" : "DOWN",
- s->cur_sess, s->queue.length, s->counters.cum_sess);
+ s->cur_sess, s->queueslength, s->counters.cum_sess);
ha_warning("%s\n", trash.area);
send_log(p, LOG_NOTICE, "%s\n", trash.area);
s = s->next;
chunk_printf(&trash,
"SIGHUP: Proxy %s has no servers. Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
p->id,
- p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_sess);
+ p->feconn, p->beconn, p->totpend, p->queueslength, p->fe_counters.cum_conn, p->be_counters.cum_sess);
} else if (p->srv_act == 0) {
chunk_printf(&trash,
"SIGHUP: Proxy %s %s ! Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
p->id,
(p->srv_bck) ? "is running on backup servers" : "has no server available",
- p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_sess);
+ p->feconn, p->beconn, p->totpend, p->queueslength, p->fe_counters.cum_conn, p->be_counters.cum_sess);
} else {
chunk_printf(&trash,
"SIGHUP: Proxy %s has %d active servers and %d backup servers available."
" Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
p->id, p->srv_act, p->srv_bck,
- p->feconn, p->beconn, p->totpend, p->queue.length, p->fe_counters.cum_conn, p->be_counters.cum_sess);
+ p->feconn, p->beconn, p->totpend, p->queueslength, p->fe_counters.cum_conn, p->be_counters.cum_sess);
}
ha_warning("%s\n", trash.area);
send_log(p, LOG_NOTICE, "%s\n", trash.area);
return 1;
}
- lua_pushinteger(L, srv->queue.length);
+ lua_pushinteger(L, srv->queueslength);
return 1;
}
* case we simply remember it for later use if needed.
*/
s = eb32_entry(node, struct tree_occ, node)->server;
- if (!s->maxconn || (!s->queue.length && s->served < srv_dynamic_maxconn(s))) {
+ if (!s->maxconn || (!s->queueslength && s->served < srv_dynamic_maxconn(s))) {
if (s != srvtoavoid) {
srv = s;
break;
struct server *s;
s = eb32_entry(node, struct server, lb_node);
- if (!s->maxconn || (!s->queue.length && s->served < srv_dynamic_maxconn(s))) {
+ if (!s->maxconn || (!s->queueslength && s->served < srv_dynamic_maxconn(s))) {
if (s != srvtoavoid) {
srv = s;
break;
*/
static inline void fwlc_queue_srv(struct server *s, unsigned int eweight)
{
- unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queue.length);
+ unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queueslength);
s->lb_node.key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / eweight : 0;
eb32_insert(s->lb_tree, &s->lb_node);
*/
static void fwlc_srv_reposition(struct server *s)
{
- unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queue.length);
+ unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queueslength);
unsigned int eweight = _HA_ATOMIC_LOAD(&s->cur_eweight);
unsigned int new_key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / (eweight ? eweight : 1) : 0;
* likely to have released a connection or taken one leading
* to our target value (50% of the case in measurements).
*/
- inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queue.length);
+ inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queueslength);
eweight = _HA_ATOMIC_LOAD(&s->cur_eweight);
new_key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / (eweight ? eweight : 1) : 0;
if (!s->lb_node.node.leaf_p || s->lb_node.key != new_key) {
struct server *s;
s = eb32_entry(node, struct server, lb_node);
- if (!s->maxconn || s->served + s->queue.length < srv_dynamic_maxconn(s) + s->maxqueue) {
+ if (!s->maxconn || s->served + s->queueslength < srv_dynamic_maxconn(s) + s->maxqueue) {
if (s != srvtoavoid) {
srv = s;
break;
fwrr_update_position(grp, srv);
fwrr_dequeue_srv(srv);
grp->curr_pos++;
- if (!srv->maxconn || (!srv->queue.length && srv->served < srv_dynamic_maxconn(srv))) {
+ if (!srv->maxconn || (!srv->queueslength && srv->served < srv_dynamic_maxconn(srv))) {
/* make sure it is not the server we are trying to exclude... */
if (srv != srvtoavoid || avoided)
break;
avoididx = 0; /* shut a gcc warning */
do {
srv = px->lbprm.map.srv[newidx++];
- if (!srv->maxconn || (!srv->queue.length && srv->served < srv_dynamic_maxconn(srv))) {
+ if (!srv->maxconn || (!srv->queueslength && srv->served < srv_dynamic_maxconn(srv))) {
/* make sure it is not the server we are try to exclude... */
/* ...but remember that is was selected yet avoided */
avoided = srv;
_HA_ATOMIC_DEC(&px->queue.length);
_HA_ATOMIC_INC(&px->queue.idx);
+ _HA_ATOMIC_DEC(&px->queueslength);
return 1;
use_p:
_HA_ATOMIC_DEC(&srv->queue.length);
_HA_ATOMIC_INC(&srv->queue.idx);
+ _HA_ATOMIC_DEC(&srv->queueslength);
return 1;
}
struct server *srv;
struct queue *q;
unsigned int *max_ptr;
+ unsigned int *queueslength;
unsigned int old_max, new_max;
p = pool_alloc(pool_head_pendconn);
if (srv) {
q = &srv->queue;
max_ptr = &srv->counters.nbpend_max;
+ queueslength = &srv->queueslength;
}
else {
q = &px->queue;
max_ptr = &px->be_counters.nbpend_max;
+ queueslength = &px->queueslength;
}
p->queue = q;
p->queue_idx = _HA_ATOMIC_LOAD(&q->idx) - 1; // for logging only
- new_max = _HA_ATOMIC_ADD_FETCH(&q->length, 1);
+ new_max = _HA_ATOMIC_ADD_FETCH(queueslength, 1);
+ _HA_ATOMIC_INC(&q->length);
old_max = _HA_ATOMIC_LOAD(max_ptr);
while (new_max > old_max) {
if (likely(_HA_ATOMIC_CAS(max_ptr, &old_max, new_max)))
if (xferred) {
_HA_ATOMIC_SUB(&s->queue.length, xferred);
+ _HA_ATOMIC_SUB(&s->queueslength, xferred);
_HA_ATOMIC_SUB(&s->proxy->totpend, xferred);
}
if (px_xferred) {
_HA_ATOMIC_SUB(&px->queue.length, px_xferred);
+ _HA_ATOMIC_SUB(&px->queueslength, px_xferred);
_HA_ATOMIC_SUB(&px->totpend, px_xferred);
}
done:
" %d sessions active, %d requeued, %d remaining in queue",
s->proxy->srv_act, s->proxy->srv_bck,
(s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
- s->cur_sess, xferred, s->queue.length);
+ s->cur_sess, xferred, s->queueslength);
else
chunk_appendf(msg, ". %d active and %d backup servers online.%s"
" %d sessions requeued, %d total in queue",
s->proxy->srv_act, s->proxy->srv_bck,
(s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
- xferred, s->queue.length);
+ xferred, s->queueslength);
}
}
/* Ensure that there is no active/pending connection on the server. */
if (srv->curr_used_conns ||
- !eb_is_empty(&srv->queue.head) || srv_has_streams(srv)) {
+ srv->queueslength || srv_has_streams(srv)) {
msg = "Server still has connections attached to it, cannot remove it.";
goto leave;
}
field = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode));
break;
case ST_I_PX_QCUR:
- field = mkf_u32(0, sv->queue.length);
+ field = mkf_u32(0, sv->queueslength);
break;
case ST_I_PX_QMAX:
field = mkf_u32(FN_MAX, sv->counters.nbpend_max);
field = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode));
break;
case ST_I_PX_QCUR:
- field = mkf_u32(0, px->queue.length);
+ field = mkf_u32(0, px->queueslength);
break;
case ST_I_PX_QMAX:
field = mkf_u32(FN_MAX, px->be_counters.nbpend_max);