int reuse_orphan = 0;
int init_mux = 0;
int err;
+ int was_unused = 0;
/* This will catch some corner cases such as lying connections resulting from
s->txn && (s->txn->flags & TX_NOT_FIRST)) &&
srv->curr_idle_nb > 0) {
srv_conn = conn_backend_get(srv, 0);
+ was_unused = 1;
}
else if (srv->safe_conns &&
((s->txn && (s->txn->flags & TX_NOT_FIRST)) ||
(s->be->options & PR_O_REUSE_MASK) >= PR_O_REUSE_AGGR) &&
srv->curr_safe_nb > 0) {
srv_conn = conn_backend_get(srv, 1);
+ was_unused = 1;
}
else if (srv->idle_conns &&
((s->be->options & PR_O_REUSE_MASK) == PR_O_REUSE_ALWS) &&
srv->curr_idle_nb > 0) {
srv_conn = conn_backend_get(srv, 0);
+ was_unused = 1;
}
/* If we've picked a connection from the pool, we now have to
* detach it. We may have to get rid of the previous idle
/* no reuse or failed to reuse the connection above, pick a new one */
if (!srv_conn) {
srv_conn = conn_new();
+ was_unused = 1;
if (srv_conn)
srv_conn->target = s->target;
srv_cs = NULL;
}
- if (srv_conn && srv) {
+ if (srv_conn && srv && was_unused) {
_HA_ATOMIC_ADD(&srv->curr_used_conns, 1);
/* It's ok not to do that atomically, we don't need an
* exact max.