src/session.c
static int sess_update_st_cer(struct session *s, struct stream_interface *si)
{
	/* we probably have to release last session from the server */
	if (objt_server(s->target)) {
		health_adjust(objt_server(s->target), HANA_STATUS_L4_ERR);

		if (s->flags & SN_CURR_SESS) {
			s->flags &= ~SN_CURR_SESS;
			objt_server(s->target)->cur_sess--;
		}
	}

	/* ensure that we have enough retries left */
	si->conn_retries--;
	if (si->conn_retries < 0) {
		if (!si->err_type) {
			si->err_type = SI_ET_CONN_ERR;
			si->err_loc = objt_server(s->target);
		}

		if (objt_server(s->target))
			objt_server(s->target)->counters.failed_conns++;
		s->be->be_counters.failed_conns++;
		sess_change_server(s, NULL);
		if (may_dequeue_tasks(objt_server(s->target), s->be))
			process_srv_queue(objt_server(s->target));

		/* shutw is enough so stop a connecting socket */
		si_shutw(si);
		si->ob->flags |= CF_WRITE_ERROR;
		si->ib->flags |= CF_READ_ERROR;

		si->state = SI_ST_CLO;
		if (s->srv_error)
			s->srv_error(s, si);
		return 0;
	}

	/* If the "redispatch" option is set on the backend, we are allowed to
	 * retry on another server for the last retry. In order to achieve this,
	 * we must mark the session unassigned, and eventually clear the DIRECT
	 * bit to ignore any persistence cookie. We won't count a retry nor a
	 * redispatch yet, because this will depend on what server is selected.
	 */
	if (objt_server(s->target) && si->conn_retries == 0 &&
	    s->be->options & PR_O_REDISP && !(s->flags & SN_FORCE_PRST)) {
		sess_change_server(s, NULL);
		if (may_dequeue_tasks(objt_server(s->target), s->be))
			process_srv_queue(objt_server(s->target));

		s->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
		si->state = SI_ST_REQ;
	} else {
		if (objt_server(s->target))
			objt_server(s->target)->counters.retries++;
		s->be->be_counters.retries++;
		si->state = SI_ST_ASS;
	}

	if (si->flags & SI_FL_ERR) {
		/* The error was an asynchronous connection error, and we will
		 * likely have to retry connecting to the same server, most
		 * likely leading to the same result. To avoid this, we wait
		 * one second before retrying.
		 */

		if (!si->err_type)
			si->err_type = SI_ET_CONN_ERR;

		si->state = SI_ST_TAR;
		si->exp = tick_add(now_ms, MS_TO_TICKS(1000));
		return 0;
	}
	return 0;
}
/* This function is called with (si->state == SI_ST_CER) meaning that a
 * previous connection attempt has failed and that the file descriptor
 * has already been released. Possible causes include asynchronous error
 * notification and time out. Possible output states are SI_ST_CLO when
 * retries are exhausted, SI_ST_TAR when a delay is wanted before a new
 * connection attempt, SI_ST_ASS when it's wise to retry on the same server,
 * and SI_ST_REQ when an immediate redispatch is wanted. The buffers are
 * marked as in error state. It returns 0.
 */
This function is called with (si->state == SI_ST_CER) meaning that a
previous connection attempt has failed and that the file descriptor
has already been released. Possible causes include asynchronous error
notification and time out. Possible output states are SI_ST_CLO when
retries are exhausted, SI_ST_TAR when a delay is wanted before a new
connection attempt, SI_ST_ASS when it's wise to retry on the same server,
and SI_ST_REQ when an immediate redispatch is wanted. The buffers are
marked as in error state. It returns 0.
This function is called with ( si - > state == SI_ST_CER ) meaning that a previous connection attempt has failed and that the file descriptor has already been released . Possible causes include asynchronous error notification and time out . Possible output states are SI_ST_CLO when retries are exhausted SI_ST_TAR when a delay is wanted before a new connection attempt SI_ST_ASS when it ' s wise to retry on the same server and SI_ST_REQ when an immediate redispatch is wanted . The buffers are marked as in error state . It returns 0 .
static int sess_update_st_cer(struct session *s, struct stream_interface *si)
{
	if (objt_server(s->target)) {
		health_adjust(objt_server(s->target), HANA_STATUS_L4_ERR);
		if (s->flags & SN_CURR_SESS) {
			s->flags &= ~SN_CURR_SESS;
			objt_server(s->target)->cur_sess--;
		}
	}
	si->conn_retries--;
	if (si->conn_retries < 0) {
		if (!si->err_type) {
			si->err_type = SI_ET_CONN_ERR;
			si->err_loc = objt_server(s->target);
		}
		if (objt_server(s->target))
			objt_server(s->target)->counters.failed_conns++;
		s->be->be_counters.failed_conns++;
		sess_change_server(s, NULL);
		if (may_dequeue_tasks(objt_server(s->target), s->be))
			process_srv_queue(objt_server(s->target));
		si_shutw(si);
		si->ob->flags |= CF_WRITE_ERROR;
		si->ib->flags |= CF_READ_ERROR;
		si->state = SI_ST_CLO;
		if (s->srv_error)
			s->srv_error(s, si);
		return 0;
	}
	if (objt_server(s->target) && si->conn_retries == 0 &&
	    s->be->options & PR_O_REDISP && !(s->flags & SN_FORCE_PRST)) {
		sess_change_server(s, NULL);
		if (may_dequeue_tasks(objt_server(s->target), s->be))
			process_srv_queue(objt_server(s->target));
		s->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
		si->state = SI_ST_REQ;
	} else {
		if (objt_server(s->target))
			objt_server(s->target)->counters.retries++;
		s->be->be_counters.retries++;
		si->state = SI_ST_ASS;
	}
	if (si->flags & SI_FL_ERR) {
		if (!si->err_type)
			si->err_type = SI_ET_CONN_ERR;
		si->state = SI_ST_TAR;
		si->exp = tick_add(now_ms, MS_TO_TICKS(1000));
		return 0;
	}
	return 0;
}
static int sess_update_st_cer ( struct session * s , struct stream_interface * si ) { if ( objt_server ( s -> target ) ) { health_adjust ( objt_server ( s -> target ) , HANA_STATUS_L4_ERR ) ; if ( s -> flags & SN_CURR_SESS ) { s -> flags &= ~ SN_CURR_SESS ; objt_server ( s -> target ) -> cur_sess -- ; } } si -> conn_retries -- ; if ( si -> conn_retries < 0 ) { if ( ! si -> err_type ) { si -> err_type = SI_ET_CONN_ERR ; si -> err_loc = objt_server ( s -> target ) ; } if ( objt_server ( s -> target ) ) objt_server ( s -> target ) -> counters . failed_conns ++ ; s -> be -> be_counters . failed_conns ++ ; sess_change_server ( s , NULL ) ; if ( may_dequeue_tasks ( objt_server ( s -> target ) , s -> be ) ) process_srv_queue ( objt_server ( s -> target ) ) ; si_shutw ( si ) ; si -> ob -> flags |= CF_WRITE_ERROR ; si -> ib -> flags |= CF_READ_ERROR ; si -> state = SI_ST_CLO ; if ( s -> srv_error ) s -> srv_error ( s , si ) ; return 0 ; } if ( objt_server ( s -> target ) && si -> conn_retries == 0 && s -> be -> options & PR_O_REDISP && ! ( s -> flags & SN_FORCE_PRST ) ) { sess_change_server ( s , NULL ) ; if ( may_dequeue_tasks ( objt_server ( s -> target ) , s -> be ) ) process_srv_queue ( objt_server ( s -> target ) ) ; s -> flags &= ~ ( SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET ) ; si -> state = SI_ST_REQ ; } else { if ( objt_server ( s -> target ) ) objt_server ( s -> target ) -> counters . retries ++ ; s -> be -> be_counters . retries ++ ; si -> state = SI_ST_ASS ; } if ( si -> flags & SI_FL_ERR ) { if ( ! si -> err_type ) si -> err_type = SI_ET_CONN_ERR ; si -> state = SI_ST_TAR ; si -> exp = tick_add ( now_ms , MS_TO_TICKS ( 1000 ) ) ; return 0 ; } return 0 ; }
This function is called with (si->state == SI_ST_CER) meaning that a
 previous connection attempt has failed and that the file descriptor
 has already been released.
This function is called with ( si - > state == SI_ST_CER ) meaning that a previous connection attempt has failed and that the file descriptor has already been released .
/* we probably have to release last session from the server */ /* ensure that we have enough retries left */ /* shutw is enough so stop a connecting socket */ /* If the "redispatch" option is set on the backend, we are allowed to
	 * retry on another server for the last retry. In order to achieve this,
	 * we must mark the session unassigned, and eventually clear the DIRECT
	 * bit to ignore any persistence cookie. We won't count a retry nor a
	 * redispatch yet, because this will depend on what server is selected.
	 */ /* The error was an asynchronous connection error, and we will
		 * likely have to retry connecting to the same server, most
		 * likely leading to the same result. To avoid this, we wait
		 * one second before retrying.
		 */