aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/doc/src/erl.xml14
-rw-r--r--erts/emulator/Makefile.in1
-rw-r--r--erts/emulator/drivers/common/efile_drv.c33
-rw-r--r--erts/emulator/sys/common/erl_sys_common_misc.c2
-rw-r--r--erts/emulator/sys/unix/sys.c2
-rw-r--r--erts/preloaded/ebin/prim_file.beambin44612 -> 44880 bytes
-rw-r--r--erts/preloaded/src/prim_file.erl17
-rw-r--r--erts/vsn.mk2
8 files changed, 51 insertions, 20 deletions
diff --git a/erts/doc/src/erl.xml b/erts/doc/src/erl.xml
index 27a23174d5..4aa3033f40 100644
--- a/erts/doc/src/erl.xml
+++ b/erts/doc/src/erl.xml
@@ -535,12 +535,15 @@
</item>
<tag><marker id="file_name_encoding"></marker><c><![CDATA[+fnl]]></c></tag>
<item>
- <p>The VM works with file names as if they are encoded using the ISO-latin-1 encoding, disallowing Unicode characters with codepoints beyond 255. This is default on operating systems that have transparent file naming, i.e. all Unixes except MacOSX.</p>
+ <p>The VM works with file names as if they are encoded using the ISO-latin-1 encoding, disallowing Unicode characters with codepoints beyond 255.</p>
<p>See <seealso marker="stdlib:unicode_usage#unicode_file_names">STDLIB User's Guide</seealso> for more infomation about unicode file names.</p>
</item>
<tag><c><![CDATA[+fnu[{w|i|e}]]]></c></tag>
<item>
- <p>The VM works with file names as if they are encoded using UTF-8 (or some other system specific Unicode encoding). This is the default on operating systems that enforce Unicode encoding, i.e. Windows and MacOSX.</p>
+ <p>The VM works with file names as if they are encoded using
+ UTF-8 (or some other system specific Unicode encoding). This
+ is the default on operating systems that enforce Unicode
+ encoding, i.e. Windows and MacOS X.</p>
<p>The <c>+fnu</c> switch can be followed by <c>w</c>,
<c>i</c>, or <c>e</c> to control the way wrongly encoded file
names are to be reported. <c>w</c> means that a warning is
@@ -556,7 +559,12 @@
</item>
<tag><c><![CDATA[+fna[{w|i|e}]]]></c></tag>
<item>
- <p>Selection between <c>+fnl</c> and <c>+fnu</c> is done based on the current locale settings in the OS, meaning that if you have set your terminal for UTF-8 encoding, the filesystem is expected to use the same encoding for file names (use with care).</p>
+ <p>Selection between <c>+fnl</c> and <c>+fnu</c> is done based
+ on the current locale settings in the OS, meaning that if you
+ have set your terminal for UTF-8 encoding, the filesystem is
+ expected to use the same encoding for file names. This is
+ default on all operating systems except MacOS X and
+ Windows.</p>
<p>The <c>+fna</c> switch can be followed by <c>w</c>,
<c>i</c>, or <c>e</c>. This will have effect if the locale
settings cause the behavior of <c>+fnu</c> to be selected.
diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
index 54365f279c..f88a4ccc24 100644
--- a/erts/emulator/Makefile.in
+++ b/erts/emulator/Makefile.in
@@ -665,7 +665,6 @@ endif
ifneq ($(filter tile-%,$(TARGET)),)
$(OBJDIR)/beam_emu.o: beam/beam_emu.c
$(V_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) \
- -OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off \
$(INCLUDES) -c $< -o $@
else
# Usually the same as the default rule, but certain platforms (e.g. win32) mix
diff --git a/erts/emulator/drivers/common/efile_drv.c b/erts/emulator/drivers/common/efile_drv.c
index dca979c13a..e040864d24 100644
--- a/erts/emulator/drivers/common/efile_drv.c
+++ b/erts/emulator/drivers/common/efile_drv.c
@@ -167,7 +167,7 @@ dt_private *get_dt_private(int);
#ifdef USE_THREADS
-#define IF_THRDS if (sys_info.async_threads > 0)
+#define THRDS_AVAILABLE (sys_info.async_threads > 0)
#ifdef HARDDEBUG /* HARDDEBUG in io.c is expected too */
#define TRACE_DRIVER fprintf(stderr, "Efile: ")
#else
@@ -177,24 +177,26 @@ dt_private *get_dt_private(int);
#define MUTEX_LOCK(m) do { IF_THRDS { TRACE_DRIVER; driver_pdl_lock(m); } } while (0)
#define MUTEX_UNLOCK(m) do { IF_THRDS { TRACE_DRIVER; driver_pdl_unlock(m); } } while (0)
#else
-#define IF_THRDS if (0)
+#define THRDS_AVAILABLE (0)
#define MUTEX_INIT(m, p)
#define MUTEX_LOCK(m)
#define MUTEX_UNLOCK(m)
#endif
+#define IF_THRDS if (THRDS_AVAILABLE)
+#define SENDFILE_FLGS_USE_THREADS (1 << 0)
/**
* On DARWIN sendfile can deadlock with close if called in
* different threads. So until Apple fixes so that sendfile
* is not buggy we disable usage of the async pool for
* DARWIN. The testcase t_sendfile_crashduring reproduces
- * this error when using +A 10.
+ * this error when using +A 10 and enabling SENDFILE_FLGS_USE_THREADS.
*/
#if defined(__APPLE__) && defined(__MACH__)
-#define USE_THRDS_FOR_SENDFILE 0
+#define USE_THRDS_FOR_SENDFILE(DATA) 0
#else
-#define USE_THRDS_FOR_SENDFILE (sys_info.async_threads > 0)
+#define USE_THRDS_FOR_SENDFILE(DATA) (DATA->flags & SENDFILE_FLGS_USE_THREADS)
#endif /* defined(__APPLE__) && defined(__MACH__) */
@@ -300,7 +302,7 @@ static void file_stop_select(ErlDrvEvent event, void* _);
enum e_timer {timer_idle, timer_again, timer_write};
#ifdef HAVE_SENDFILE
enum e_sendfile {sending, not_sending};
-static void free_sendfile(void *data);
+#define SENDFILE_USE_THREADS (1 << 0)
#endif /* HAVE_SENDFILE */
struct t_data;
@@ -1932,7 +1934,7 @@ static void invoke_sendfile(void *data)
d->c.sendfile.written += nbytes;
- if (result == 1 || (result == 0 && USE_THRDS_FOR_SENDFILE)) {
+ if (result == 1 || (result == 0 && USE_THRDS_FOR_SENDFILE(d))) {
d->result_ok = 0;
} else if (result == 0 && (d->errInfo.posix_errno == EAGAIN
|| d->errInfo.posix_errno == EINTR)) {
@@ -1949,7 +1951,7 @@ static void invoke_sendfile(void *data)
static void free_sendfile(void *data) {
struct t_data *d = (struct t_data *)data;
- if (USE_THRDS_FOR_SENDFILE) {
+ if (USE_THRDS_FOR_SENDFILE(d)) {
SET_NONBLOCKING(d->c.sendfile.out_fd);
} else {
MUTEX_LOCK(d->c.sendfile.q_mtx);
@@ -4122,8 +4124,16 @@ file_outputv(ErlDrvData e, ErlIOVec *ev) {
goto done;
}
- if (hd_len != 0 || tl_len != 0 || flags != 0) {
- /* We do not allow header, trailers and/or flags right now */
+ if (hd_len != 0 || tl_len != 0) {
+ /* We do not allow header, trailers */
+ reply_posix_error(desc, EINVAL);
+ goto done;
+ }
+
+
+ if (flags & SENDFILE_FLGS_USE_THREADS && !THRDS_AVAILABLE) {
+ /* We do not allow use_threads flag on a system where
+ no threads are available. */
reply_posix_error(desc, EINVAL);
goto done;
}
@@ -4133,6 +4143,7 @@ file_outputv(ErlDrvData e, ErlIOVec *ev) {
d->command = command;
d->invoke = invoke_sendfile;
d->free = free_sendfile;
+ d->flags = flags;
d->level = 2;
d->c.sendfile.out_fd = (int) out_fd;
@@ -4152,7 +4163,7 @@ file_outputv(ErlDrvData e, ErlIOVec *ev) {
d->c.sendfile.nbytes = nbytes;
- if (USE_THRDS_FOR_SENDFILE) {
+ if (USE_THRDS_FOR_SENDFILE(d)) {
SET_BLOCKING(d->c.sendfile.out_fd);
} else {
/**
diff --git a/erts/emulator/sys/common/erl_sys_common_misc.c b/erts/emulator/sys/common/erl_sys_common_misc.c
index 31ad3b82d5..e3ba741058 100644
--- a/erts/emulator/sys/common/erl_sys_common_misc.c
+++ b/erts/emulator/sys/common/erl_sys_common_misc.c
@@ -52,7 +52,7 @@ static int filename_warning = ERL_FILENAME_WARNING_WARNING;
/* Default unicode on windows and MacOS X */
static int user_filename_encoding = ERL_FILENAME_UTF8;
#else
-static int user_filename_encoding = ERL_FILENAME_LATIN1;
+static int user_filename_encoding = ERL_FILENAME_UNKNOWN;
#endif
/* This controls the heuristic in printing characters in shell and w/
io:format("~tp", ...) etc. */
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 59e34eb819..a5294ad84e 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -409,8 +409,10 @@ void sys_tty_reset(int exit_code)
#ifdef __tile__
/* Direct malloc to spread memory around the caches of multiple tiles. */
#include <malloc.h>
+#if defined(MALLOC_USE_HASH)
MALLOC_USE_HASH(1);
#endif
+#endif
#ifdef USE_THREADS
diff --git a/erts/preloaded/ebin/prim_file.beam b/erts/preloaded/ebin/prim_file.beam
index d5a1ec766d..e40e33b332 100644
--- a/erts/preloaded/ebin/prim_file.beam
+++ b/erts/preloaded/ebin/prim_file.beam
Binary files differ
diff --git a/erts/preloaded/src/prim_file.erl b/erts/preloaded/src/prim_file.erl
index 5999e98340..34679404a2 100644
--- a/erts/preloaded/src/prim_file.erl
+++ b/erts/preloaded/src/prim_file.erl
@@ -27,7 +27,7 @@
%% Generic file contents operations
-export([open/2, close/1, datasync/1, sync/1, advise/4, position/2, truncate/1,
write/2, pwrite/2, pwrite/3, read/2, read_line/1, pread/2, pread/3,
- copy/3, sendfile/10, allocate/3]).
+ copy/3, sendfile/8, allocate/3]).
%% Specialized file operations
-export([open/1, open/3]).
@@ -149,6 +149,9 @@
-define(POSIX_FADV_DONTNEED, 4).
-define(POSIX_FADV_NOREUSE, 5).
+%% Sendfile flags
+-define(EFILE_SENDFILE_USE_THREADS, 1).
+
%%% BIFs
@@ -582,13 +585,14 @@ write_file(_, _) ->
% {error, enotsup};
sendfile(#file_descriptor{module = ?MODULE, data = {Port, _}},
Dest, Offset, Bytes, _ChunkSize, Headers, Trailers,
- _Nodiskio, _MNowait, _Sync) ->
+ Flags) ->
case erlang:port_get_data(Dest) of
Data when Data == inet_tcp; Data == inet6_tcp ->
ok = inet:lock_socket(Dest,true),
{ok, DestFD} = prim_inet:getfd(Dest),
+ IntFlags = translate_sendfile_flags(Flags),
try drv_command(Port, [<<?FILE_SENDFILE, DestFD:32,
- 0:8,
+ IntFlags:8,
Offset:64/unsigned,
Bytes:64/unsigned,
(iolist_size(Headers)):32/unsigned,
@@ -601,6 +605,13 @@ sendfile(#file_descriptor{module = ?MODULE, data = {Port, _}},
{error,badarg}
end.
+translate_sendfile_flags([{use_threads,true}|T]) ->
+ ?EFILE_SENDFILE_USE_THREADS bor translate_sendfile_flags(T);
+translate_sendfile_flags([_|T]) ->
+ translate_sendfile_flags(T);
+translate_sendfile_flags([]) ->
+ 0.
+
%%%-----------------------------------------------------------------
%%% Functions operating on files without handle to the file. ?DRV.
diff --git a/erts/vsn.mk b/erts/vsn.mk
index 8e77a9a26e..88a393f3d5 100644
--- a/erts/vsn.mk
+++ b/erts/vsn.mk
@@ -22,7 +22,7 @@ VSN = 6.0
# OTP major version
SYSTEM_VSN = 17
# OTP correction package version
-SYSTEM_CP_VSN = 17.0-rc0
+SYSTEM_CP_VSN = 17.0-rc1
# Port number 4365 in 4.2
# Port number 4366 in 4.3