BUG/MINOR: connections: Set idle_time before adding to idle list.
In srv_add_to_idle_list(), make sure we set the idle_time before we add
the connection to an idle list, not after, otherwise another thread may
grab it, set the idle_time to 0, only to have the original thread set it
back to now_ms.
This may have an impact, as in conn_free() we check idle_time to decide
if we should decrement the idle connection counters for the server.
diff --git a/include/proto/server.h b/include/proto/server.h
index 6eb4515..575e922 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -262,6 +262,7 @@
return 0;
}
MT_LIST_DEL(&conn->list);
+ conn->idle_time = now_ms;
if (is_safe) {
conn->flags = (conn->flags & ~CO_FL_LIST_MASK) | CO_FL_SAFE_LIST;
MT_LIST_ADDQ(&srv->safe_conns[tid], (struct mt_list *)&conn->list);
@@ -273,7 +274,6 @@
}
_HA_ATOMIC_ADD(&srv->curr_idle_thr[tid], 1);
- conn->idle_time = now_ms;
__ha_barrier_full();
if ((volatile void *)srv->idle_node.node.leaf_p == NULL) {
HA_SPIN_LOCK(OTHER_LOCK, &idle_conn_srv_lock);