aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/common/inet_drv.c
AgeCommit message (Collapse)Author
2015-12-04Merge branch 'maint-17' into maintHenrik Nord
Conflicts: OTP_VERSION erts/doc/src/notes.xml erts/vsn.mk lib/kernel/doc/src/notes.xml lib/kernel/src/kernel.appup.src lib/kernel/vsn.mk lib/ssl/doc/src/notes.xml lib/ssl/src/ssl.appup.src lib/ssl/src/ssl_cipher.erl lib/ssl/vsn.mk otp_versions.table
2015-11-19Fix error propagate from setoptsRaimo Niskanen
2015-10-26erts: Add {line_delimiter, byte()} option to inet:setopts/2Serge Aleynikov
A new {line_delimiter, byte()} option allows line-oriented TCP-based protocols to use a custom line delimiting character. It is to be used in conjunction with {packet, line}. This option also works with erlang:decode_packet/3 when its first argument is 'line'.
2015-09-07erts: Fix inet packet mode ssl_tls for passive modeSverker Eriksson
Caused stack corruption leading to VM crash on windows. {packet,ssl_tls} is undocumented by the way.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-06-17Merge branch 'nybek/fix_so_linger_zero__simple'Raimo Niskanen
* nybek/fix_so_linger_zero__simple: Update prim_inet.beam Fix socket option {linger, {true, 0}} to abort TCP connections Apply 'show_econnreset' socket option to send errors as well Add 'show_econnreset' TCP socket option
2015-06-09Fix socket option {linger, {true, 0}} to abort TCP connectionsRory Byrne
Up until now, if {linger, {true, 0}} is set on the socket and there is data in the port driver queue, the connection is not aborted until the port queue is empty and close() is called on the underlying file descriptor. This bug allows an idle TCP client to prevent a server from terminating the connection and freeing resources. This patch fixes the problem by discarding the port queue if the socket is closed when {linger, {true, 0}} is set.
2015-06-09Apply 'show_econnreset' socket option to send errors as wellRory Byrne
Up till now all send errors have been translated into a generic {error, closed}. This patch allows {error, econnreset} to be returned on send errors when it is detected that the TCP peer has sent an RST.
2015-06-09Add 'show_econnreset' TCP socket optionRory Byrne
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.
2015-06-04Fix add_multi_timer() in inet_drvRory Byrne
Fix the sorting logic in add_multi_timer() and expand the test case coverage around this area.
2015-05-12Fix gen_tcp:shutdown/2 by making it asynchronousRory Byrne
If the driver queue is empty, or the user is requesting a 'read' shutdown, then the shutdown() syscall is performed synchronously, as per the old version of shutdown/2. However, if the user is requesting a 'write' or 'read_write' shutdown, and there is data in the driver queue for the socket, then the shutdown() syscall is delayed and handled asynchronously when the driver queue is written out. This version of shutdown solves a number of issues with the old version. The two main solutions it offers are: * It doesn't block when the TCP peer is idle or slow. This is the expected behaviour when shutdown() is called: the caller needs to be able to continue reading from the socket, not be prevented from doing so. * It doesn't truncate the output. The current version of gen_tcp:shutdown/2 will truncate any outbound data in the driver queue after about 10 seconds if the TCP peer is idle of slow. Worse yet, it doesn't even inform anyone that the data has been truncated: 'ok' is returned to the caller; and a FIN rather than an RST is sent to the TCP peer. For a detailed description of all the problems with the old version of shutdown, please see the EEP Light that was written to justify this patch.
2015-02-03Merge branch 'maint'Zandra Hird
Conflicts: OTP_VERSION erts/emulator/sys/unix/sys.c erts/vsn.mk
2015-02-03Merge branch 'maint-17' into maintZandra Hird
2015-01-30Merge branch 'egil/fix-getifaddrs-realloc/OTP-12445' into maint-17Erlang/OTP
* egil/fix-getifaddrs-realloc/OTP-12445: erts: Fix getifaddrs realloc ptr mismatch
2015-01-29erts: Fix getifaddrs realloc ptr mismatchBjörn-Egil Dahlberg
When a buffer was exhausted and subsequently a realloc, we could get an invalid pointer. For this to occur we would need to have a realloc to lower adresses. The symptom would be garbage returned from erlang:port_control(Port, 25, []) (prim_inet:getifaddrs(Port) resulting in a badarg) or a segmentation fault.
2015-01-23erts: Use emergency close to close epmdBjörn-Egil Dahlberg
Closes all open socket before writing crashdump to file.
2015-01-14Merge branch 'maint'Marcus Arendt
2015-01-13erts: Extend driver interface with emergency_closeBjörn-Egil Dahlberg
The intention of this callback is to close all sockets associated to a port. It is closed only on crashdumps. This will currently only be used for the epmd port.
2014-12-08Fix inet:getopts involving #sctp_paddrinfo{}Simon Cornish
Handle peer addresses that are unconfirmed (i.e. in state SCTP_UNCONFIRMED). Handle unknown states instead of using ASSERT
2014-12-02erts: Add compile time assert ERTS_CT_ASSERTSverker Eriksson
and usage
2014-09-12erts: getsockname is not allowed on non-bound socketsLukas Larsson
This only produces an error on win32, but should not really be called on *nix either.
2014-08-25Fix misspellings of 'another'Tuncer Ayaz
2014-07-24Merge branch 'maint-r16' into maintHenrik Nord
Conflicts: erts/doc/src/notes.xml erts/preloaded/ebin/prim_inet.beam erts/vsn.mk lib/kernel/doc/src/notes.xml lib/kernel/vsn.mk
2014-07-22erts: Fix inet close on prebound fdsBjörn-Egil Dahlberg
Inet close must remove fd from select/poll without closing the fd.
2014-07-22kernel: When doing an fdopen we now also bind the fd to the specified addr/portLukas Larsson
2014-03-28erts: Move debug printout to eliminate gcc warningLukas Larsson
2014-03-26ose: Implement tcp inet driver for OSELukas Larsson
The inet driver for OSE has to handle signals instead of selects and thus the wrappers for ready_input/output are a little bit different. However the majority of the inet code remains the same.
2014-03-26ose: Add ifdefs for HAVE_UDPLukas Larsson
2014-02-24Added support for ENEA OSELukas Larsson
This port has support for both non-smp and smp. It contains a new way to do io checking in which erts_poll_wait receives the payload of the polled entity. This has implications for all linked-in drivers.
2014-01-27Merge branch 'lukas/erts/sendfile_passive_mode_fix/OTP-11614'Lukas Larsson
* lukas/erts/sendfile_passive_mode_fix/OTP-11614: erts: fix bug when using passive mode and sendfile
2014-01-27erts: fix bug when using passive mode and sendfileLukas Larsson
The bug incorrectly issued driver_select when un-ignoring an fd for a socket in passive mode, which caused an incorrect error tuple to be returned when the remote end closed the connection.
2013-12-13erts: Fix compiler warningSverker Eriksson
2013-11-26Merge branch 'maint'Raimo Niskanen
Conflicts: erts/preloaded/ebin/prim_inet.beam lib/kernel/test/gen_sctp_SUITE.erl
2013-11-26Merge branch 'maint-r16' into maintRaimo Niskanen
2013-11-20Suppress false valgrind warnings caused by sctp_getpaddrsSverker Eriksson
2013-11-11Clean up address family handling towards ErlangRaimo Niskanen
2013-11-07Implement prim_inet:socknames/1,2 and prim_inet:peernames/1,2Raimo Niskanen
2013-10-15Merge branch 'maint'Sverker Eriksson
Conflicts: erts/preloaded/ebin/erlang.beam
2013-09-30erts: Refactor the ASSERT macroSverker Eriksson
Introduce unconditional ERTS_ASSERT and use that for both ASSERT and ASSERT_EXPR.
2013-09-23add {active,N} socket option for TCP, UDP, and SCTPSteve Vinoski
Add the {active,N} socket option, where N is an integer in the range -32768..32767, to allow a caller to specify the number of data messages to be delivered to the controlling process. Once the socket's delivered message count either reaches 0 or is explicitly set to 0 with inet:setopts/2 or by including {active,0} as an option when the socket is created, the socket transitions to passive ({active, false}) mode and the socket's controlling process receives a message to inform it of the transition. TCP sockets receive {tcp_passive,Socket}, UDP sockets receive {udp_passive,Socket} and SCTP sockets receive {sctp_passive,Socket}. The socket's delivered message counter defaults to 0, but it can be set using {active,N} via any gen_tcp, gen_udp, or gen_sctp function that takes socket options as arguments, or via inet:setopts/2. New N values are added to the socket's current counter value, and negative numbers can be used to reduce the counter value. Specifying a number that would cause the socket's counter value to go above 32767 causes an einval error. If a negative number is specified such that the counter value would become negative, the socket's counter value is set to 0 and the socket transitions to passive mode. If the counter value is already 0 and inet:setopts(Socket, [{active,0}]) is specified, the counter value remains at 0 but the appropriate passive mode transition message is generated for the socket. This commit contains a modified preloaded prim_inet.beam due to changes in prim_inet.erl. Add tests for {active,N} mode for TCP, UDP, and SCTP sockets. Add documentation for {active,N} mode for inet, gen_tcp, gen_udp, and gen_sctp.
2013-07-17Implement netns for SCTP + bugfixesRaimo Niskanen
2013-07-17Implement emulator netns support for TCP and UDPRaimo Niskanen
2013-05-16Merge branch 'rickard/inet_opts/OTP-11075' into maintRickard Green
* rickard/inet_opts/OTP-11075: Make high_msgq_watermark and low_msgq_watermark generic inet options Conflicts: erts/preloaded/ebin/prim_inet.beam
2013-05-06Make high_msgq_watermark and low_msgq_watermark generic inet optionsRickard Green
2013-03-04erts: Use block comments - ansi styleBjörn-Egil Dahlberg
2013-02-22Update copyright yearsBjörn-Egil Dahlberg
2013-02-21Merge branch 'sverk/tcp-exit_on_close-false'Sverker Eriksson
* sverk/tcp-exit_on_close-false: inet_drv: Fix condition to reject INET_REQ_IGNOREFD for UDP and SCTP A stab at fixing bug with {exit_on_close,false} not working
2013-02-07inet_drv: Fix condition to reject INET_REQ_IGNOREFD for UDP and SCTPSverker Eriksson
2013-01-29A stab at fixing bug with {exit_on_close,false} not workingSverker Eriksson
when invalid packets are received.
2013-01-23Make _oct counters in inet_drv exactly 64 bitsPatrik Nyblom
Also, on 64 bit architectures, use 64 bit int's for the counters and be specific about the counter variables sizes utilizing datatypes from sys.h.