Age | Commit message (Collapse) | Author |
|
|
|
|
|
* 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
|
|
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.
|
|
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.
|
|
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.
|
|
Fix the sorting logic in add_multi_timer() and expand the test case
coverage around this area.
|
|
OTP-12797
|
|
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.
|
|
check (nbytes == 0 && d->c.sendfile.nbytes == 0) when efile_sendfile returns 0 and
has EAGAIN set.
FreeBSD sendfile(2) man page:
When using a socket marked for non-blocking I/O, sendfile() may send
fewer bytes than requested. In this case, the number of bytes
successfully written is returned in *sbytes (if specified), and the error
EAGAIN is returned.
The number of bytes successfully written can be 0. If this happens and
in a request handling either file:sendfile/2 or file:sendfile/5 with Bytes=0,
the sendfile loop will stop prematurely and file:sendfile will return
{ok, BytesSent} where BytesSent < DataAfterOffset, effectively breaking sendfile
support on FreeBSD.
|
|
|
|
The `invoke_pwritev()` function was in some places using the union
member intended for the `invoke_writev()` function.
|
|
|
|
All uses of these macros were removed in
commit c3a615aa2da09bc3a0575e973959f800460a63de.
|
|
* seriyps/zlib-inflate-bound:
Add zlib limited output buffer size functionality
Conflicts:
erts/preloaded/ebin/zlib.beam
OTP-12548
|
|
This functionality may be useful for compressed streams with high
compression ratio (in case of gzip it may be up to x1000), when
small amount of compressed data will produce large amount of
uncompressed output. This may lead to DoS attacks, because
server easily goes out of memory.
Example of such high compression ratio stream:
```
dd if=/dev/zero of=sparse.bin bs=1MB count=100 # 100mb of zeroes
gzip sparse.bin # 95kb sparse.bin.gz
$ erl
> {ok, Compressed} = file:read_file("sparse.bin.gz"),
> 97082 = size(Compressed),
> Uncompressed = zlib:gunzip(Compressed),
> 100000000 = iolist_size(Uncompressed).
```
|
|
Conflicts:
OTP_VERSION
erts/emulator/sys/unix/sys.c
erts/vsn.mk
|
|
|
|
* egil/fix-getifaddrs-realloc/OTP-12445:
erts: Fix getifaddrs realloc ptr mismatch
|
|
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.
|
|
Closes all open socket before writing crashdump to file.
|
|
|
|
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.
|
|
Handle peer addresses that are unconfirmed (i.e. in state SCTP_UNCONFIRMED).
Handle unknown states instead of using ASSERT
|
|
and usage
|
|
This only produces an error on win32, but should not really be called
on *nix either.
|
|
|
|
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
|
|
Inet close must remove fd from select/poll without closing the fd.
|
|
|
|
* lukas/ose/master-17.0/OTP-11334:
erts: Move debug printout to eliminate gcc warning
|
|
|
|
* lukas/ose/master-17.0/OTP-11334:
ose: Fix erts assert failed printouts
ose: fix for packet_bytes in fd/spawn driver.
ose: Prepare slave for running on OSE
ose: Fix bug when hunting for signal proxy
ose: Implement tcp inet driver for OSE
ose: Add ifdefs for HAVE_UDP
ose: Yielding has to be done differently for background processes.
ose: Print faults in aio sys driver calls
ose: Prinout errno when to_erl read fails
ose: erlang display goes to ramlog printf
ose: Initiate stdin/stdout/stderr
ose: Break lmconf into one per load module
ose: Reset busy port when pdq empty
ose: Restore the owner of the signal
|
|
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.
|
|
|
|
* bjorn/erts/zlib-fix:
zlib: Fix adler32_combine/4 and crc32_combine/4
|
|
* sverk/win-long-filenames/OTP-11813:
erts: Cleanup debug tracing in win_efile.c
erts: Fix file:list_dir for windows paths 258 or 259 chars long
erts: Increase MAXPATHLEN to 4096 for windows
erts: Fix bug in efile_readlink for long win paths
kernel: Fix failed tests in prim_file_SUITE for windows
erts: Fix compiler warning in win_efile.c
erts: Skip tests of paths longer than 255 characters as atoms
erts: Skip tests of file:set_cwd for too long path on Windows
erts: Make file:make_symlink/2 return {error,eperm} on Windows
erts: Revert file:set_cwd impl for windows
erts: Ignore reduntant slashes in windows paths
fix file_SUITE:cur_dir_0 for long windows paths
erts: Fix file_SUITE:make_del_dir for long paths
erts: Fix long windows paths for compressed files
erts: Use GetFullPathNameW to construct abs paths from relative ones
erts: Fix file driver to handle long paths on windows
Conflicts:
erts/emulator/drivers/win32/win_efile.c
|
|
Since our config.h is included in each source file in the zlib
directory, we must make sure that config.h is also included
every time zlib functions are called to ensure that definitions
of types are consistent.
zlib_drv.c did not include config.h, which caused problems on
a MacOS X Leopard system. What happened was that HAVE_UNISTD_H
was not defined when zlib.h was included. When unistd.h is not
known to exist, the type z_off_t will be set to a long (32 bits
on this platform). But when the zlib source files were compiled,
HAVE_UNISTD_H was defined, unistd.h would be included, and
z_off_t would be set to off_t (64 bits; defined in unistd.h).
As a result of the mismatch, calls to the adler32_combine() and
crc32_combine() would pass only 32 bits in the len2 argument when
64 bits were expected.
|
|
|
|
* lukas/ose/master/OTP-11334: (71 commits)
erts: Fix unix efile assert
ose: Use -O2 when building
ose: Expand OSE docs
ose: Add dummy ttsl driver
ose: Cleanup cleanup of mutex selection defines
ose: Polish mmap configure checks
ose: Add ose specific x-compile flags
ose: Updating fd_driver and spawn_driver for OSE
ose: Updating event and signal API for OSE
ose: Cleanup of mutex selection defines
win32: Compile erl_log.exe
ose: Remove uneccesary define
ose: Fix ssl configure test for osx
erts: Fix sys_msg_dispatcher assert
ose: Fix broken doc links
ose: Thread priorities configurable from lmconf
ose: Yielding the cpu is done "the OSE" way
ose: Start using ppdata for tse key
ose: Do not use spinlocks on OSE
ose: Fix support for crypto
...
Conflicts:
lib/crypto/c_src/crypto.c
|
|
Some OSE cross-chains have problems with system includes
being used, so for atleast OSE specific parts we use ""
instead of <>.
|
|
|
|
This is needed because OSE does not have the same integers
as unix/win32 for SEEK_ST and friends.
|
|
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.
|
|
Daniel Goertzen reported that commit 8a147a7365 broke building
of Erlang/OTP on Gentoo Linux because the macro OF() was missing.
Apparently, on Gentoo the OF() macro in zconf.h has been renamed
to _Z_OF() (to avoid polluting the global namespace).
Don't use the OF() macro in gzio.c since it no longer serves any
useful purpose (it provided compatibility with pre-ANSI/ISO C
compilers, but the rest of Erlang/OTP requires an ANSI/ISO C
compiler anyway).
|
|
* lukas/erts/sendfile_no_async_pool/OTP-11639:
erts/kernel: sendfile no longer uses async threads
|
|
* lukas/erts/sendfile_passive_mode_fix/OTP-11614:
erts: fix bug when using passive mode and sendfile
|
|
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.
|
|
This has been done because a slow client attack is possible if the
async thread pool is used. The scenario is:
Client does a request for a file and then slowly receives the file one
byte at a time. This will eventually fill the async thread pool with blocking
sendfile operations and thus starving the vm of all file operations.
If you still want to use the async threads pool for sendfile an option to
enable it has been introduced.
|
|
gzio.c is our own replacement for zlib's gzopen() etc
(based on a version of gzio.c that was included in an old version
of zlib).
Unfortunately, gzio.c still depends on the *internal* zlib header file
zutil.h which is not supposed to be used outside of the zlib source
code. The dependencies are the use of the gzFile typedef and the
F_OPEN() macro.
Instead of gzFile, define and use our own ErtsGzFile.
To get rid of the F_OPEN() macro, call open() of _wfopen() directly.
|