MINOR: proxy: add 'served' field to proxy, equal to total of all servers'

This will allow lb_chash to determine the total active sessions for a
proxy without any computation.

Signed-off-by: Andrew Rodland <andrewr@vimeo.com>
This commit is contained in:
Andrew Rodland 2016-10-25 12:48:17 -04:00 committed by Willy Tarreau
parent b957109727
commit e168feb4a8
3 changed files with 4 additions and 0 deletions

View File

@ -277,6 +277,7 @@ struct proxy {
} tcp_rep;
struct server *srv, defsrv; /* known servers; default server configuration */
int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
int served; /* # of active sessions currently being served */
struct lbprm lbprm; /* load-balancing parameters */
char *cookie_domain; /* domain used to insert the cookie */
char *cookie_name; /* name of the cookie to look for */

View File

@ -126,6 +126,7 @@ struct stream *pendconn_get_next_strm(struct server *srv, struct proxy *px)
strm->target = &srv->obj_type;
stream_add_srv_conn(strm, srv);
srv->served++;
srv->proxy->served++;
if (px->lbprm.server_take_conn)
px->lbprm.server_take_conn(srv);

View File

@ -2515,6 +2515,7 @@ void sess_change_server(struct stream *sess, struct server *newsrv)
if (sess->srv_conn) {
sess->srv_conn->served--;
sess->srv_conn->proxy->served--;
if (sess->srv_conn->proxy->lbprm.server_drop_conn)
sess->srv_conn->proxy->lbprm.server_drop_conn(sess->srv_conn);
stream_del_srv_conn(sess);
@ -2522,6 +2523,7 @@ void sess_change_server(struct stream *sess, struct server *newsrv)
if (newsrv) {
newsrv->served++;
newsrv->proxy->served++;
if (newsrv->proxy->lbprm.server_take_conn)
newsrv->proxy->lbprm.server_take_conn(newsrv);
stream_add_srv_conn(sess, newsrv);