mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-14 11:31:59 +01:00
MINOR: servers: MAke sess_change_server() return the number of requests
Change sess_change_server() so that when it decrements the number of requests on the old server, if any, it returns that number to the caller. It will be useful to detect if the server was full, and is not anymore.
This commit is contained in:
parent
ead5f27477
commit
3eadd5b4eb
@ -72,7 +72,7 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch
|
||||
struct ist stream_generate_unique_id(struct stream *strm, struct lf_expr *format);
|
||||
|
||||
void stream_process_counters(struct stream *s);
|
||||
void sess_change_server(struct stream *strm, struct server *newsrv);
|
||||
int sess_change_server(struct stream *strm, struct server *newsrv);
|
||||
struct task *process_stream(struct task *t, void *context, unsigned int state);
|
||||
void default_srv_error(struct stream *s, struct stconn *sc);
|
||||
|
||||
|
||||
11
src/stream.c
11
src/stream.c
@ -2850,10 +2850,12 @@ void stream_update_time_stats(struct stream *s)
|
||||
* current connection slot. This function also notifies any LB algo which might
|
||||
* expect to be informed about any change in the number of active streams on a
|
||||
* server.
|
||||
* Returns the number of simultaneous requests on the old server.
|
||||
*/
|
||||
void sess_change_server(struct stream *strm, struct server *newsrv)
|
||||
int sess_change_server(struct stream *strm, struct server *newsrv)
|
||||
{
|
||||
struct server *oldsrv = strm->srv_conn;
|
||||
int count = -1;
|
||||
|
||||
/* Dynamic servers may be deleted during process lifetime. This
|
||||
* operation is always conducted under thread isolation. Several
|
||||
@ -2875,8 +2877,8 @@ void sess_change_server(struct stream *strm, struct server *newsrv)
|
||||
* served field has been incremented, so we have to decrement it now.
|
||||
*/
|
||||
if (oldsrv)
|
||||
_HA_ATOMIC_DEC(&oldsrv->served);
|
||||
return;
|
||||
count = _HA_ATOMIC_SUB_FETCH(&oldsrv->served, 1);
|
||||
return count;
|
||||
}
|
||||
|
||||
if (oldsrv) {
|
||||
@ -2891,7 +2893,7 @@ void sess_change_server(struct stream *strm, struct server *newsrv)
|
||||
*/
|
||||
_HA_ATOMIC_DEC(&oldsrv->proxy->served);
|
||||
stream_del_srv_conn(strm);
|
||||
_HA_ATOMIC_DEC(&oldsrv->served);
|
||||
count = _HA_ATOMIC_SUB_FETCH(&oldsrv->served, 1);
|
||||
__ha_barrier_atomic_store();
|
||||
if (oldsrv->proxy->lbprm.server_drop_conn)
|
||||
oldsrv->proxy->lbprm.server_drop_conn(oldsrv);
|
||||
@ -2904,6 +2906,7 @@ void sess_change_server(struct stream *strm, struct server *newsrv)
|
||||
newsrv->proxy->lbprm.server_take_conn(newsrv);
|
||||
stream_add_srv_conn(strm, newsrv);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Handle server-side errors for default protocols. It is called whenever a a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user