diff options
author | Rory Byrne <[email protected]> | 2015-04-20 10:57:53 +0100 |
---|---|---|
committer | Rory Byrne <[email protected]> | 2015-06-09 20:50:06 +0100 |
commit | 4f63e427f1345b40b484ef16f6ff5e922bf14dac (patch) | |
tree | f7e1e7ddf8d24c2beacc09d67e6989cca431c61f /erts/preloaded | |
parent | f1dede329de90e4805cd21a43bb5b19e288c81a3 (diff) | |
download | otp-4f63e427f1345b40b484ef16f6ff5e922bf14dac.tar.gz otp-4f63e427f1345b40b484ef16f6ff5e922bf14dac.tar.bz2 otp-4f63e427f1345b40b484ef16f6ff5e922bf14dac.zip |
Add 'show_econnreset' TCP socket option
An ECONNRESET is a socket error which tells us that a TCP peer has sent
an RST. The RST indicates that they have aborted the connection and
that the payload we have received should not be considered complete. Up
until now, the implementation of TCP in inet_drv.c has hidden the
receipt of the RST from the user, treating it as though it was just
a FIN terminating the read side of the socket.
There are many cases where user code needs to be able to distinguish
between a socket that was closed normally and one that was aborted.
Setting the option {show_econnreset, true} enables the user to receive
ECONNRESET errors on both active and passive sockets.
A connected socket returned from gen_tcp:accept/1 will inherit the
show_econnreset setting of the listening socket.
By default this option is set to {show_econnreset, false}.
Note that this patch only enables the reporting of ECONNRESET when
the socket is being read from. It does not report ECONNRESET (or
EPIPE) when the user tries to write to a connection when an RST
has already been received. Currently the TCP implementation in
inet_drv.c hides all such send errors from the user in favour
of returning {error, close}. A separate patch will be needed to
enable the reporting of such errors.
Diffstat (limited to 'erts/preloaded')
-rw-r--r-- | erts/preloaded/src/prim_inet.erl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/erts/preloaded/src/prim_inet.erl b/erts/preloaded/src/prim_inet.erl index 622e1be869..fb0f67aa8a 100644 --- a/erts/preloaded/src/prim_inet.erl +++ b/erts/preloaded/src/prim_inet.erl @@ -1140,6 +1140,7 @@ enc_opt(delay_send) -> ?INET_LOPT_TCP_DELAY_SEND; enc_opt(packet_size) -> ?INET_LOPT_PACKET_SIZE; enc_opt(read_packets) -> ?INET_LOPT_READ_PACKETS; enc_opt(netns) -> ?INET_LOPT_NETNS; +enc_opt(show_econnreset) -> ?INET_LOPT_TCP_SHOW_ECONNRESET; enc_opt(raw) -> ?INET_OPT_RAW; % Names of SCTP opts: enc_opt(sctp_rtoinfo) -> ?SCTP_OPT_RTOINFO; @@ -1197,6 +1198,7 @@ dec_opt(?INET_LOPT_TCP_DELAY_SEND) -> delay_send; dec_opt(?INET_LOPT_PACKET_SIZE) -> packet_size; dec_opt(?INET_LOPT_READ_PACKETS) -> read_packets; dec_opt(?INET_LOPT_NETNS) -> netns; +dec_opt(?INET_LOPT_TCP_SHOW_ECONNRESET) -> show_econnreset; dec_opt(?INET_OPT_RAW) -> raw; dec_opt(I) when is_integer(I) -> undefined. @@ -1296,6 +1298,7 @@ type_opt_1(delay_send) -> bool; type_opt_1(packet_size) -> uint; type_opt_1(read_packets) -> uint; type_opt_1(netns) -> binary; +type_opt_1(show_econnreset) -> bool; %% %% SCTP options (to be set). If the type is a record type, the corresponding %% record signature is returned, otherwise, an "elementary" type tag |