mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 17:17:06 +02:00
[CLEANUP] stream_sock: move the write-nothing condition out of the loop
Some tricks to handle situations where we write nothing were in the middle of the main loop in stream_sock_write(). This cleanup provides better source and object code, and slightly shrinks the output code.
This commit is contained in:
parent
efc612c17b
commit
ac128fef73
@ -361,7 +361,7 @@ int stream_sock_write(int fd) {
|
|||||||
* so we cannot write anything from the buffer. Let's disable
|
* so we cannot write anything from the buffer. Let's disable
|
||||||
* the write event and pretend we never came there.
|
* the write event and pretend we never came there.
|
||||||
*/
|
*/
|
||||||
goto write_nothing;
|
goto out_stop_write;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
#ifndef MSG_NOSIGNAL
|
||||||
@ -398,25 +398,7 @@ int stream_sock_write(int fd) {
|
|||||||
|
|
||||||
if (!b->l && !b->splice_len) {
|
if (!b->l && !b->splice_len) {
|
||||||
b->flags |= BF_EMPTY;
|
b->flags |= BF_EMPTY;
|
||||||
|
goto out_stop_write;
|
||||||
write_nothing:
|
|
||||||
/* Maybe we just wrote the last chunk and need to close ? */
|
|
||||||
if ((b->flags & (BF_SHUTW|BF_EMPTY|BF_HIJACK|BF_WRITE_ENA|BF_SHUTR)) == (BF_EMPTY|BF_WRITE_ENA|BF_SHUTR)) {
|
|
||||||
if (si->state == SI_ST_EST) {
|
|
||||||
stream_sock_shutw(si);
|
|
||||||
b->wex = TICK_ETERNITY;
|
|
||||||
goto out_wakeup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we may either get there when the buffer is empty or when
|
|
||||||
* we refrain from sending due to send_max reached.
|
|
||||||
*/
|
|
||||||
if (!b->l && !b->splice_len)
|
|
||||||
si->flags |= SI_FL_WAIT_DATA;
|
|
||||||
EV_FD_CLR(fd, DIR_WR);
|
|
||||||
b->wex = TICK_ETERNITY;
|
|
||||||
goto out_wakeup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if the system buffer is full, don't insist */
|
/* if the system buffer is full, don't insist */
|
||||||
@ -479,6 +461,22 @@ int stream_sock_write(int fd) {
|
|||||||
fdtab[fd].ev &= ~FD_POLL_OUT;
|
fdtab[fd].ev &= ~FD_POLL_OUT;
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
out_stop_write:
|
||||||
|
/* We can't write anymore. Either the buffer is empty, or we just
|
||||||
|
* refrain from sending because send_max is reached. Maybe we just
|
||||||
|
* wrote the last chunk and need to close.
|
||||||
|
*/
|
||||||
|
if ((b->flags & (BF_SHUTW|BF_EMPTY|BF_HIJACK|BF_WRITE_ENA|BF_SHUTR)) == (BF_EMPTY|BF_WRITE_ENA|BF_SHUTR) &&
|
||||||
|
(si->state == SI_ST_EST)) {
|
||||||
|
stream_sock_shutw(si);
|
||||||
|
} else {
|
||||||
|
if (!b->l && !b->splice_len)
|
||||||
|
si->flags |= SI_FL_WAIT_DATA;
|
||||||
|
EV_FD_CLR(fd, DIR_WR);
|
||||||
|
}
|
||||||
|
b->wex = TICK_ETERNITY;
|
||||||
|
goto out_wakeup;
|
||||||
|
|
||||||
out_error:
|
out_error:
|
||||||
/* Write error on the file descriptor. We mark the FD as STERROR so
|
/* Write error on the file descriptor. We mark the FD as STERROR so
|
||||||
* that we don't use it anymore. The error is reported to the stream
|
* that we don't use it anymore. The error is reported to the stream
|
||||||
|
Loading…
Reference in New Issue
Block a user