MINOR: raw-sock: don't try to send if an error was already reported

There's no point trying to send() on a socket on which an error was already
reported. This wastes syscalls. Till now it was possible to occasionally
see an attempt to sendto() after epoll_wait() had reported EPOLLERR.
This commit is contained in:
Willy Tarreau 2022-08-29 16:48:14 +02:00
parent 2c30de3b90
commit c6fc77404e

View File

@ -360,6 +360,13 @@ static size_t raw_sock_from_buf(struct connection *conn, void *xprt_ctx, const s
if (!fd_send_ready(conn->handle.fd))
return 0;
if (unlikely(fdtab[conn->handle.fd].state & FD_POLL_ERR)) {
/* an error was reported on the FD, we can't send anymore */
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_WR_SH | CO_FL_SOCK_RD_SH;
errno = EPIPE;
return 0;
}
if (conn->flags & CO_FL_SOCK_WR_SH) {
/* it's already closed */
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH;