summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/stream_sock.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 82bf8caf6..80d4996a7 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -787,11 +787,16 @@ void stream_sock_shutw(struct stream_interface *si)
switch (si->state) {
case SI_ST_EST:
- if (!(si->ib->flags & BF_SHUTR)) {
- EV_FD_CLR(si->fd, DIR_WR);
- shutdown(si->fd, SHUT_WR);
+ /* 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);
+ shutdown(si->fd, SHUT_WR);
+
+ if (!(si->ib->flags & BF_SHUTR))
return;
- }
+
/* fall through */
case SI_ST_CON:
/* we may have to close a pending connection, and mark the