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);
* 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
* 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) {
*/
_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);
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