conn->flags = CO_FL_NONE;
conn->data = NULL;
conn->owner = NULL;
+ conn->send_proxy_ofs = 0;
conn->t.sock.fd = -1; /* just to help with debugging */
conn->err_code = CO_ER_NONE;
conn->target = NULL;
si->owner = owner;
si->err_type = SI_ET_NONE;
si->conn_retries = 0; /* used for logging too */
- si->send_proxy_ofs = 0;
si->exp = TICK_ETERNITY;
si->flags = SI_FL_NONE;
si->end = NULL;
if (unlikely(!conn || !conn->ctrl || !conn->ctrl->connect))
return SN_ERR_INTERNAL;
- ret = conn->ctrl->connect(conn, !channel_is_empty(si->ob), !!si->send_proxy_ofs);
+ ret = conn->ctrl->connect(conn, !channel_is_empty(si->ob), !!conn->send_proxy_ofs);
if (ret != SN_ERR_NONE)
return ret;
conn_get_from_addr(conn);
/* Prepare to send a few handshakes related to the on-wire protocol. */
- if (si->send_proxy_ofs)
+ if (conn->send_proxy_ofs)
conn->flags |= CO_FL_SI_SEND_PROXY;
/* we need to be notified about connection establishment */
*/
struct connection {
enum obj_type obj_type; /* differentiates connection from applet context */
+ unsigned int flags; /* CO_FL_* */
const struct protocol *ctrl; /* operations at the socket layer */
const struct xprt_ops *xprt; /* operations at the transport layer */
const struct data_cb *data; /* data layer callbacks. Must be set before xprt->init() */
- unsigned int flags; /* CO_FL_* */
- int xprt_st; /* transport layer state, initialized to zero */
void *xprt_ctx; /* general purpose pointer, initialized to NULL */
void *owner; /* pointer to upper layer's entity (eg: stream interface) */
+ int xprt_st; /* transport layer state, initialized to zero */
+ int send_proxy_ofs; /* <0 = offset to (re)send from the end, >0 = send all */
union { /* definitions which depend on connection type */
struct { /*** information used by socket-based connections ***/
int fd; /* file descriptor for a stream driver when known */
unsigned int state; /* SI_ST* */
unsigned int prev_state;/* SI_ST*, copy of previous state */
unsigned int flags; /* SI_FL_* */
- struct channel *ib, *ob; /* input and output buffers */
unsigned int exp; /* wake up time for connect, queue, turn-around, ... */
+ struct channel *ib, *ob; /* input and output buffers */
void *owner; /* generally a (struct task*) */
- unsigned int err_type; /* first error detected, one of SI_ET_* */
enum obj_type *end; /* points to the end point (connection or appctx) */
struct si_ops *ops; /* general operations at the stream interface layer */
/* struct members below are the "remote" part, as seen from the buffer side */
+ unsigned int err_type; /* first error detected, one of SI_ET_* */
int conn_retries; /* number of connect retries left */
- int send_proxy_ofs; /* <0 = offset to (re)send from the end, >0 = send all */
struct appctx appctx; /* context of the running applet if any */
};
si_attach_conn(s->req->cons, srv_conn);
/* process the case where the server requires the PROXY protocol to be sent */
- s->req->cons->send_proxy_ofs = 0;
+ srv_conn->send_proxy_ofs = 0;
if (objt_server(s->target) && (objt_server(s->target)->state & SRV_SEND_PROXY)) {
- s->req->cons->send_proxy_ofs = 1; /* must compute size */
+ srv_conn->send_proxy_ofs = 1; /* must compute size */
cli_conn = objt_conn(s->req->prod->end);
if (cli_conn)
conn_get_to_addr(cli_conn);
* connection, in which case the connection is validated only once
* we've sent the whole proxy line. Otherwise we use connect().
*/
- while (si->send_proxy_ofs) {
+ while (conn->send_proxy_ofs) {
int ret;
/* The target server expects a PROXY line to be sent first.
if (!ret)
goto out_error;
- if (si->send_proxy_ofs > 0)
- si->send_proxy_ofs = -ret; /* first call */
+ if (conn->send_proxy_ofs > 0)
+ conn->send_proxy_ofs = -ret; /* first call */
/* we have to send trash from (ret+sp for -sp bytes). If the
* data layer has a pending write, we'll also set MSG_MORE.
*/
- ret = send(conn->t.sock.fd, trash.str + ret + si->send_proxy_ofs, -si->send_proxy_ofs,
+ ret = send(conn->t.sock.fd, trash.str + ret + conn->send_proxy_ofs, -conn->send_proxy_ofs,
(conn->flags & CO_FL_DATA_WR_ENA) ? MSG_MORE : 0);
if (ret == 0)
goto out_error;
}
- si->send_proxy_ofs += ret; /* becomes zero once complete */
- if (si->send_proxy_ofs != 0)
+ conn->send_proxy_ofs += ret; /* becomes zero once complete */
+ if (conn->send_proxy_ofs != 0)
goto out_wait;
/* OK we've sent the whole line, we're connected */