* immediately assigned when SN_DIRECT is determined. Both must be cleared
* when clearing SN_DIRECT (eg: redispatch).
* - ->srv has no meaning without SN_ASSIGNED and must not be checked without
- * it. ->prev_srv should be used to check previous ->srv. If SN_ASSIGNED is
- * set and sess->srv is NULL, then it is a dispatch or proxy mode.
+ * it. ->target and ->target_type may be used to check previous ->srv after
+ * a failed connection attempt.
* - a session being processed has srv_conn set.
* - srv_conn might remain after SN_DIRECT has been reset, but the assigned
* server should eventually be released.
struct stream_interface si[2]; /* client and server stream interfaces */
struct server *srv; /* the server the session will be running or has been running on */
struct server *srv_conn; /* session already has a slot on a server and is not in queue */
- struct server *prev_srv; /* the server the was running on, after a redispatch, otherwise NULL */
struct target target; /* target to use for this session */
struct pendconn *pend_pos; /* if not NULL, points to the position in the pending queue */
struct http_txn txn; /* current HTTP transaction being processed. Should become a list. */
*
* This function MAY NOT be called with SN_ASSIGNED already set. If the session
* had a server previously assigned, it is rebalanced, trying to avoid the same
- * server.
+ * server, which should still be present in s->srv before the call.
* The function tries to keep the original connection slot if it reconnects to
* the same server, otherwise it releases it and tries to offer it.
*
{
struct server *conn_slot;
+ struct server *prev_srv;
int err;
#ifdef DEBUG_FULL
if (unlikely(s->pend_pos || s->flags & SN_ASSIGNED))
goto out_err;
- s->prev_srv = s->prev_srv;
+ prev_srv = s->srv;
conn_slot = s->srv_conn;
/* We have to release any connection slot before applying any LB algo,
*/
switch (s->be->lbprm.algo & BE_LB_LKUP) {
case BE_LB_LKUP_RRTREE:
- s->srv = fwrr_get_next_server(s->be, s->prev_srv);
+ s->srv = fwrr_get_next_server(s->be, prev_srv);
break;
case BE_LB_LKUP_LCTREE:
- s->srv = fwlc_get_next_server(s->be, s->prev_srv);
+ s->srv = fwlc_get_next_server(s->be, prev_srv);
break;
case BE_LB_LKUP_CHTREE:
case BE_LB_LKUP_MAP:
if ((s->be->lbprm.algo & BE_LB_KIND) == BE_LB_KIND_RR) {
if (s->be->lbprm.algo & BE_LB_LKUP_CHTREE)
- s->srv = chash_get_next_server(s->be, s->prev_srv);
+ s->srv = chash_get_next_server(s->be, prev_srv);
else
- s->srv = map_get_server_rr(s->be, s->prev_srv);
+ s->srv = map_get_server_rr(s->be, prev_srv);
break;
}
else if ((s->be->lbprm.algo & BE_LB_KIND) != BE_LB_KIND_HI) {
*/
if (!s->srv) {
if (s->be->lbprm.algo & BE_LB_LKUP_CHTREE)
- s->srv = chash_get_next_server(s->be, s->prev_srv);
+ s->srv = chash_get_next_server(s->be, prev_srv);
else
- s->srv = map_get_server_rr(s->be, s->prev_srv);
+ s->srv = map_get_server_rr(s->be, prev_srv);
}
/* end of map-based LB */
err = SRV_STATUS_FULL;
goto out;
}
- else if (s->srv != s->prev_srv) {
+ else if (s->srv != prev_srv) {
s->be->counters.cum_lbconn++;
s->srv->counters.cum_lbconn++;
}
err = SRV_STATUS_OK;
if (!(s->flags & SN_ASSIGNED)) {
+ struct server *prev_srv = s->srv;
+
err = assign_server(s);
- if (s->prev_srv) {
+ if (prev_srv) {
/* This session was previously assigned to a server. We have to
* update the session's and the server's stats :
* - if the server changed :
* - if the server remained the same : update retries.
*/
- if (s->prev_srv != s->srv) {
+ if (prev_srv != s->srv) {
if ((s->txn.flags & TX_CK_MASK) == TX_CK_VALID) {
s->txn.flags &= ~TX_CK_MASK;
s->txn.flags |= TX_CK_DOWN;
}
s->flags |= SN_REDISP;
- s->prev_srv->counters.redispatches++;
+ prev_srv->counters.redispatches++;
s->be->counters.redispatches++;
} else {
- s->prev_srv->counters.retries++;
+ prev_srv->counters.retries++;
s->be->counters.retries++;
}
}
if (((t->flags & (SN_DIRECT|SN_FORCE_PRST)) == SN_DIRECT) &&
(t->be->options & PR_O_REDISP)) {
t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
- t->prev_srv = t->srv;
goto redispatch;
}