Handle orderly shutdown of remote sockets

When getting a EOF from remote, do not close immediately, drain the send
buffer.

PUBLISHED_FROM=e06cdaa2abc0d67d5d88bf3e72d887590a7aeccf
This commit is contained in:
Deomid Ryabkov 2016-04-29 15:13:50 +01:00 committed by rojer
parent 203d4a79e2
commit 8a81dce0c1

View File

@ -3429,7 +3429,10 @@ static void mg_read_from_socket(struct mg_connection *conn) {
} else {
MG_FREE(buf);
}
if (mg_is_error(n)) {
if (n == 0) {
/* Orderly shutdown of the socket, try flushing output. */
conn->flags |= MG_F_SEND_AND_CLOSE;
} else if (mg_is_error(n)) {
conn->flags |= MG_F_CLOSE_IMMEDIATELY;
}
}