aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkvakvs <[email protected]>2016-08-03 14:39:00 +0200
committerJohn Högberg <[email protected]>2017-06-14 10:05:25 +0200
commit635b35ef4d0403a9bbf149e076aed6fca84af383 (patch)
treed26dc31b957f1f45cb5496116d662d77dcbb432e
parent5e1b5ef47f3f2b898d30e0425823835bd9a574d4 (diff)
downloadotp-635b35ef4d0403a9bbf149e076aed6fca84af383.tar.gz
otp-635b35ef4d0403a9bbf149e076aed6fca84af383.tar.bz2
otp-635b35ef4d0403a9bbf149e076aed6fca84af383.zip
Mark socket disconnected on tcp_send_or_shutdown_error
The socket left lingering due to {exit_on_close, false} will accept writes in a confusing way, returning either enotconn or blocking. This fix allows socket to know that it has been closed recently, and new writes won't pass.
-rw-r--r--erts/emulator/drivers/common/inet_drv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 2d2bd80783..1649b07ad9 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -4378,6 +4378,12 @@ static void desc_close(inet_descriptor* desc)
desc->event = INVALID_EVENT; /* closed by stop_select callback */
desc->s = INVALID_SOCKET;
desc->event_mask = 0;
+
+ /* mark as disconnected in case when socket is left lingering due to
+ * {exit_on_close, false} option in gen_tcp socket creation. Next
+ * write to socket should produce {error, enotconn} and send a
+ * message {tcp_error,#Port<>,econnreset} */
+ desc->state &= ~INET_STATE_CONNECTED;
}
}