mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-18 21:21:22 +02:00
[BUG] stream_sock: always shutdown(SHUT_WR) before closing
When we close a socket with unread data in the buffer, or when the nolinger option is set, we regularly lose the last fragment, which often contains the error message. This typically occurs when sending too large a request. Only the RST is seen due to the close() (since not all data were read) and the output message never reaches the network. Doing a shutdown() before the close() solves this annoying issue because the data are really pushed before the system sends the RST. (cherry picked from commit 720058cdcbd5285dc4e4a48216b10c9b96000141)
This commit is contained in:
parent
b6b8f478e2
commit
77cb067142
@ -787,11 +787,16 @@ void stream_sock_shutw(struct stream_interface *si)
|
|||||||
|
|
||||||
switch (si->state) {
|
switch (si->state) {
|
||||||
case SI_ST_EST:
|
case SI_ST_EST:
|
||||||
if (!(si->ib->flags & BF_SHUTR)) {
|
/* we have to shut before closing, otherwise some short messages
|
||||||
|
* may never leave the system, especially when there are remaining
|
||||||
|
* unread data in the socket input buffer, or when nolinger is set.
|
||||||
|
*/
|
||||||
EV_FD_CLR(si->fd, DIR_WR);
|
EV_FD_CLR(si->fd, DIR_WR);
|
||||||
shutdown(si->fd, SHUT_WR);
|
shutdown(si->fd, SHUT_WR);
|
||||||
|
|
||||||
|
if (!(si->ib->flags & BF_SHUTR))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case SI_ST_CON:
|
case SI_ST_CON:
|
||||||
/* we may have to close a pending connection, and mark the
|
/* we may have to close a pending connection, and mark the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user