static inline void conn_ctrl_init(struct connection *conn)
{
if (!conn_ctrl_ready(conn)) {
- int fd = conn->t.sock.fd;
+ int fd = conn->handle.fd;
fd_insert(fd);
/* mark the fd as ready so as not to needlessly poll at the beginning */
static inline void conn_ctrl_close(struct connection *conn)
{
if ((conn->flags & (CO_FL_XPRT_READY|CO_FL_CTRL_READY)) == CO_FL_CTRL_READY) {
- fd_delete(conn->t.sock.fd);
+ fd_delete(conn->handle.fd);
conn->flags &= ~CO_FL_CTRL_READY;
}
}
conn->xprt->close(conn);
if (conn_ctrl_ready(conn))
- fd_delete(conn->t.sock.fd);
+ fd_delete(conn->handle.fd);
- conn->t.sock.fd = DEAD_FD_MAGIC;
+ conn->handle.fd = DEAD_FD_MAGIC;
conn->flags &= ~(CO_FL_XPRT_READY|CO_FL_CTRL_READY);
}
if (conn_ctrl_ready(conn)) {
unsigned int flags = conn->flags & ~(CO_FL_CURR_RD_ENA | CO_FL_CURR_WR_ENA);
- if (fd_recv_active(conn->t.sock.fd))
+ if (fd_recv_active(conn->handle.fd))
flags |= CO_FL_CURR_RD_ENA;
- if (fd_send_active(conn->t.sock.fd))
+ if (fd_send_active(conn->handle.fd))
flags |= CO_FL_CURR_WR_ENA;
conn->flags = flags;
}
CO_FL_SOCK_RD_ENA | CO_FL_SOCK_WR_ENA |
CO_FL_DATA_RD_ENA | CO_FL_DATA_WR_ENA);
if (conn_ctrl_ready(c))
- fd_stop_both(c->t.sock.fd);
+ fd_stop_both(c->handle.fd);
}
/* Automatically update polling on connection <c> depending on the DATA and
*/
static inline int __conn_data_done_recv(struct connection *c)
{
- if (!conn_ctrl_ready(c) || !fd_recv_polled(c->t.sock.fd)) {
+ if (!conn_ctrl_ready(c) || !fd_recv_polled(c->handle.fd)) {
c->flags &= ~CO_FL_DATA_RD_ENA;
return 1;
}
* zero from the other side.
*/
if (conn_ctrl_ready(c))
- fdtab[c->t.sock.fd].linger_risk = 0;
+ fdtab[c->handle.fd].linger_risk = 0;
}
static inline void conn_data_read0(struct connection *c)
c->flags |= CO_FL_SOCK_WR_SH;
__conn_sock_stop_send(c);
if (conn_ctrl_ready(c))
- shutdown(c->t.sock.fd, SHUT_WR);
+ shutdown(c->handle.fd, SHUT_WR);
}
static inline void conn_data_shutw(struct connection *c)
conn->data = NULL;
conn->owner = NULL;
conn->send_proxy_ofs = 0;
- conn->t.sock.fd = DEAD_FD_MAGIC;
+ conn->handle.fd = DEAD_FD_MAGIC;
conn->err_code = CO_ER_NONE;
conn->target = NULL;
conn->proxy_netns = NULL;
if (!conn_ctrl_ready(conn) || !conn->ctrl->get_src)
return;
- if (conn->ctrl->get_src(conn->t.sock.fd, (struct sockaddr *)&conn->addr.from,
+ if (conn->ctrl->get_src(conn->handle.fd, (struct sockaddr *)&conn->addr.from,
sizeof(conn->addr.from),
obj_type(conn->target) != OBJ_TYPE_LISTENER) == -1)
return;
if (!conn_ctrl_ready(conn) || !conn->ctrl->get_dst)
return;
- if (conn->ctrl->get_dst(conn->t.sock.fd, (struct sockaddr *)&conn->addr.to,
+ if (conn->ctrl->get_dst(conn->handle.fd, (struct sockaddr *)&conn->addr.to,
sizeof(conn->addr.to),
obj_type(conn->target) != OBJ_TYPE_LISTENER) == -1)
return;
struct server;
struct pipe;
+
+/* A connection handle is how we differenciate two connections on the lower
+ * layers. It usually is a file descriptor but can be a connection id.
+ */
+union conn_handle {
+ int fd; /* file descriptor, for regular sockets */
+};
+
+
/* For each direction, we have a CO_FL_{SOCK,DATA}_<DIR>_ENA flag, which
* indicates if read or write is desired in that direction for the respective
* layers. The current status corresponding to the current layer being used is
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 */
-
- union { /* definitions which depend on connection type */
- struct { /*** information used by socket-based connections ***/
- int fd; /* file descriptor for a stream driver when known */
- } sock;
- } t;
+ union conn_handle handle; /* connection handle at the socket layer */
enum obj_type *target; /* the target to connect to (server, proxy, applet, ...) */
struct list list; /* attach point to various connection lists (idle, ...) */
const struct netns_entry *proxy_netns;
if (!conn_ctrl_ready(conn))
return 0;
- if (getsockopt(conn->t.sock.fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr) == 0)
+ if (getsockopt(conn->handle.fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr) == 0)
errno = skerr;
if (errno == EAGAIN)
return "out of memory while allocating check connection";
}
- check->conn->t.sock.fd = -1; /* no agent in progress yet */
+ check->conn->handle.fd = -1; /* no agent in progress yet */
return NULL;
}
int tot_fd_nb = 0;
struct proxy *px;
int i = 0;
- int fd = remote->t.sock.fd;
+ int fd = remote->handle.fd;
int curoff = 0;
int old_fcntl;
int ret;
/* update read status if needed */
if (unlikely((f & (CO_FL_CURR_RD_ENA|CO_FL_DATA_RD_ENA)) == CO_FL_DATA_RD_ENA)) {
- fd_want_recv(c->t.sock.fd);
+ fd_want_recv(c->handle.fd);
f |= CO_FL_CURR_RD_ENA;
}
else if (unlikely((f & (CO_FL_CURR_RD_ENA|CO_FL_DATA_RD_ENA)) == CO_FL_CURR_RD_ENA)) {
- fd_stop_recv(c->t.sock.fd);
+ fd_stop_recv(c->handle.fd);
f &= ~CO_FL_CURR_RD_ENA;
}
/* update write status if needed */
if (unlikely((f & (CO_FL_CURR_WR_ENA|CO_FL_DATA_WR_ENA)) == CO_FL_DATA_WR_ENA)) {
- fd_want_send(c->t.sock.fd);
+ fd_want_send(c->handle.fd);
f |= CO_FL_CURR_WR_ENA;
}
else if (unlikely((f & (CO_FL_CURR_WR_ENA|CO_FL_DATA_WR_ENA)) == CO_FL_CURR_WR_ENA)) {
- fd_stop_send(c->t.sock.fd);
+ fd_stop_send(c->handle.fd);
f &= ~CO_FL_CURR_WR_ENA;
}
c->flags = f;
/* update read status if needed */
if (unlikely((f & (CO_FL_CURR_RD_ENA|CO_FL_SOCK_RD_ENA)) == CO_FL_SOCK_RD_ENA)) {
- fd_want_recv(c->t.sock.fd);
+ fd_want_recv(c->handle.fd);
f |= CO_FL_CURR_RD_ENA;
}
else if (unlikely((f & (CO_FL_CURR_RD_ENA|CO_FL_SOCK_RD_ENA)) == CO_FL_CURR_RD_ENA)) {
- fd_stop_recv(c->t.sock.fd);
+ fd_stop_recv(c->handle.fd);
f &= ~CO_FL_CURR_RD_ENA;
}
/* update write status if needed */
if (unlikely((f & (CO_FL_CURR_WR_ENA|CO_FL_SOCK_WR_ENA)) == CO_FL_SOCK_WR_ENA)) {
- fd_want_send(c->t.sock.fd);
+ fd_want_send(c->handle.fd);
f |= CO_FL_CURR_WR_ENA;
}
else if (unlikely((f & (CO_FL_CURR_WR_ENA|CO_FL_SOCK_WR_ENA)) == CO_FL_CURR_WR_ENA)) {
- fd_stop_send(c->t.sock.fd);
+ fd_stop_send(c->handle.fd);
f &= ~CO_FL_CURR_WR_ENA;
}
c->flags = f;
if (!len)
goto fail;
- if (!fd_send_ready(conn->t.sock.fd))
+ if (!fd_send_ready(conn->handle.fd))
goto wait;
do {
- ret = send(conn->t.sock.fd, buf, len, flags | MSG_DONTWAIT | MSG_NOSIGNAL);
+ ret = send(conn->handle.fd, buf, len, flags | MSG_DONTWAIT | MSG_NOSIGNAL);
} while (ret < 0 && errno == EINTR);
if (ret == 0 || errno == EAGAIN || errno == ENOTCONN) {
wait:
- fd_cant_send(conn->t.sock.fd);
+ fd_cant_send(conn->handle.fd);
return 0;
}
fail:
if (conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH))
return 1;
- if (fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) {
- fdtab[conn->t.sock.fd].linger_risk = 0;
+ if (fdtab[conn->handle.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) {
+ fdtab[conn->handle.fd].linger_risk = 0;
}
else {
- if (!fd_recv_ready(conn->t.sock.fd))
+ if (!fd_recv_ready(conn->handle.fd))
return 0;
/* disable draining if we were called and have no drain function */
return 0;
}
- if (conn->ctrl->drain(conn->t.sock.fd) <= 0)
+ if (conn->ctrl->drain(conn->handle.fd) <= 0)
return 0;
}
if (!conn_ctrl_ready(conn))
goto fail;
- if (!fd_recv_ready(conn->t.sock.fd))
+ if (!fd_recv_ready(conn->handle.fd))
return 0;
do {
- trash.len = recv(conn->t.sock.fd, trash.str, trash.size, MSG_PEEK);
+ trash.len = recv(conn->handle.fd, trash.str, trash.size, MSG_PEEK);
if (trash.len < 0) {
if (errno == EINTR)
continue;
if (errno == EAGAIN) {
- fd_cant_recv(conn->t.sock.fd);
+ fd_cant_recv(conn->handle.fd);
return 0;
}
goto recv_abort;
* fail.
*/
do {
- int len2 = recv(conn->t.sock.fd, trash.str, trash.len, 0);
+ int len2 = recv(conn->handle.fd, trash.str, trash.len, 0);
if (len2 < 0 && errno == EINTR)
continue;
if (len2 != trash.len)
if (!conn_ctrl_ready(conn))
goto fail;
- if (!fd_recv_ready(conn->t.sock.fd))
+ if (!fd_recv_ready(conn->handle.fd))
return 0;
do {
- trash.len = recv(conn->t.sock.fd, trash.str, trash.size, MSG_PEEK);
+ trash.len = recv(conn->handle.fd, trash.str, trash.size, MSG_PEEK);
if (trash.len < 0) {
if (errno == EINTR)
continue;
if (errno == EAGAIN) {
- fd_cant_recv(conn->t.sock.fd);
+ fd_cant_recv(conn->handle.fd);
return 0;
}
goto recv_abort;
* result, we fail.
*/
do {
- int len2 = recv(conn->t.sock.fd, trash.str, trash.len, 0);
+ int len2 = recv(conn->handle.fd, trash.str, trash.len, 0);
if (len2 < 0 && errno == EINTR)
continue;
if (len2 != trash.len)
case AF_INET:
case AF_INET6:
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [%s:%d] ALPN=%s\n",
- s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->t.sock.fd,
+ s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->handle.fd,
pn, get_host_port(&conn->addr.from), alpn);
break;
case AF_UNIX:
/* UNIX socket, only the destination is known */
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [unix:%d] ALPN=%s\n",
- s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->t.sock.fd,
+ s->uniq_id, fe->id, (unsigned short)l->fd, (unsigned short)conn->handle.fd,
l->luid, alpn);
break;
}
tos = MAY_LJMP(luaL_checkinteger(L, 2));
if ((cli_conn = objt_conn(htxn->s->sess->origin)) && conn_ctrl_ready(cli_conn))
- inet_set_tos(cli_conn->t.sock.fd, &cli_conn->addr.from, tos);
+ inet_set_tos(cli_conn->handle.fd, &cli_conn->addr.from, tos);
return 0;
}
mark = MAY_LJMP(luaL_checkinteger(L, 2));
if ((cli_conn = objt_conn(htxn->s->sess->origin)) && conn_ctrl_ready(cli_conn))
- setsockopt(cli_conn->t.sock.fd, SOL_SOCKET, SO_MARK, &mark, sizeof(mark));
+ setsockopt(cli_conn->handle.fd, SOL_SOCKET, SO_MARK, &mark, sizeof(mark));
#endif
return 0;
}
* previously disabled it, otherwise we might cause the client
* to delay next data.
*/
- setsockopt(__objt_conn(sess->origin)->t.sock.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
+ setsockopt(__objt_conn(sess->origin)->handle.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
}
#endif
case ACT_HTTP_SET_TOS:
if ((cli_conn = objt_conn(sess->origin)) && conn_ctrl_ready(cli_conn))
- inet_set_tos(cli_conn->t.sock.fd, &cli_conn->addr.from, rule->arg.tos);
+ inet_set_tos(cli_conn->handle.fd, &cli_conn->addr.from, rule->arg.tos);
break;
case ACT_HTTP_SET_MARK:
#ifdef SO_MARK
if ((cli_conn = objt_conn(sess->origin)) && conn_ctrl_ready(cli_conn))
- setsockopt(cli_conn->t.sock.fd, SOL_SOCKET, SO_MARK, &rule->arg.mark, sizeof(rule->arg.mark));
+ setsockopt(cli_conn->handle.fd, SOL_SOCKET, SO_MARK, &rule->arg.mark, sizeof(rule->arg.mark));
#endif
break;
case ACT_HTTP_SET_TOS:
if ((cli_conn = objt_conn(sess->origin)) && conn_ctrl_ready(cli_conn))
- inet_set_tos(cli_conn->t.sock.fd, &cli_conn->addr.from, rule->arg.tos);
+ inet_set_tos(cli_conn->handle.fd, &cli_conn->addr.from, rule->arg.tos);
break;
case ACT_HTTP_SET_MARK:
#ifdef SO_MARK
if ((cli_conn = objt_conn(sess->origin)) && conn_ctrl_ready(cli_conn))
- setsockopt(cli_conn->t.sock.fd, SOL_SOCKET, SO_MARK, &rule->arg.mark, sizeof(rule->arg.mark));
+ setsockopt(cli_conn->handle.fd, SOL_SOCKET, SO_MARK, &rule->arg.mark, sizeof(rule->arg.mark));
#endif
break;
cli_conn && conn_ctrl_ready(cli_conn) &&
((msg->flags & HTTP_MSGF_TE_CHNK) ||
(msg->body_len > req->buf->i - txn->req.eoh - 2)))
- setsockopt(cli_conn->t.sock.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
+ setsockopt(cli_conn->handle.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));
#endif
/*************************************************************
chunk_printf(&trash, "%08x:%s.%s[%04x:%04x]: ", s->uniq_id, s->be->id,
dir,
- objt_conn(sess->origin) ? (unsigned short)objt_conn(sess->origin)->t.sock.fd : -1,
- objt_conn(s->si[1].end) ? (unsigned short)objt_conn(s->si[1].end)->t.sock.fd : -1);
+ objt_conn(sess->origin) ? (unsigned short)objt_conn(sess->origin)->handle.fd : -1,
+ objt_conn(s->si[1].end) ? (unsigned short)objt_conn(s->si[1].end)->handle.fd : -1);
for (max = 0; start + max < end; max++)
if (start[max] == '\r' || start[max] == '\n')
return SF_ERR_INTERNAL;
}
- fd = conn->t.sock.fd = create_server_socket(conn);
+ fd = conn->handle.fd = create_server_socket(conn);
if (fd == -1) {
qfprintf(stderr, "Cannot get a server socket.\n");
*/
int tcp_connect_probe(struct connection *conn)
{
- int fd = conn->t.sock.fd;
+ int fd = conn->handle.fd;
socklen_t lskerr;
int skerr;
/* re-enable quickack if it was disabled to ack all data and avoid
* retransmits from the client that might trigger a real reset.
*/
- setsockopt(conn->t.sock.fd, SOL_TCP, TCP_QUICKACK, &one, sizeof(one));
+ setsockopt(conn->handle.fd, SOL_TCP, TCP_QUICKACK, &one, sizeof(one));
#endif
/* lingering must absolutely be disabled so that we don't send a
* shutdown(), this is critical to the TCP_REPAIR trick. When no stream
/* We're on the client-facing side, we must force to disable lingering to
* ensure we will use an RST exclusively and kill any pending data.
*/
- fdtab[conn->t.sock.fd].linger_risk = 1;
+ fdtab[conn->handle.fd].linger_risk = 1;
#ifdef TCP_REPAIR
- if (setsockopt(conn->t.sock.fd, SOL_TCP, TCP_REPAIR, &one, sizeof(one)) == 0) {
+ if (setsockopt(conn->handle.fd, SOL_TCP, TCP_REPAIR, &one, sizeof(one)) == 0) {
/* socket will be quiet now */
goto out;
}
* network and has no effect on local net.
*/
#ifdef IP_TTL
- setsockopt(conn->t.sock.fd, SOL_IP, IP_TTL, &one, sizeof(one));
+ setsockopt(conn->handle.fd, SOL_IP, IP_TTL, &one, sizeof(one));
#endif
out:
/* kill the stream if any */
/* The fd may not be avalaible for the tcp_info struct, and the
syscal can fail. */
optlen = sizeof(info);
- if (getsockopt(conn->t.sock.fd, SOL_TCP, TCP_INFO, &info, &optlen) == -1)
+ if (getsockopt(conn->handle.fd, SOL_TCP, TCP_INFO, &info, &optlen) == -1)
return 0;
/* extract the value. */
return SF_ERR_INTERNAL;
}
- if ((fd = conn->t.sock.fd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
+ if ((fd = conn->handle.fd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
qfprintf(stderr, "Cannot get a server socket.\n");
if (errno == ENFILE) {
if (!conn_ctrl_ready(conn))
return 0;
- if (!fd_recv_ready(conn->t.sock.fd))
+ if (!fd_recv_ready(conn->handle.fd))
return 0;
errno = 0;
* Since older splice() implementations were buggy and returned
* EAGAIN on end of read, let's bypass the call to splice() now.
*/
- if (unlikely(!(fdtab[conn->t.sock.fd].ev & FD_POLL_IN))) {
+ if (unlikely(!(fdtab[conn->handle.fd].ev & FD_POLL_IN))) {
/* stop here if we reached the end of data */
- if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
+ if ((fdtab[conn->handle.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
goto out_read0;
/* report error on POLL_ERR before connection establishment */
- if ((fdtab[conn->t.sock.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
+ if ((fdtab[conn->handle.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
errno = 0; /* let the caller do a getsockopt() if it wants it */
return retval;
if (count > MAX_SPLICE_AT_ONCE)
count = MAX_SPLICE_AT_ONCE;
- ret = splice(conn->t.sock.fd, NULL, pipe->prod, NULL, count,
+ ret = splice(conn->handle.fd, NULL, pipe->prod, NULL, count,
SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
if (ret <= 0) {
#ifndef ASSUME_SPLICE_WORKS
if (splice_detects_close)
#endif
- fd_cant_recv(conn->t.sock.fd); /* we know for sure that it's EAGAIN */
+ fd_cant_recv(conn->handle.fd); /* we know for sure that it's EAGAIN */
break;
}
else if (errno == ENOSYS || errno == EINVAL || errno == EBADF) {
* being asked to poll.
*/
conn->flags |= CO_FL_WAIT_ROOM;
- fd_done_recv(conn->t.sock.fd);
+ fd_done_recv(conn->handle.fd);
break;
}
} /* while */
if (!conn_ctrl_ready(conn))
return 0;
- if (!fd_send_ready(conn->t.sock.fd))
+ if (!fd_send_ready(conn->handle.fd))
return 0;
done = 0;
while (pipe->data) {
- ret = splice(pipe->cons, NULL, conn->t.sock.fd, NULL, pipe->data,
+ ret = splice(pipe->cons, NULL, conn->handle.fd, NULL, pipe->data,
SPLICE_F_MOVE|SPLICE_F_NONBLOCK);
if (ret <= 0) {
if (ret == 0 || errno == EAGAIN) {
- fd_cant_send(conn->t.sock.fd);
+ fd_cant_send(conn->handle.fd);
break;
}
else if (errno == EINTR)
if (!conn_ctrl_ready(conn))
return 0;
- if (!fd_recv_ready(conn->t.sock.fd))
+ if (!fd_recv_ready(conn->handle.fd))
return 0;
errno = 0;
- if (unlikely(!(fdtab[conn->t.sock.fd].ev & FD_POLL_IN))) {
+ if (unlikely(!(fdtab[conn->handle.fd].ev & FD_POLL_IN))) {
/* stop here if we reached the end of data */
- if ((fdtab[conn->t.sock.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
+ if ((fdtab[conn->handle.fd].ev & (FD_POLL_ERR|FD_POLL_HUP)) == FD_POLL_HUP)
goto read0;
/* report error on POLL_ERR before connection establishment */
- if ((fdtab[conn->t.sock.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
+ if ((fdtab[conn->handle.fd].ev & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) {
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
return done;
}
if (try > count)
try = count;
- ret = recv(conn->t.sock.fd, bi_end(buf), try, 0);
+ ret = recv(conn->handle.fd, bi_end(buf), try, 0);
if (ret > 0) {
buf->i += ret;
* to read an unlikely close from the client since we'll
* close first anyway.
*/
- if (fdtab[conn->t.sock.fd].ev & FD_POLL_HUP)
+ if (fdtab[conn->handle.fd].ev & FD_POLL_HUP)
goto read0;
- if ((!fdtab[conn->t.sock.fd].linger_risk) ||
+ if ((!fdtab[conn->handle.fd].linger_risk) ||
(cur_poller.flags & HAP_POLL_F_RDHUP)) {
- fd_done_recv(conn->t.sock.fd);
+ fd_done_recv(conn->handle.fd);
break;
}
}
goto read0;
}
else if (errno == EAGAIN || errno == ENOTCONN) {
- fd_cant_recv(conn->t.sock.fd);
+ fd_cant_recv(conn->handle.fd);
break;
}
else if (errno != EINTR) {
* of recv()'s return value 0, so we have no way to tell there was
* an error without checking.
*/
- if (unlikely(fdtab[conn->t.sock.fd].ev & FD_POLL_ERR))
+ if (unlikely(fdtab[conn->handle.fd].ev & FD_POLL_ERR))
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
return done;
}
if (!conn_ctrl_ready(conn))
return 0;
- if (!fd_send_ready(conn->t.sock.fd))
+ if (!fd_send_ready(conn->handle.fd))
return 0;
done = 0;
if (try < buf->o || flags & CO_SFL_MSG_MORE)
send_flag |= MSG_MORE;
- ret = send(conn->t.sock.fd, bo_ptr(buf), try, send_flag);
+ ret = send(conn->handle.fd, bo_ptr(buf), try, send_flag);
if (ret > 0) {
buf->o -= ret;
}
else if (ret == 0 || errno == EAGAIN || errno == ENOTCONN) {
/* nothing written, we need to poll for write first */
- fd_cant_send(conn->t.sock.fd);
+ fd_cant_send(conn->handle.fd);
break;
}
else if (errno != EINTR) {
conn_prepare(cli_conn, l->proto, l->bind_conf->xprt);
- cli_conn->t.sock.fd = cfd;
+ cli_conn->handle.fd = cfd;
cli_conn->addr.from = *addr;
cli_conn->flags |= CO_FL_ADDR_FROM_SET;
cli_conn->target = &l->obj_type;
if (ret == 0)
return;
fprintf(stderr, "fd[%04x] OpenSSL error[0x%lx] %s: %s\n",
- (unsigned short)conn->t.sock.fd, ret,
+ (unsigned short)conn->handle.fd, ret,
ERR_func_error_string(ret), ERR_reason_error_string(ret));
}
}
}
/* set fd on SSL session context */
- if (!SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd)) {
+ if (!SSL_set_fd(conn->xprt_ctx, conn->handle.fd)) {
SSL_free(conn->xprt_ctx);
conn->xprt_ctx = NULL;
if (may_retry--) {
}
/* set fd on SSL session context */
- if (!SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd)) {
+ if (!SSL_set_fd(conn->xprt_ctx, conn->handle.fd)) {
SSL_free(conn->xprt_ctx);
conn->xprt_ctx = NULL;
if (may_retry--) {
/* SSL handshake needs to write, L4 connection may not be ready */
__conn_sock_stop_recv(conn);
__conn_sock_want_send(conn);
- fd_cant_send(conn->t.sock.fd);
+ fd_cant_send(conn->handle.fd);
return 0;
}
else if (ret == SSL_ERROR_WANT_READ) {
conn->flags &= ~CO_FL_WAIT_L4_CONN;
__conn_sock_stop_send(conn);
__conn_sock_want_recv(conn);
- fd_cant_recv(conn->t.sock.fd);
+ fd_cant_recv(conn->handle.fd);
return 0;
}
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
/* SSL handshake needs to write, L4 connection may not be ready */
__conn_sock_stop_recv(conn);
__conn_sock_want_send(conn);
- fd_cant_send(conn->t.sock.fd);
+ fd_cant_send(conn->handle.fd);
return 0;
}
else if (ret == SSL_ERROR_WANT_READ) {
conn->flags &= ~CO_FL_WAIT_L4_CONN;
__conn_sock_stop_send(conn);
__conn_sock_want_recv(conn);
- fd_cant_recv(conn->t.sock.fd);
+ fd_cant_recv(conn->handle.fd);
return 0;
}
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
break;
}
/* we need to poll for retry a read later */
- fd_cant_recv(conn->t.sock.fd);
+ fd_cant_recv(conn->handle.fd);
break;
}
/* otherwise it's a real error */
break;
}
/* we need to poll to retry a write later */
- fd_cant_send(conn->t.sock.fd);
+ fd_cant_send(conn->handle.fd);
break;
}
else if (ret == SSL_ERROR_WANT_READ) {
si_b->prev_state == SI_ST_EST) {
chunk_printf(&trash, "%08x:%s.srvcls[%04x:%04x]\n",
s->uniq_id, s->be->id,
- objt_conn(si_f->end) ? (unsigned short)objt_conn(si_f->end)->t.sock.fd : -1,
- objt_conn(si_b->end) ? (unsigned short)objt_conn(si_b->end)->t.sock.fd : -1);
+ objt_conn(si_f->end) ? (unsigned short)objt_conn(si_f->end)->handle.fd : -1,
+ objt_conn(si_b->end) ? (unsigned short)objt_conn(si_b->end)->handle.fd : -1);
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
}
si_f->prev_state == SI_ST_EST) {
chunk_printf(&trash, "%08x:%s.clicls[%04x:%04x]\n",
s->uniq_id, s->be->id,
- objt_conn(si_f->end) ? (unsigned short)objt_conn(si_f->end)->t.sock.fd : -1,
- objt_conn(si_b->end) ? (unsigned short)objt_conn(si_b->end)->t.sock.fd : -1);
+ objt_conn(si_f->end) ? (unsigned short)objt_conn(si_f->end)->handle.fd : -1,
+ objt_conn(si_b->end) ? (unsigned short)objt_conn(si_b->end)->handle.fd : -1);
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
}
}
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
chunk_printf(&trash, "%08x:%s.closed[%04x:%04x]\n",
s->uniq_id, s->be->id,
- objt_conn(si_f->end) ? (unsigned short)objt_conn(si_f->end)->t.sock.fd : -1,
- objt_conn(si_b->end) ? (unsigned short)objt_conn(si_b->end)->t.sock.fd : -1);
+ objt_conn(si_f->end) ? (unsigned short)objt_conn(si_f->end)->handle.fd : -1,
+ objt_conn(si_b->end) ? (unsigned short)objt_conn(si_b->end)->handle.fd : -1);
shut_your_big_mouth_gcc(write(1, trash.str, trash.len));
}
chunk_appendf(&trash,
" flags=0x%08x fd=%d fd.state=%02x fd.cache=%d updt=%d\n",
conn->flags,
- conn->t.sock.fd,
- conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].state : 0,
- conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].cache : 0,
- conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].updated : 0);
+ conn->handle.fd,
+ conn->handle.fd >= 0 ? fdtab[conn->handle.fd].state : 0,
+ conn->handle.fd >= 0 ? fdtab[conn->handle.fd].cache : 0,
+ conn->handle.fd >= 0 ? fdtab[conn->handle.fd].updated : 0);
}
else if ((tmpctx = objt_appctx(strm->si[0].end)) != NULL) {
chunk_appendf(&trash,
chunk_appendf(&trash,
" flags=0x%08x fd=%d fd.state=%02x fd.cache=%d updt=%d\n",
conn->flags,
- conn->t.sock.fd,
- conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].state : 0,
- conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].cache : 0,
- conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].updated : 0);
+ conn->handle.fd,
+ conn->handle.fd >= 0 ? fdtab[conn->handle.fd].state : 0,
+ conn->handle.fd >= 0 ? fdtab[conn->handle.fd].cache : 0,
+ conn->handle.fd >= 0 ? fdtab[conn->handle.fd].updated : 0);
}
else if ((tmpctx = objt_appctx(strm->si[1].end)) != NULL) {
chunk_appendf(&trash,
" s0=[%d,%1xh,fd=%d,ex=%s]",
curr_strm->si[0].state,
curr_strm->si[0].flags,
- conn ? conn->t.sock.fd : -1,
+ conn ? conn->handle.fd : -1,
curr_strm->si[0].exp ?
human_time(TICKS_TO_MS(curr_strm->si[0].exp - now_ms),
TICKS_TO_MS(1000)) : "");
" s1=[%d,%1xh,fd=%d,ex=%s]",
curr_strm->si[1].state,
curr_strm->si[1].flags,
- conn ? conn->t.sock.fd : -1,
+ conn ? conn->handle.fd : -1,
curr_strm->si[1].exp ?
human_time(TICKS_TO_MS(curr_strm->si[1].exp - now_ms),
TICKS_TO_MS(1000)) : "");