MINOR: server: replace the pendconns-related stuff with a struct queue
Just like for proxies, all three elements (pendconns, nbpend, queue_idx)
were moved to struct queue.
diff --git a/src/backend.c b/src/backend.c
index 1bd40fb..f6f3ef0 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -552,7 +552,7 @@
* the backend's queue instead.
*/
if (curr &&
- (curr->nbpend || (curr->maxconn && curr->served >= srv_dynamic_maxconn(curr))))
+ (curr->queue.length || (curr->maxconn && curr->served >= srv_dynamic_maxconn(curr))))
curr = NULL;
return curr;
@@ -624,7 +624,7 @@
((s->sess->flags & SESS_FL_PREFER_LAST) ||
(!s->be->max_ka_queue ||
server_has_room(tmpsrv) || (
- tmpsrv->nbpend + 1 < s->be->max_ka_queue))) &&
+ tmpsrv->queue.length + 1 < s->be->max_ka_queue))) &&
srv_currently_usable(tmpsrv)) {
list_for_each_entry(conn, &srv_list->conn_list, session_list) {
if (!(conn->flags & CO_FL_WAIT_XPRT)) {
@@ -1001,9 +1001,9 @@
* not full, in which case we have to return FULL.
*/
if (srv->maxconn &&
- (srv->nbpend || srv->served >= srv_dynamic_maxconn(srv))) {
+ (srv->queue.length || srv->served >= srv_dynamic_maxconn(srv))) {
- if (srv->maxqueue > 0 && srv->nbpend >= srv->maxqueue)
+ if (srv->maxqueue > 0 && srv->queue.length >= srv->maxqueue)
return SRV_STATUS_FULL;
p = pendconn_add(s);
@@ -2734,7 +2734,7 @@
}
smp->data.u.sint += (iterator->maxconn - iterator->cur_sess)
- + (iterator->maxqueue - iterator->nbpend);
+ + (iterator->maxqueue - iterator->queue.length);
}
return 1;
@@ -2981,7 +2981,7 @@
{
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = args->data.srv->nbpend;
+ smp->data.u.sint = args->data.srv->queue.length;
return 1;
}
@@ -3123,7 +3123,7 @@
return 0;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = srv->nbpend;
+ smp->data.u.sint = srv->queue.length;
return 1;
}
diff --git a/src/check.c b/src/check.c
index 68cb1c3..9c885ea 100644
--- a/src/check.c
+++ b/src/check.c
@@ -994,7 +994,7 @@
(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->nbpend);
+ s->queue.length);
if ((s->cur_state == SRV_ST_STARTING) &&
now.tv_sec < s->last_change + s->slowstart &&
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 743565d..3d68fc5 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -1728,7 +1728,7 @@
*/
if (global.nbthread > 1 &&
(agent->b.be->queue.length ||
- (srv && (srv->nbpend || (srv->maxconn && srv->served >=srv_dynamic_maxconn(srv)))))) {
+ (srv && (srv->queue.length || (srv->maxconn && srv->served >=srv_dynamic_maxconn(srv)))))) {
SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_NONE;
appctx->st0 = SPOE_APPCTX_ST_DISCONNECT;
appctx->st1 = SPOE_APPCTX_ERR_NONE;
diff --git a/src/haproxy.c b/src/haproxy.c
index 82efcd2..de13aba 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -904,7 +904,7 @@
"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->nbpend, s->counters.cum_sess);
+ s->cur_sess, s->queue.length, s->counters.cum_sess);
ha_warning("%s\n", trash.area);
send_log(p, LOG_NOTICE, "%s\n", trash.area);
s = s->next;
diff --git a/src/lb_chash.c b/src/lb_chash.c
index 23b2b12..023219c 100644
--- a/src/lb_chash.c
+++ b/src/lb_chash.c
@@ -443,7 +443,7 @@
* case we simply remember it for later use if needed.
*/
s = eb32_entry(node, struct tree_occ, node)->server;
- if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s))) {
+ if (!s->maxconn || (!s->queue.length && s->served < srv_dynamic_maxconn(s))) {
if (s != srvtoavoid) {
srv = s;
break;
diff --git a/src/lb_fas.c b/src/lb_fas.c
index 53bd039..d90388b 100644
--- a/src/lb_fas.c
+++ b/src/lb_fas.c
@@ -322,7 +322,7 @@
struct server *s;
s = eb32_entry(node, struct server, lb_node);
- if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s))) {
+ if (!s->maxconn || (!s->queue.length && s->served < srv_dynamic_maxconn(s))) {
if (s != srvtoavoid) {
srv = s;
break;
diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c
index ba1ca95..091241c 100644
--- a/src/lb_fwlc.c
+++ b/src/lb_fwlc.c
@@ -57,7 +57,7 @@
*/
static inline void fwlc_queue_srv(struct server *s, unsigned int eweight)
{
- unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->nbpend);
+ unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queue.length);
s->lb_node.key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / eweight : 0;
eb32_insert(s->lb_tree, &s->lb_node);
@@ -70,7 +70,7 @@
*/
static void fwlc_srv_reposition(struct server *s)
{
- unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->nbpend);
+ unsigned int inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queue.length);
unsigned int new_key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / s->cur_eweight : 0;
/* some calls will be made for no change (e.g connect_server() after
@@ -86,7 +86,7 @@
* 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->nbpend);
+ inflight = _HA_ATOMIC_LOAD(&s->served) + _HA_ATOMIC_LOAD(&s->queue.length);
new_key = inflight ? (inflight + 1) * SRV_EWGHT_MAX / s->cur_eweight : 0;
if (!s->lb_node.node.leaf_p || s->lb_node.key != new_key) {
eb32_delete(&s->lb_node);
@@ -347,7 +347,7 @@
struct server *s;
s = eb32_entry(node, struct server, lb_node);
- if (!s->maxconn || s->served + s->nbpend < srv_dynamic_maxconn(s) + s->maxqueue) {
+ if (!s->maxconn || s->served + s->queue.length < srv_dynamic_maxconn(s) + s->maxqueue) {
if (s != srvtoavoid) {
srv = s;
break;
diff --git a/src/lb_fwrr.c b/src/lb_fwrr.c
index d7f618f..74c7fb2 100644
--- a/src/lb_fwrr.c
+++ b/src/lb_fwrr.c
@@ -564,7 +564,7 @@
fwrr_update_position(grp, srv);
fwrr_dequeue_srv(srv);
grp->curr_pos++;
- if (!srv->maxconn || (!srv->nbpend && srv->served < srv_dynamic_maxconn(srv))) {
+ if (!srv->maxconn || (!srv->queue.length && srv->served < srv_dynamic_maxconn(srv))) {
/* make sure it is not the server we are trying to exclude... */
if (srv != srvtoavoid || avoided)
break;
diff --git a/src/lb_map.c b/src/lb_map.c
index b735678..592df91 100644
--- a/src/lb_map.c
+++ b/src/lb_map.c
@@ -230,7 +230,7 @@
avoididx = 0; /* shut a gcc warning */
do {
srv = px->lbprm.map.srv[newidx++];
- if (!srv->maxconn || (!srv->nbpend && srv->served < srv_dynamic_maxconn(srv))) {
+ if (!srv->maxconn || (!srv->queue.length && 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;
diff --git a/src/queue.c b/src/queue.c
index 40fabfc..c9134af 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -133,7 +133,7 @@
*/
static void __pendconn_unlink_srv(struct pendconn *p)
{
- p->strm->logs.srv_queue_pos += p->srv->queue_idx - p->queue_idx;
+ p->strm->logs.srv_queue_pos += p->srv->queue.idx - p->queue_idx;
eb32_delete(&p->node);
}
@@ -194,7 +194,7 @@
}
HA_SPIN_UNLOCK(SERVER_LOCK, &p->srv->lock);
if (done) {
- _HA_ATOMIC_DEC(&p->srv->nbpend);
+ _HA_ATOMIC_DEC(&p->srv->queue.length);
_HA_ATOMIC_DEC(&p->px->totpend);
}
}
@@ -273,8 +273,8 @@
rsrv = srv;
p = NULL;
- if (srv->nbpend)
- p = pendconn_first(&srv->pendconns);
+ if (srv->queue.length)
+ p = pendconn_first(&srv->queue.head);
pp = NULL;
if (srv_currently_usable(rsrv) && px->queue.length &&
@@ -320,9 +320,9 @@
goto unlinked;
use_p:
__pendconn_unlink_srv(p);
- _HA_ATOMIC_DEC(&srv->nbpend);
+ _HA_ATOMIC_DEC(&srv->queue.length);
_HA_ATOMIC_DEC(&px->totpend);
- srv->queue_idx++;
+ srv->queue.idx++;
unlinked:
p->strm_flags |= SF_ASSIGNED;
p->target = srv;
@@ -416,7 +416,7 @@
if (srv) {
unsigned int old_max, new_max;
- new_max = _HA_ATOMIC_ADD_FETCH(&srv->nbpend, 1);
+ new_max = _HA_ATOMIC_ADD_FETCH(&srv->queue.length, 1);
old_max = srv->counters.nbpend_max;
while (new_max > old_max) {
if (likely(_HA_ATOMIC_CAS(&srv->counters.nbpend_max, &old_max, new_max)))
@@ -425,8 +425,8 @@
__ha_barrier_atomic_store();
HA_SPIN_LOCK(SERVER_LOCK, &p->srv->lock);
- p->queue_idx = srv->queue_idx - 1; // for increment
- eb32_insert(&srv->pendconns, &p->node);
+ p->queue_idx = srv->queue.idx - 1; // for increment
+ eb32_insert(&srv->queue.head, &p->node);
HA_SPIN_UNLOCK(SERVER_LOCK, &p->srv->lock);
}
else {
@@ -465,7 +465,7 @@
if ((s->proxy->options & (PR_O_REDISP|PR_O_PERSIST)) != PR_O_REDISP)
return 0;
- for (node = eb32_first(&s->pendconns); node; node = nodeb) {
+ for (node = eb32_first(&s->queue.head); node; node = nodeb) {
nodeb = eb32_next(node);
p = eb32_entry(node, struct pendconn, node);
@@ -480,7 +480,7 @@
xferred++;
}
if (xferred) {
- _HA_ATOMIC_SUB(&s->nbpend, xferred);
+ _HA_ATOMIC_SUB(&s->queue.length, xferred);
_HA_ATOMIC_SUB(&s->proxy->totpend, xferred);
}
return xferred;
diff --git a/src/server.c b/src/server.c
index 141f1ba..5d869e6 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1370,13 +1370,13 @@
" %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->nbpend);
+ s->cur_sess, xferred, s->queue.length);
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->nbpend);
+ xferred, s->queue.length);
}
}
@@ -2163,7 +2163,7 @@
srv->obj_type = OBJ_TYPE_SERVER;
srv->proxy = proxy;
- srv->pendconns = EB_ROOT;
+ srv->queue.head = EB_ROOT;
LIST_APPEND(&servers_list, &srv->global_list);
LIST_INIT(&srv->srv_rec_item);
LIST_INIT(&srv->ip_rec_item);
@@ -4642,7 +4642,7 @@
* cleanup function should be implemented to be used here.
*/
if (srv->cur_sess || srv->curr_idle_conns ||
- !eb_is_empty(&srv->pendconns)) {
+ !eb_is_empty(&srv->queue.head)) {
cli_err(appctx, "Server still has connections attached to it, cannot remove it.");
goto out;
}
diff --git a/src/stats.c b/src/stats.c
index c8b5fb1..3458924 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -2141,7 +2141,7 @@
metric = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode));
break;
case ST_F_QCUR:
- metric = mkf_u32(0, sv->nbpend);
+ metric = mkf_u32(0, sv->queue.length);
break;
case ST_F_QMAX:
metric = mkf_u32(FN_MAX, sv->counters.nbpend_max);