aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/doc/src/app.xml4
-rw-r--r--lib/kernel/doc/src/application.xml46
-rw-r--r--lib/kernel/doc/src/auth.xml4
-rw-r--r--lib/kernel/doc/src/book.xml4
-rw-r--r--lib/kernel/doc/src/code.xml2
-rw-r--r--lib/kernel/doc/src/config.xml4
-rw-r--r--lib/kernel/doc/src/disk_log.xml4
-rw-r--r--lib/kernel/doc/src/erl_boot_server.xml4
-rw-r--r--lib/kernel/doc/src/erl_ddll.xml4
-rw-r--r--lib/kernel/doc/src/erl_prim_loader_stub.xml4
-rw-r--r--lib/kernel/doc/src/erlang_stub.xml4
-rw-r--r--lib/kernel/doc/src/error_handler.xml2
-rw-r--r--lib/kernel/doc/src/error_logger.xml4
-rw-r--r--lib/kernel/doc/src/fascicules.xml2
-rw-r--r--lib/kernel/doc/src/file.xml132
-rw-r--r--lib/kernel/doc/src/gen_sctp.xml37
-rw-r--r--lib/kernel/doc/src/gen_tcp.xml10
-rw-r--r--lib/kernel/doc/src/gen_udp.xml21
-rw-r--r--lib/kernel/doc/src/global.xml2
-rw-r--r--lib/kernel/doc/src/global_group.xml4
-rw-r--r--lib/kernel/doc/src/heart.xml13
-rw-r--r--lib/kernel/doc/src/inet.xml211
-rw-r--r--lib/kernel/doc/src/inet_res.xml4
-rw-r--r--lib/kernel/doc/src/init_stub.xml4
-rw-r--r--lib/kernel/doc/src/kernel_app.xml4
-rw-r--r--lib/kernel/doc/src/net_adm.xml4
-rw-r--r--lib/kernel/doc/src/net_kernel.xml4
-rw-r--r--lib/kernel/doc/src/notes.xml133
-rw-r--r--lib/kernel/doc/src/notes_history.xml4
-rw-r--r--lib/kernel/doc/src/os.xml15
-rw-r--r--lib/kernel/doc/src/part_notes.xml4
-rw-r--r--lib/kernel/doc/src/part_notes_history.xml4
-rw-r--r--lib/kernel/doc/src/pg2.xml4
-rw-r--r--lib/kernel/doc/src/ref_man.xml2
-rw-r--r--lib/kernel/doc/src/rpc.xml6
-rw-r--r--lib/kernel/doc/src/seq_trace.xml4
-rw-r--r--lib/kernel/doc/src/specs.xml2
-rw-r--r--lib/kernel/doc/src/user.xml4
-rw-r--r--lib/kernel/doc/src/wrap_log_reader.xml4
-rw-r--r--lib/kernel/doc/src/zlib_stub.xml4
-rw-r--r--lib/kernel/src/application.erl65
-rw-r--r--lib/kernel/src/application_controller.erl54
-rw-r--r--lib/kernel/src/application_master.erl44
-rw-r--r--lib/kernel/src/auth.erl4
-rw-r--r--lib/kernel/src/code.erl2
-rw-r--r--lib/kernel/src/code_server.erl251
-rw-r--r--lib/kernel/src/disk_log.erl13
-rw-r--r--lib/kernel/src/disk_log_1.erl78
-rw-r--r--lib/kernel/src/disk_log_server.erl20
-rw-r--r--lib/kernel/src/dist_ac.erl68
-rw-r--r--lib/kernel/src/erl_boot_server.erl35
-rw-r--r--lib/kernel/src/erl_epmd.erl71
-rw-r--r--lib/kernel/src/erl_reply.erl4
-rw-r--r--lib/kernel/src/error_logger.erl20
-rw-r--r--lib/kernel/src/erts_debug.erl4
-rw-r--r--lib/kernel/src/file.erl57
-rw-r--r--lib/kernel/src/file_io_server.erl12
-rw-r--r--lib/kernel/src/file_server.erl3
-rw-r--r--lib/kernel/src/gen_sctp.erl8
-rw-r--r--lib/kernel/src/gen_tcp.erl4
-rw-r--r--lib/kernel/src/gen_udp.erl2
-rw-r--r--lib/kernel/src/global.erl5
-rw-r--r--lib/kernel/src/global_group.erl13
-rw-r--r--lib/kernel/src/group.erl8
-rw-r--r--lib/kernel/src/heart.erl36
-rw-r--r--lib/kernel/src/hipe_unified_loader.erl53
-rw-r--r--lib/kernel/src/inet.erl200
-rw-r--r--lib/kernel/src/inet6_tcp_dist.erl2
-rw-r--r--lib/kernel/src/inet_db.erl11
-rw-r--r--lib/kernel/src/inet_gethost_native.erl6
-rw-r--r--lib/kernel/src/inet_int.hrl4
-rw-r--r--lib/kernel/src/inet_parse.erl6
-rw-r--r--lib/kernel/src/inet_res.erl33
-rw-r--r--lib/kernel/src/inet_sctp.erl4
-rw-r--r--lib/kernel/src/inet_tcp_dist.erl2
-rw-r--r--lib/kernel/src/kernel.appup.src16
-rw-r--r--lib/kernel/src/kernel.erl11
-rw-r--r--lib/kernel/src/kernel_config.erl6
-rw-r--r--lib/kernel/src/net_adm.erl6
-rw-r--r--lib/kernel/src/net_kernel.erl19
-rw-r--r--lib/kernel/src/os.erl51
-rw-r--r--lib/kernel/src/pg2.erl20
-rw-r--r--lib/kernel/src/rpc.erl32
-rw-r--r--lib/kernel/src/seq_trace.erl4
-rw-r--r--lib/kernel/src/standard_error.erl6
-rw-r--r--lib/kernel/src/user.erl8
-rw-r--r--lib/kernel/src/user_drv.erl43
-rw-r--r--lib/kernel/src/wrap_log_reader.erl10
-rw-r--r--lib/kernel/test/Makefile2
-rw-r--r--lib/kernel/test/application_SUITE.erl188
-rw-r--r--lib/kernel/test/application_SUITE_data/deadlock/deadlock.app2
-rw-r--r--lib/kernel/test/application_SUITE_data/deadlock/deadlock.erl12
-rw-r--r--lib/kernel/test/code_SUITE.erl927
-rw-r--r--lib/kernel/test/erl_prim_loader_SUITE.erl27
-rw-r--r--lib/kernel/test/file_SUITE.erl14
-rw-r--r--lib/kernel/test/file_name_SUITE.erl1
-rw-r--r--lib/kernel/test/gen_sctp_SUITE.erl454
-rw-r--r--lib/kernel/test/gen_tcp_misc_SUITE.erl114
-rw-r--r--lib/kernel/test/gen_udp_SUITE.erl109
-rw-r--r--lib/kernel/test/global_SUITE_data/global_trace.erl1
-rw-r--r--lib/kernel/test/inet_SUITE.erl103
-rw-r--r--lib/kernel/test/interactive_shell_SUITE.erl51
-rw-r--r--lib/kernel/test/kernel_SUITE.erl116
-rw-r--r--lib/kernel/test/kernel_smoke.spec9
-rw-r--r--lib/kernel/test/os_SUITE.erl26
-rw-r--r--lib/kernel/test/os_SUITE_data/my_echo.c28
-rw-r--r--lib/kernel/test/ram_file_SUITE.erl3
-rw-r--r--lib/kernel/test/sendfile_SUITE.erl90
-rw-r--r--lib/kernel/test/zlib_SUITE.erl11
-rw-r--r--lib/kernel/vsn.mk2
110 files changed, 3180 insertions, 1276 deletions
diff --git a/lib/kernel/doc/src/app.xml b/lib/kernel/doc/src/app.xml
index 1914844b37..7c9d6eecec 100644
--- a/lib/kernel/doc/src/app.xml
+++ b/lib/kernel/doc/src/app.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE fileref SYSTEM "fileref.dtd">
<fileref>
<header>
<copyright>
- <year>1997</year><year>2012</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/application.xml b/lib/kernel/doc/src/application.xml
index 362c373c6c..016151891c 100644
--- a/lib/kernel/doc/src/application.xml
+++ b/lib/kernel/doc/src/application.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
@@ -239,10 +239,19 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}]</code>
<desc>
<p>Sets the value of the configuration parameter <c><anno>Par</anno></c> for
<c><anno>Application</anno></c>.</p>
- <p><c>set_env/3</c> uses the standard <c>gen_server</c> timeout
- value (5000 ms). A <c><anno>Timeout</anno></c> argument can be provided
+ <p><c>set_env/4</c> uses the standard <c>gen_server</c> timeout
+ value (5000 ms). The <c>timeout</c> option can be provided
if another timeout value is useful, for example, in situations
where the application controller is heavily loaded.</p>
+ <p>If <c>set_env/4</c> is called before the application is loaded,
+ the application environment values specified in the <c>Application.app</c>
+ file will override the ones previously set. This is also true for application
+ reloads.</p>
+ <p>The <c>persistent</c> option can be set to <c>true</c>
+ when there is a need to guarantee parameters set with <c>set_env/4</c>
+ will not be overridden by the ones defined in the application resource
+ file on load. This means persistent values will stick after the application
+ is loaded and also on application reload.</p>
<warning>
<p>Use this function only if you know what you are doing,
that is, on your own applications. It is very application
@@ -253,15 +262,30 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}]</code>
</warning>
</desc>
</func>
- <func>
+ <func>
<name name="ensure_started" arity="1"/>
<name name="ensure_started" arity="2"/>
<fsummary>Load and start an application</fsummary>
- <desc>
- <p>Equivalent to <seealso marker="#start/2"><c>application:start/1,2</c></seealso> except
- it returns <c>ok</c> for already started applications.</p>
- </desc>
- </func>
+ <desc>
+ <p>Equivalent to <seealso marker="#start/2"><c>application:start/1,2</c></seealso> except
+ it returns <c>ok</c> for already started applications.</p>
+ </desc>
+ </func>
+ <func>
+ <name name="ensure_all_started" arity="1"/>
+ <name name="ensure_all_started" arity="2"/>
+ <fsummary>Load and start an application and its dependencies, recursively</fsummary>
+ <desc>
+ <p>Equivalent to calling <seealso marker="#start/2"><c>application:start/1,2</c></seealso>
+ repeatedly on all dependencies that have not yet been started for an application.
+ The function returns <c>{ok, AppNames}</c> for a successful start or for an already started
+ application (which are however omitted from the <c>AppNames</c> list), and reports
+ <c>{error, {AppName,Reason}}</c> for errors, where <c>Reason</c> is any possible reason
+ returned by <seealso marker="#start/2"><c>application:start/1,2</c></seealso> when starting a
+ specific dependency. In case of an error, the applications that were started by the
+ function are stopped to bring the set of running applications back to its initial state.</p>
+ </desc>
+ </func>
<func>
<name name="start" arity="1"/>
<name name="start" arity="2"/>
@@ -391,9 +415,11 @@ Nodes = [cp1@cave, {cp2@cave, cp3@cave}]</code>
<p>Removes the configuration parameter <c><anno>Par</anno></c> and its value
for <c><anno>Application</anno></c>.</p>
<p><c>unset_env/2</c> uses the standard <c>gen_server</c>
- timeout value (5000 ms). A <c><anno>Timeout</anno></c> argument can be
+ timeout value (5000 ms). The <c>timeout</c> option can be
provided if another timeout value is useful, for example, in
situations where the application controller is heavily loaded.</p>
+ <p><c>unset_env/3</c> also allows the persistent option to be passed
+ (see <c>set_env/4</c> above).</p>
<warning>
<p>Use this function only if you know what you are doing,
that is, on your own applications. It is very application
diff --git a/lib/kernel/doc/src/auth.xml b/lib/kernel/doc/src/auth.xml
index 15d9ef0fe4..72beee46f5 100644
--- a/lib/kernel/doc/src/auth.xml
+++ b/lib/kernel/doc/src/auth.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2011</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/book.xml b/lib/kernel/doc/src/book.xml
index caf13fd001..09123976cb 100644
--- a/lib/kernel/doc/src/book.xml
+++ b/lib/kernel/doc/src/book.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE book SYSTEM "book.dtd">
<book xmlns:xi="http://www.w3.org/2001/XInclude">
<header titlestyle="normal">
<copyright>
- <year>1997</year><year>2009</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/code.xml b/lib/kernel/doc/src/code.xml
index 6f04741f85..454ee9bcbb 100644
--- a/lib/kernel/doc/src/code.xml
+++ b/lib/kernel/doc/src/code.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
diff --git a/lib/kernel/doc/src/config.xml b/lib/kernel/doc/src/config.xml
index 34398e90ac..005504dbd1 100644
--- a/lib/kernel/doc/src/config.xml
+++ b/lib/kernel/doc/src/config.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE fileref SYSTEM "fileref.dtd">
<fileref>
<header>
<copyright>
- <year>1997</year><year>2009</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/disk_log.xml b/lib/kernel/doc/src/disk_log.xml
index d278d54d93..27d8ab4fc1 100644
--- a/lib/kernel/doc/src/disk_log.xml
+++ b/lib/kernel/doc/src/disk_log.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1997</year>
- <year>2011</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/erl_boot_server.xml b/lib/kernel/doc/src/erl_boot_server.xml
index 472671a80e..abaea4f695 100644
--- a/lib/kernel/doc/src/erl_boot_server.xml
+++ b/lib/kernel/doc/src/erl_boot_server.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2011</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/erl_ddll.xml b/lib/kernel/doc/src/erl_ddll.xml
index 26db11cfcd..7be54c8b95 100644
--- a/lib/kernel/doc/src/erl_ddll.xml
+++ b/lib/kernel/doc/src/erl_ddll.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1997</year><year>2012</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/erl_prim_loader_stub.xml b/lib/kernel/doc/src/erl_prim_loader_stub.xml
index e6324b8168..485b16b91f 100644
--- a/lib/kernel/doc/src/erl_prim_loader_stub.xml
+++ b/lib/kernel/doc/src/erl_prim_loader_stub.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1997</year>
- <year>2009</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/erlang_stub.xml b/lib/kernel/doc/src/erlang_stub.xml
index 333c4fedaf..79a041110a 100644
--- a/lib/kernel/doc/src/erlang_stub.xml
+++ b/lib/kernel/doc/src/erlang_stub.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1997</year>
- <year>2009</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/error_handler.xml b/lib/kernel/doc/src/error_handler.xml
index 84ec3927c8..2f8f09b984 100644
--- a/lib/kernel/doc/src/error_handler.xml
+++ b/lib/kernel/doc/src/error_handler.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
diff --git a/lib/kernel/doc/src/error_logger.xml b/lib/kernel/doc/src/error_logger.xml
index cd86b364f6..3815b0877c 100644
--- a/lib/kernel/doc/src/error_logger.xml
+++ b/lib/kernel/doc/src/error_logger.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2012</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/fascicules.xml b/lib/kernel/doc/src/fascicules.xml
index 43090b4aed..fadd37eefb 100644
--- a/lib/kernel/doc/src/fascicules.xml
+++ b/lib/kernel/doc/src/fascicules.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE fascicules SYSTEM "fascicules.dtd">
<fascicules>
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index 66ecba1bf2..b3ec9fd33d 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2013</year>
+ <year>1996</year><year>2014</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -37,54 +37,48 @@
the file operations. See the command line flag
<c>+A</c> in <seealso marker="erts:erl">erl(1)</seealso>.</p>
- <p>The Erlang VM supports file names in Unicode to a limited
- extent. Depending on how the VM is started (with the parameter
- <c>+fnu</c> or <c>+fnl</c>), file names given can contain
- characters > 255 and the VM system will convert file names
- back and forth to the native file name encoding.</p>
+ <p>With regard to file name encoding, the Erlang VM can operate in
+ two modes. The current mode can be queried using the <seealso
+ marker="#native_name_encoding">native_name_encoding/0</seealso>
+ function. It returns either <c>latin1</c> or <c>utf8</c>.</p>
- <p>The default behavior for Unicode character translation depends
- on to what extent the underlying OS/filesystem enforces consistent
- naming. On OSes where all file names are ensured to be in one or
- another encoding, Unicode is the default (currently this holds for
- Windows and MacOSX). On OSes with completely transparent file
- naming (i.e. all Unixes except MacOSX), ISO-latin-1 file naming is
- the default. The reason for the ISO-latin-1 default is that
- file names are not guaranteed to be possible to interpret according to
- the Unicode encoding expected (i.e. UTF-8), and file names that
- cannot be decoded will only be accessible by using &quot;raw
- file names&quot;, in other word file names given as binaries.</p>
-
- <p>As file names are traditionally not binaries in Erlang,
- applications that need to handle raw file names need to be
- converted, why the Unicode mode for file names is not default on
- systems having completely transparent file naming.</p>
+ <p>In the <c>latin1</c> mode, the Erlang VM does not change the
+ encoding of file names. In the <c>utf8</c> mode, file names can
+ contain Unicode characters greater than 255 and the VM will
+ convert file names back and forth to the native file name encoding
+ (usually UTF-8, but UTF-16 on Windows).</p>
- <p>Raw file names is a new feature in OTP R14B01, which allows the
- user to supply completely uninterpreted file names to the
- underlying OS/filesystem. They are supplied as binaries, where it
- is up to the user to supply a correct encoding for the
- environment. The function <c>file:native_name_encoding()</c> can
- be used to check what encoding the VM is working in. If the
- function returns <c>latin1</c> file names are not in any way
- converted to Unicode, if it is <c>utf8</c>, raw file names should
- be encoded as UTF-8 if they are to follow the convention of the VM
- (and usually the convention of the OS as well). Using raw
- file names is useful if you have a filesystem with inconsistent
- file naming, where some files are named in UTF-8 encoding while
- others are not. A file:list_dir on such mixed file name systems
- when the VM is in Unicode file name mode might return file names as
- raw binaries as they cannot be interpreted as Unicode
- file names. Raw file names can also be used to give UTF-8 encoded
- file names even though the VM is not started in Unicode file name
- translation mode.</p>
+ <p>The default mode depends on the operating system. Windows and
+ MacOS X enforce consistent file name encoding and therefore the
+ VM uses the <c>utf8</c> mode.</p>
+
+ <p>On operating systems with transparent naming (i.e. all Unix
+ systems except MacOS X), the default will be <c>utf8</c> if the
+ terminal supports UTF-8, otherwise <c>latin1</c>. The default may
+ be overridden using the <c>+fnl</c> (to force <c>latin1</c> mode)
+ or <c>+fnu</c> (to force <c>utf8</c> mode) when starting <seealso
+ marker="erts:erl">erl</seealso>.</p>
+
+ <p>On operating systems with transparent naming, files could be
+ inconsistently named, i.e. some files are encoded in UTF-8 while
+ others are encoded in (for example) iso-latin1. To be able to
+ handle file systems with inconsistent naming when running in the
+ <c>utf8</c> mode, the concept of "raw file names" has been
+ introduced.</p>
+
+ <p>A raw file name is a file name given as a binary. The Erlang VM
+ will perform no translation of a file name given as a binary on
+ systems with transparent naming.</p>
+
+ <p>When running in the <c>utf8</c> mode, the
+ <c>file:list_dir/1</c> and <c>file:read_link/1</c> functions will
+ never return raw file names. Use the <seealso
+ marker="#list_dir_all">list_dir_all/1</seealso> and <seealso
+ marker="#read_link_all">read_link_all/1</seealso> functions to
+ return all file names including raw file names.</p>
+
+ <p>Also see <seealso marker="stdlib:unicode_usage#notes-about-raw-filenames">Notes about raw file names</seealso>.</p>
- <p>Note that on Windows, <c>file:native_name_encoding()</c>
- returns <c>utf8</c> per default, which is the format for raw
- file names even on Windows, although the underlying OS specific
- code works in a limited version of little endian UTF16. As far as
- the Erlang programmer is concerned, Windows native Unicode format
- is UTF-8...</p>
</description>
<datatypes>
@@ -535,8 +529,8 @@
<name name="list_dir_all" arity="1"/>
<fsummary>List all files in a directory</fsummary>
<desc>
- <p>Lists all the files in a directory, including files with
- "raw" names.
+ <p><marker id="list_dir_all"/>Lists all the files in a directory,
+ including files with "raw" names.
Returns <c>{ok, <anno>Filenames</anno>}</c> if successful.
Otherwise, it returns <c>{error, <anno>Reason</anno>}</c>.
<c><anno>Filenames</anno></c> is a list of
@@ -653,11 +647,14 @@
</func>
<func>
<name name="native_name_encoding" arity="0"/>
- <fsummary>Return the VM's configured filename encoding.</fsummary>
+ <fsummary>Return the VM's configured filename encoding</fsummary>
<desc>
- <p>This function returns the configured default file name encoding to use for raw file names. Generally an application supplying file names raw (as binaries), should obey the character encoding returned by this function.</p>
- <p>By default, the VM uses ISO-latin-1 file name encoding on filesystems and/or OSes that use completely transparent file naming. This includes all Unix versions except MacOSX, where the vfs layer enforces UTF-8 file naming. By giving the experimental option <c>+fnu</c> when starting Erlang, UTF-8 translation of file names can be turned on even for those systems. If Unicode file name translation is in effect, the system behaves as usual as long as file names conform to the encoding, but will return file names that are not properly encoded in UTF-8 as raw file names (i.e. binaries).</p>
- <p>On Windows, this function also returns <c>utf8</c> by default. The OS uses a pure Unicode naming scheme and file names are always possible to interpret as valid Unicode. The fact that the underlying Windows OS actually encodes file names using little endian UTF-16 can be ignored by the Erlang programmer. Windows and MacOSX are the only operating systems where the VM operates in Unicode file name mode by default.</p>
+ <p><marker id="native_name_encoding"/>This function returns
+ the file name encoding mode. If it is <c>latin1</c>, the
+ system does no translation of file names. If it is
+ <c>utf8</c>, file names will be converted back and forth to
+ the native file name encoding (usually UTF-8, but UTF-16 on
+ Windows).</p>
</desc>
</func>
<func>
@@ -826,6 +823,16 @@
<item>
<p><c>File</c> must be <c>iodata()</c>. Returns an <c>fd()</c> which lets the <c>file</c> module operate on the data in-memory as if it is a file.</p>
</item>
+ <tag><c>sync</c></tag>
+ <item>
+ <p>On platforms that support it, enables the POSIX <c>O_SYNC</c> synchronous I/O flag or its platform-dependent
+ equivalent (e.g., <c>FILE_FLAG_WRITE_THROUGH</c> on Windows) so that writes to the file block until the data has
+ been physically written to disk. Be aware, though, that the exact semantics of this flag differ from platform to
+ platform; for example, neither Linux nor Windows guarantees that all file metadata are also written before the call
+ returns. For precise semantics, check the details of your platform's documentation. On platforms with no
+ support for POSIX <c>O_SYNC</c> or equivalent, use of the <c>sync</c> flag causes <c>open</c> to return
+ <c>{error, enotsup}</c>.</p>
+ </item>
</taglist>
<p>Returns:</p>
<taglist>
@@ -1440,7 +1447,8 @@
<name name="read_link" arity="1"/>
<fsummary>See what a link is pointing to</fsummary>
<desc>
- <p>This function returns <c>{ok, <anno>Filename</anno>}</c> if
+ <p><marker id="read_link_all"/>This function returns
+ <c>{ok, <anno>Filename</anno>}</c> if
<c><anno>Name</anno></c> refers to a symbolic link that is
not a "raw" file name, or <c>{error, <anno>Reason</anno>}</c>
otherwise.
@@ -1736,16 +1744,16 @@
<item>The chunk size used by the erlang fallback to send
data. If using the fallback, this should be set to a value
which comfortably fits in the systems memory. Default is 20 MB.</item>
+ <tag><c>use_threads</c></tag>
+ <item>Instruct the emulator to use the async thread pool for the
+ sendfile system call. This could be usefull if the OS you are running
+ on does not properly support non-blocking sendfile calls. Do note that
+ using async threads potentially makes your system volnerable to slow
+ client attacks. If set to true and no async threads are available,
+ the sendfile call will return <c>{error,einval}</c>.
+ Introduced in Erlang/OTP 17.0. Default is false.</item>
</taglist>
</p>
- <p>On operating systems with thread support, it is recommended to use
- async threads. See the command line flag
- <c>+A</c> in <seealso marker="erts:erl">erl(1)</seealso>. If it is not
- possible to use async threads for sendfile, it is recommended to use
- a relatively small value for the send buffer on the socket. Otherwise
- the Erlang VM might loose some of its soft realtime guarantees.
- Which size to use depends on the OS/hardware and the requirements
- of the application.</p>
</desc>
</func>
<func>
diff --git a/lib/kernel/doc/src/gen_sctp.xml b/lib/kernel/doc/src/gen_sctp.xml
index 7ea58fffff..dc9e4766a9 100644
--- a/lib/kernel/doc/src/gen_sctp.xml
+++ b/lib/kernel/doc/src/gen_sctp.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>2007</year><year>2012</year>
+ <year>2007</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -322,7 +322,7 @@
<p>
Branch off an existing association <anno>Assoc</anno>
in a socket <anno>Socket</anno> of type <c>seqpacket</c>
- (one-to-may style) into
+ (one-to-many style) into
a new socket <anno>NewSocket</anno> of type <c>stream</c>
(one-to-one style).
</p>
@@ -496,9 +496,11 @@
orthogonal to the sets of TCP, UDP and generic INET options:
only those options which are explicitly listed below are allowed
for SCTP sockets. Options can be set on the socket using
- <c>gen_sctp:open/1,2</c> or <c>inet:setopts/2</c>,
- retrieved using <c>inet:getopts/2</c>, and when calling
- <c>gen_sctp:connect/4,5</c> options can be changed.</p>
+ <seealso marker="#open/1"><c>gen_sctp:open/1,2</c></seealso>
+ or <seealso marker="inet#setopts/2"><c>inet:setopts/2</c></seealso>,
+ retrieved using <seealso marker="inet#getopts/2"><c>inet:getopts/2</c></seealso>,
+ and when calling <seealso marker="#connect/4"><c>gen_sctp:connect/4,5</c></seealso>
+ options can be changed.</p>
<marker id="option-binary"></marker>
<marker id="option-list"></marker>
<taglist>
@@ -507,7 +509,7 @@
<p>Determines the type of data returned from <c>gen_sctp:recv/1,2</c>.</p>
<marker id="option-active"></marker>
</item>
- <tag><c>{active, true|false|once}</c></tag>
+ <tag><c>{active, true|false|once|N}</c></tag>
<item>
<list type="bulleted">
<item>
@@ -524,11 +526,28 @@
</item>
<item>
<p>If <c>once</c>, only one message is automatically placed
- in the message queue, after that the mode is automatically
- re-set to passive. This provides flow control as well as
+ in the message queue, and after that the mode is automatically
+ reset to passive. This provides flow control as well as
the possibility for the receiver to listen for its incoming
SCTP data interleaved with other inter-process messages.</p>
</item>
+ <item>
+ <p>If <c>active</c> is specified as an integer <c>N</c> in the
+ range -32768 to 32767 (inclusive), then that number is added to
+ the socket's count of the number of data messages to be
+ delivered to the controlling process. If the result of the
+ addition would be negative, the count is set to 0. Once the
+ count reaches 0, either through the delivery of messages or by
+ being explicitly set with <seealso
+ marker="inet#setopts/2">inet:setopts/2</seealso>, the socket's
+ mode is automatically reset to passive (<c>{active,
+ false}</c>) mode. When a socket in this active mode transitions to
+ passive mode, the message <c>{sctp_passive, Socket}</c> is sent
+ to the controlling process to notify it that if it wants to
+ receive more data messages from the socket, it must call
+ <seealso marker="inet#setopts/2">inet:setopts/2</seealso> to set
+ the socket back into an active mode.</p>
+ </item>
</list>
</item>
<tag><c>{tos, integer()}</c></tag>
diff --git a/lib/kernel/doc/src/gen_tcp.xml b/lib/kernel/doc/src/gen_tcp.xml
index 11a0843c10..dbd0d3c815 100644
--- a/lib/kernel/doc/src/gen_tcp.xml
+++ b/lib/kernel/doc/src/gen_tcp.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1997</year><year>2012</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -148,6 +148,12 @@ do_recv(Sock, Bs) ->
as messages:</p>
<code type="none">
{tcp, Socket, Data}</code>
+ <p>If the socket is in <c>{active, N}</c> mode (see <seealso marker="inet#setopts/2">
+ inet:setopts/2</seealso> for details) and its message counter
+ drops to 0, the following message is delivered to indicate that the
+ socket has transitioned to passive (<c>{active, false}</c>) mode:</p>
+ <code type="none">
+{tcp_passive, Socket}</code>
<p>If the socket is closed, the following message is delivered:</p>
<code type="none">
{tcp_closed, Socket}</code>
diff --git a/lib/kernel/doc/src/gen_udp.xml b/lib/kernel/doc/src/gen_udp.xml
index 4850278a64..503725fe18 100644
--- a/lib/kernel/doc/src/gen_udp.xml
+++ b/lib/kernel/doc/src/gen_udp.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1997</year><year>2012</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -145,14 +145,23 @@
<seealso marker="inet#setopts/2">inet:setopts/2</seealso>.</p>
</item>
</taglist>
- <p>The returned socket <c><anno>Socket</anno></c> is used to send packets
- from this port with <c>send/4</c>. When UDP packets arrive at
- the opened port, they are delivered as messages:</p>
+ <p>The returned socket <c><anno>Socket</anno></c> is used to send
+ packets from this port with <c>send/4</c>. When UDP packets arrive
+ at the opened port, if the socket is in an active mode the packets
+ are delivered as messages to the controlling process:</p>
<code type="none">
{udp, Socket, IP, InPortNo, Packet}</code>
- <p>Note that arriving UDP packets that are longer than
+ <p>If the socket is not in an active mode, data can be
+ retrieved via the <seealso marker="#recv/2">recv/2,3</seealso> calls.
+ Note that arriving UDP packets that are longer than
the receive buffer option specifies, might be truncated
without warning.</p>
+ <p>When a socket in <c>{active, N}</c> mode (see <seealso marker="inet#setopts/2">
+ inet:setopts/2</seealso> for details) transitions to passive
+ (<c>{active, false}</c>) mode, the controlling process is notified by a
+ message of the following form:</p>
+ <code type="none">
+{udp_passive, Socket}</code>
<p><c>IP</c> and <c>InPortNo</c> define the address from which
<c>Packet</c> came. <c>Packet</c> is a list of bytes if
the option <c>list</c> was specified. <c>Packet</c> is a
diff --git a/lib/kernel/doc/src/global.xml b/lib/kernel/doc/src/global.xml
index 53958c47c2..691b243443 100644
--- a/lib/kernel/doc/src/global.xml
+++ b/lib/kernel/doc/src/global.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
diff --git a/lib/kernel/doc/src/global_group.xml b/lib/kernel/doc/src/global_group.xml
index abf6178fc4..2c181da83a 100644
--- a/lib/kernel/doc/src/global_group.xml
+++ b/lib/kernel/doc/src/global_group.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1998</year><year>2011</year>
+ <year>1998</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/heart.xml b/lib/kernel/doc/src/heart.xml
index 2856d84dcf..3ec33d2f18 100644
--- a/lib/kernel/doc/src/heart.xml
+++ b/lib/kernel/doc/src/heart.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2012</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -118,8 +118,13 @@
the system. The new Erlang runtime system will (if it
misbehaves) use the environment variable
<c>HEART_COMMAND</c> to reboot.</p>
- <p>Limitations: The length of the <c><anno>Cmd</anno></c> command string
- must be less than 2047 characters.</p>
+
+ <p>Limitations: The <c><anno>Cmd</anno></c> command string
+ will be sent to the heart program as a ISO-latin-1 or UTF-8
+ encoded binary depending on the file name encoding mode of the
+ emulator (see
+ <seealso marker="kernel:file#native_name_encoding/0"><c>file:native_name_encoding/0</c></seealso>).
+ The size of the encoded binary must be less than 2047 bytes.</p>
</desc>
</func>
<func>
diff --git a/lib/kernel/doc/src/inet.xml b/lib/kernel/doc/src/inet.xml
index 7cd98914d1..4a48a5c3d8 100644
--- a/lib/kernel/doc/src/inet.xml
+++ b/lib/kernel/doc/src/inet.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
@@ -76,11 +76,11 @@ FFFF::192.168.42.2
{16#3ffe,16#b80,16#1f8d,16#2,16#204,16#acff,16#fe17,16#bf38}
fe80::204:acff:fe17:bf38
{16#fe80,0,0,0,0,16#204,16#acff,16#fe17,16#bf38}</code>
- <p>A function that may be useful is <c>inet_parse:address/1</c>:</p>
+ <p>A function that may be useful is <seealso marker="#parse_address/1">parse_address/1</seealso>:</p>
<pre>
-1> <input>inet_parse:address("192.168.42.2").</input>
+1> <input>inet:parse_address("192.168.42.2").</input>
{ok,{192,168,42,2}}
-2> <input>inet_parse:address("FFFF::192.168.42.2").</input>
+2> <input>inet:parse_address("FFFF::192.168.42.2").</input>
{ok,{65535,0,0,0,0,0,49320,10754}}</pre>
</description>
@@ -375,6 +375,13 @@ fe80::204:acff:fe17:bf38
</desc>
</func>
<func>
+ <name name="ntoa" arity="1" />
+ <fsummary>Convert IPv6 / IPV4 adress to ascii</fsummary>
+ <desc>
+ <p>Parses an <a href="#type-ip_address">ip_address()</a> and returns an IPv4 or IPv6 address string.</p>
+ </desc>
+ </func>
+ <func>
<name name="parse_ipv4_address" arity="1" />
<fsummary>Parse an IPv4 address</fsummary>
<desc>
@@ -423,8 +430,56 @@ fe80::204:acff:fe17:bf38
<name name="peername" arity="1"/>
<fsummary>Return the address and port for the other end of a connection</fsummary>
<desc>
- <p>Returns the address and port for the other end of a
- connection.</p>
+ <p>
+ Returns the address and port for the other end of a
+ connection.
+ </p>
+ <p>
+ Note that for SCTP sockets this function only returns
+ one of the socket's peer addresses. The function
+ <seealso marker="#peernames/1">peernames/1,2</seealso>
+ returns all.
+ </p>
+ </desc>
+ </func>
+ <func>
+ <name name="peernames" arity="1"/>
+ <fsummary>
+ Return all address/port numbers for the other end of a connection
+ </fsummary>
+ <desc>
+ <p>
+ Equivalent to
+ <seealso marker="#peernames/2"><c>peernames(<anno>Socket</anno>, 0)</c></seealso>.
+ Note that this function's behaviour for an SCTP
+ one-to-many style socket is not defined by the
+ <url href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">SCTP Sockets API Extensions</url>.
+ </p>
+ </desc>
+ </func>
+ <func>
+ <name name="peernames" arity="2"/>
+ <fsummary>
+ Return all address/port numbers for the other end of a connection
+ </fsummary>
+ <desc>
+ <p>
+ Returns a list of all address/port number pairs for the other end
+ of a socket's association <c><anno>Assoc</anno></c>.
+ </p>
+ <p>
+ This function can return multiple addresses for multihomed
+ sockets such as SCTP sockets. For other sockets it
+ returns a one element list.
+ </p>
+ <p>
+ Note that the <c><anno>Assoc</anno></c> parameter is by the
+ <url href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">SCTP Sockets API Extensions</url>
+ defined to be ignored for
+ one-to-one style sockets. What the special value <c>0</c>
+ means hence its behaviour for one-to-many style sockets
+ is unfortunately not defined.
+ </p>
</desc>
</func>
<func>
@@ -439,6 +494,46 @@ fe80::204:acff:fe17:bf38
<fsummary>Return the local address and port number for a socket</fsummary>
<desc>
<p>Returns the local address and port number for a socket.</p>
+ <p>
+ Note that for SCTP sockets this function only returns
+ one of the socket addresses. The function
+ <seealso marker="#socknames/1">socknames/1,2</seealso>
+ returns all.
+ </p>
+ </desc>
+ </func>
+ <func>
+ <name name="socknames" arity="1"/>
+ <fsummary>Return all local address/port numbers for a socket</fsummary>
+ <desc>
+ <p>
+ Equivalent to
+ <seealso marker="#socknames/2"><c>socknames(<anno>Socket</anno>, 0)</c></seealso>.
+ </p>
+ </desc>
+ </func>
+ <func>
+ <name name="socknames" arity="2"/>
+ <fsummary>Return all local address/port numbers for a socket</fsummary>
+ <desc>
+ <p>
+ Returns a list of all local address/port number pairs for a socket
+ for the given association <c><anno>Assoc</anno></c>.
+ </p>
+ <p>
+ This function can return multiple addresses for multihomed
+ sockets such as SCTP sockets. For other sockets it
+ returns a one element list.
+ </p>
+ <p>
+ Note that the <c><anno>Assoc</anno></c> parameter is by the
+ <url href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">SCTP Sockets API Extensions</url>
+ defined to be ignored for one-to-one style sockets.
+ For one-to-many style sockets the special value <c>0</c>
+ is defined to mean that the returned addresses shall be
+ without regard to any particular association.
+ How different SCTP implementations interprets this varies somewhat.
+ </p>
</desc>
</func>
<func>
@@ -449,47 +544,66 @@ fe80::204:acff:fe17:bf38
<p>Sets one or more options for a socket. The following options
are available:</p>
<taglist>
- <tag><c>{active, true | false | once}</c></tag>
+ <tag><c>{active, true | false | once | N}</c></tag>
<item>
<p>If the value is <c>true</c>, which is the default,
everything received from the socket will be sent as
messages to the receiving process. If the value is
<c>false</c> (passive mode), the process must explicitly
- receive incoming data by calling <c>gen_tcp:recv/2,3</c>
- or <c>gen_udp:recv/2,3</c> (depending on the type of
- socket).</p>
+ receive incoming data by calling
+ <seealso marker="gen_tcp#recv/2"><c>gen_tcp:recv/2,3</c></seealso>,
+ <seealso marker="gen_udp#recv/2"><c>gen_udp:recv/2,3</c></seealso>
+ or <seealso marker="gen_sctp#recv/1"><c>gen_sctp:recv/1,2</c></seealso>
+ (depending on the type of socket).</p>
<p>If the value is <c>once</c> (<c>{active, once}</c>),
<em>one</em> data message from the socket will be sent
to the process. To receive one more message,
<c>setopts/2</c> must be called again with the
<c>{active, once}</c> option.</p>
- <p>When using <c>{active, once}</c>, the socket changes
- behaviour automatically when data is received. This can
- sometimes be confusing in combination with connection
- oriented sockets (i.e. <c>gen_tcp</c>) as a socket with
- <c>{active, false}</c> behaviour reports closing
+ <p>If the value is an integer <c>N</c> in the range -32768 to 32767
+ (inclusive), the value is added to the socket's count of data
+ messages sent to the controlling process. A socket's default
+ message count is 0. If a negative value is specified and its
+ magnitude is equal to or greater than the socket's current
+ message count, the socket's message count is set to 0. Once
+ the socket's message count reaches 0, either due to sending
+ received data messages to the process or by being explicitly set,
+ the process is then notified by a special message, specific to
+ the type of socket, that the socket has entered passive
+ mode. Once the socket enters passive mode, to receive more
+ messages <c>setopts/2</c> must be called again to set the
+ socket back into an active mode.</p>
+ <p>When using <c>{active, once}</c> or <c>{active, N}</c>, the
+ socket changes behaviour automatically when data is received.
+ This can sometimes be confusing in combination with
+ connection-oriented sockets (i.e. <c>gen_tcp</c>) as a socket
+ with <c>{active, false}</c> behaviour reports closing
differently than a socket with <c>{active, true}</c>
behaviour. To make programming easier, a socket where
the peer closed and this was detected while in
<c>{active, false}</c> mode, will still generate the
message
- <c>{tcp_closed,Socket}</c> when set to <c>{active, once}</c> or <c>{active, true}</c> mode. It is therefore
+ <c>{tcp_closed,Socket}</c> when set to <c>{active, once}</c>,
+ <c>{active, true}</c> or <c>{active, N}</c> mode. It is therefore
safe to assume that the message
<c>{tcp_closed,Socket}</c>, possibly followed by socket
port termination (depending on the <c>exit_on_close</c>
option) will eventually appear when a socket changes
back and forth between <c>{active, true}</c> and
- <c>{active, false}</c> mode. However,
+ <c>{active, false}</c> mode. However,
<em>when</em> peer closing is detected is all up to the
underlying TCP/IP stack and protocol.</p>
- <p>Note that <c>{active,true}</c> mode provides no flow
+ <p>Note that <c>{active, true}</c> mode provides no flow
control; a fast sender could easily overflow the
- receiver with incoming messages. Use active mode only if
+ receiver with incoming messages. The same is true of
+ <c>{active, N}</c> mode while the message count is greater
+ than zero. Use active mode only if
your high-level protocol provides its own flow control
(for instance, acknowledging received messages) or the
- amount of data exchanged is small. <c>{active,false}</c>
- mode or use of the <c>{active, once}</c> mode provides
- flow control; the other side will not be able send
+ amount of data exchanged is small. <c>{active, false}</c>
+ mode, use of the <c>{active, once}</c> mode or <c>{active, N}</c>
+ mode with values of <c>N</c> appropriate for the application
+ provides flow control; the other side will not be able send
faster than the receiver can read.</p>
</item>
@@ -715,6 +829,59 @@ fe80::204:acff:fe17:bf38
<p>Received <c>Packet</c> is delivered as defined by Mode.</p>
</item>
+ <tag><c>{netns, Namespace :: file:filename_all()}</c></tag>
+ <item>
+ <p>Set a network namespace for the socket. The <c>Namespace</c>
+ parameter is a filename defining the namespace for example
+ <c>"/var/run/netns/example"</c> typically created by the command
+ <c>ip netns add example</c>. This option must be used in a
+ function call that creates a socket i.e
+ <seealso marker="gen_tcp#connect/3">
+ gen_tcp:connect/3,4</seealso>,
+ <seealso marker="gen_tcp#listen/2">
+ gen_tcp:listen/2</seealso>,
+ <seealso marker="gen_udp#open/1">
+ gen_udp:open/1,2</seealso> or
+ <seealso marker="gen_sctp#open/0">
+ gen_sctp:open/0-2</seealso>.
+ </p>
+ <p>This option uses the Linux specific syscall
+ <c>setns()</c> such as in Linux kernel 3.0 or later
+ and therefore only exists when the runtime system
+ has been compiled for such an operating system.
+ </p>
+ <p>
+ The virtual machine also needs elevated privileges either
+ running as superuser or (for Linux) having the capability
+ <c>CAP_SYS_ADMIN</c> according to the documentation for setns(2).
+ However, during testing also <c>CAP_SYS_PTRACE</c>
+ and <c>CAP_DAC_READ_SEARCH</c> has proven to be necessary.
+ Example:<code>
+setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
+</code>
+ Note also that the filesystem containing the virtual machine
+ executable (<c>beam.smp</c> in the example above) has to be local,
+ mounted without the <c>nosetuid</c> flag,
+ support extended attributes and that
+ the kernel has to support file capabilities.
+ All this runs out of the box on at least Ubuntu 12.04 LTS,
+ except that SCTP sockets appears to not support
+ network namespaces.
+ </p>
+ <p>The <c>Namespace</c> is a file name and is encoded
+ and decoded as discussed in
+ <seealso marker="file">file</seealso>
+ except that the emulator flag <c>+fnu</c> is ignored and
+ <seealso marker="#getopts/2">getopts/2</seealso>
+ for this option will return a binary for the filename
+ if the stored filename can not be decoded,
+ which should only happen if you set the option using a binary
+ that can not be decoded with the emulator's filename encoding:
+ <seealso marker="file#native_name_encoding/0">
+ file:native_name_encoding/0</seealso>.
+ </p>
+ </item>
+
<tag><c>list</c></tag>
<item>
<p>Received <c>Packet</c> is delivered as a list.</p>
diff --git a/lib/kernel/doc/src/inet_res.xml b/lib/kernel/doc/src/inet_res.xml
index bf73ccf13d..7880ccda05 100644
--- a/lib/kernel/doc/src/inet_res.xml
+++ b/lib/kernel/doc/src/inet_res.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>2009</year><year>2011</year>
+ <year>2009</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/init_stub.xml b/lib/kernel/doc/src/init_stub.xml
index e8645458e4..5c57f8850e 100644
--- a/lib/kernel/doc/src/init_stub.xml
+++ b/lib/kernel/doc/src/init_stub.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1997</year>
- <year>2009</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml
index faa8f86dbd..49a93d2c70 100644
--- a/lib/kernel/doc/src/kernel_app.xml
+++ b/lib/kernel/doc/src/kernel_app.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE appref SYSTEM "appref.dtd">
<appref>
<header>
<copyright>
- <year>1996</year><year>2012</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/net_adm.xml b/lib/kernel/doc/src/net_adm.xml
index f2aac9282c..3009b1913d 100644
--- a/lib/kernel/doc/src/net_adm.xml
+++ b/lib/kernel/doc/src/net_adm.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2011</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/net_kernel.xml b/lib/kernel/doc/src/net_kernel.xml
index e54a427ff0..f5103136a1 100644
--- a/lib/kernel/doc/src/net_kernel.xml
+++ b/lib/kernel/doc/src/net_kernel.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2011</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/notes.xml b/lib/kernel/doc/src/notes.xml
index 0175c38397..b2e89ea850 100644
--- a/lib/kernel/doc/src/notes.xml
+++ b/lib/kernel/doc/src/notes.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<chapter>
@@ -30,6 +30,129 @@
</header>
<p>This document describes the changes made to the Kernel application.</p>
+<section><title>Kernel 2.16.4</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ Fix the typespec for the inet:ifget/2 and inet:ifget/3
+ return value. Thanks to Ali Sabil.</p>
+ <p>
+ Own Id: OTP-11377</p>
+ </item>
+ <item>
+ <p>
+ Fix various typos in erts, kernel and ssh. Thanks to
+ Martin Hässler.</p>
+ <p>
+ Own Id: OTP-11414</p>
+ </item>
+ <item>
+ <p>
+ Fix rpc multicall sample code. Thanks to Edwin Fine.</p>
+ <p>
+ Own Id: OTP-11471</p>
+ </item>
+ <item>
+ <p>
+ Under rare circumstances a process calling <seealso
+ marker="kernel:inet#close/1"><c>inet:close/1</c></seealso>,
+ <seealso
+ marker="kernel:gen_tcp#close/1"><c>gen_tcp:close/1</c></seealso>,
+ <seealso
+ marker="kernel:gen_udp#close/1"><c>gen_udp:close/1</c></seealso>,
+ or <seealso
+ marker="kernel:gen_sctp#close/1"><c>gen_sctp:close/1</c></seealso>
+ could hang in the call indefinitely.</p>
+ <p>
+ Own Id: OTP-11491</p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ Add more SCTP errors as described in RFC 4960. Thanks to
+ Artem Teslenko.</p>
+ <p>
+ Own Id: OTP-11379</p>
+ </item>
+ <item>
+ <p>
+ Add new BIF os:unsetenv/1 which deletes an environment
+ variable. Thanks to Martin Hässler.</p>
+ <p>
+ Own Id: OTP-11446</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
+<section><title>Kernel 2.16.3</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ Fix indentation of User switch command help in Erlang
+ shell. Thanks to Sylvain Benner.</p>
+ <p>
+ Own Id: OTP-11209</p>
+ </item>
+ </list>
+ </section>
+
+
+ <section><title>Improvements and New Features</title>
+ <list>
+ <item>
+ <p>
+ The previous undocumented function ntoa/1 has been added
+ to inet docs and exported in the inet module.</p>
+ <p>
+ Own Id: OTP-10676 Aux Id: OTP-10314 </p>
+ </item>
+ <item>
+ <p>
+ Fix typo in abcast() function comment. Thanks to Johannes
+ Weissl.</p>
+ <p>
+ Own Id: OTP-11219</p>
+ </item>
+ <item>
+ <p>
+ Add application:ensure_all_started/1-2. Thanks to Fred
+ Hebert.</p>
+ <p>
+ Own Id: OTP-11250</p>
+ </item>
+ <item>
+ <p>
+ Make edlin understand a few important control keys.
+ Thanks to Stefan Zegenhagen.</p>
+ <p>
+ Own Id: OTP-11251</p>
+ </item>
+ <item>
+ <p>
+ Cleanup of hipe_unified_loader, eliminating uses of
+ is_subtype/2 in specs, change module-local void functions
+ to return 'ok' instead of [] and made sure there are no
+ dialyzer warnings with --Wunmatched_returns. Thanks to
+ Kostis Sagonas.</p>
+ <p>
+ Own Id: OTP-11301</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Kernel 2.16.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
@@ -390,7 +513,7 @@
<p>
Fixed issue where using controlling_process/2 with self()
as the second argument caused the port to leak if self()
- crashes. (Thanks to Ricardo Catalinas Jim�nez)</p>
+ crashes. (Thanks to Ricardo Catalinas Jiménez)</p>
<p>
Own Id: OTP-10094</p>
</item>
@@ -532,7 +655,7 @@
Various typographical errors corrected in documentation
for the global, error_logger, etop, lists, ets and
supervisor modules and in the c_portdriver and kernel_app
- documentation. (Thanks to Ricardo Catalinas Jim�nez)</p>
+ documentation. (Thanks to Ricardo Catalinas Jiménez)</p>
<p>
Own Id: OTP-9987</p>
</item>
@@ -727,7 +850,7 @@
Fixes net_kernel:get_net_ticktime() doc</p>
<p>
Adds missing description when `ignored' is returned.
- (Thanks to Ricardo Catalinas Jim�nez )</p>
+ (Thanks to Ricardo Catalinas Jiménez )</p>
<p>
Own Id: OTP-9713</p>
</item>
@@ -913,7 +1036,7 @@
<item>
<p>
Fix typo in doc of rpc:pmap/3 (Thanks to Ricardo
- Catalinas Jim�nez)</p>
+ Catalinas Jiménez)</p>
<p>
Own Id: OTP-9168</p>
</item>
diff --git a/lib/kernel/doc/src/notes_history.xml b/lib/kernel/doc/src/notes_history.xml
index 2f6ceb9d42..58d5109774 100644
--- a/lib/kernel/doc/src/notes_history.xml
+++ b/lib/kernel/doc/src/notes_history.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<chapter>
<header>
<copyright>
- <year>2006</year><year>2009</year>
+ <year>2006</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml
index 5e182de41d..2b57e75023 100644
--- a/lib/kernel/doc/src/os.xml
+++ b/lib/kernel/doc/src/os.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1997</year><year>2012</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -177,6 +177,17 @@ format_utc_timestamp() ->
</desc>
</func>
<func>
+ <name name="unsetenv" arity="1"/>
+ <fsummary>Delete an environment variable</fsummary>
+ <desc>
+ <p>Deletes the environment variable <c><anno>VarName</anno></c>.</p>
+ <p>If Unicode filename encoding is in effect (see the <seealso
+ marker="erts:erl#file_name_encoding">erl manual
+ page</seealso>), the string (<c><anno>VarName</anno></c>) may
+ contain characters with codepoints > 255.</p>
+ </desc>
+ </func>
+ <func>
<name name="version" arity="0"/>
<fsummary>Return the Operating System version</fsummary>
<desc>
diff --git a/lib/kernel/doc/src/part_notes.xml b/lib/kernel/doc/src/part_notes.xml
index ff43b9e007..d196878f19 100644
--- a/lib/kernel/doc/src/part_notes.xml
+++ b/lib/kernel/doc/src/part_notes.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE part SYSTEM "part.dtd">
<part xmlns:xi="http://www.w3.org/2001/XInclude">
<header>
<copyright>
- <year>2004</year><year>2009</year>
+ <year>2004</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/part_notes_history.xml b/lib/kernel/doc/src/part_notes_history.xml
index a73cc911b8..ec4998408e 100644
--- a/lib/kernel/doc/src/part_notes_history.xml
+++ b/lib/kernel/doc/src/part_notes_history.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE part SYSTEM "part.dtd">
<part>
<header>
<copyright>
<year>2006</year>
- <year>2011</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/pg2.xml b/lib/kernel/doc/src/pg2.xml
index d26ff0fc6b..5eb63c1ef6 100644
--- a/lib/kernel/doc/src/pg2.xml
+++ b/lib/kernel/doc/src/pg2.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1997</year><year>2011</year>
+ <year>1997</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/ref_man.xml b/lib/kernel/doc/src/ref_man.xml
index 96604a2fa2..c1b9eac9d7 100644
--- a/lib/kernel/doc/src/ref_man.xml
+++ b/lib/kernel/doc/src/ref_man.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE application SYSTEM "application.dtd">
<application xmlns:xi="http://www.w3.org/2001/XInclude">
diff --git a/lib/kernel/doc/src/rpc.xml b/lib/kernel/doc/src/rpc.xml
index b01ff16c85..e6c896f18d 100644
--- a/lib/kernel/doc/src/rpc.xml
+++ b/lib/kernel/doc/src/rpc.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1996</year><year>2011</year>
+ <year>1996</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -185,7 +185,7 @@
{Mod, Bin, File} = code:get_object_code(Mod),
%% and load it on all nodes including this one
-{ResL, _} = rpc:multicall(code, load_binary, [Mod, Bin, File,]),
+{ResL, _} = rpc:multicall(code, load_binary, [Mod, File, Bin]),
%% and then maybe check the ResL list.</code>
</desc>
diff --git a/lib/kernel/doc/src/seq_trace.xml b/lib/kernel/doc/src/seq_trace.xml
index 1ab955bd8a..45df06e0b4 100644
--- a/lib/kernel/doc/src/seq_trace.xml
+++ b/lib/kernel/doc/src/seq_trace.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1998</year><year>2011</year>
+ <year>1998</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/specs.xml b/lib/kernel/doc/src/specs.xml
index 813bb06e1f..29d52f23bb 100644
--- a/lib/kernel/doc/src/specs.xml
+++ b/lib/kernel/doc/src/specs.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<specs xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="../specs/specs_application.xml"/>
<xi:include href="../specs/specs_auth.xml"/>
diff --git a/lib/kernel/doc/src/user.xml b/lib/kernel/doc/src/user.xml
index 4d0f044321..df6dff9882 100644
--- a/lib/kernel/doc/src/user.xml
+++ b/lib/kernel/doc/src/user.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1996</year>
- <year>2011</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/wrap_log_reader.xml b/lib/kernel/doc/src/wrap_log_reader.xml
index 6cf480b532..5227b4d01c 100644
--- a/lib/kernel/doc/src/wrap_log_reader.xml
+++ b/lib/kernel/doc/src/wrap_log_reader.xml
@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
- <year>1998</year><year>2011</year>
+ <year>1998</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/doc/src/zlib_stub.xml b/lib/kernel/doc/src/zlib_stub.xml
index fa14262181..5f5bfd56db 100644
--- a/lib/kernel/doc/src/zlib_stub.xml
+++ b/lib/kernel/doc/src/zlib_stub.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="latin1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1997</year>
- <year>2009</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl
index 5dd6b73857..76a80553b0 100644
--- a/lib/kernel/src/application.erl
+++ b/lib/kernel/src/application.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -18,7 +18,8 @@
%%
-module(application).
--export([start/1, start/2, start_boot/1, start_boot/2, stop/1,
+-export([ensure_all_started/1, ensure_all_started/2, start/1, start/2,
+ start_boot/1, start_boot/2, stop/1,
load/1, load/2, unload/1, takeover/2,
which_applications/0, which_applications/1,
loaded_applications/0, permit/2]).
@@ -113,6 +114,46 @@ load1(Application, DistNodes) ->
unload(Application) ->
application_controller:unload_application(Application).
+
+-spec ensure_all_started(Application) -> {'ok', Started} | {'error', Reason} when
+ Application :: atom(),
+ Started :: [atom()],
+ Reason :: term().
+ensure_all_started(Application) ->
+ ensure_all_started(Application, temporary).
+
+-spec ensure_all_started(Application, Type) -> {'ok', Started} | {'error', Reason} when
+ Application :: atom(),
+ Type :: restart_type(),
+ Started :: [atom()],
+ Reason :: term().
+ensure_all_started(Application, Type) ->
+ case ensure_all_started(Application, Type, []) of
+ {ok, Started} ->
+ {ok, lists:reverse(Started)};
+ {error, Reason, Started} ->
+ _ = [stop(App) || App <- Started],
+ {error, Reason}
+ end.
+
+ensure_all_started(Application, Type, Started) ->
+ case start(Application, Type) of
+ ok ->
+ {ok, [Application | Started]};
+ {error, {already_started, Application}} ->
+ {ok, Started};
+ {error, {not_started, Dependency}} ->
+ case ensure_all_started(Dependency, Type, Started) of
+ {ok, NewStarted} ->
+ ensure_all_started(Application, Type, NewStarted);
+ Error ->
+ Error
+ end;
+ {error, Reason} ->
+ {error, {Application, Reason}, Started}
+ end.
+
+
-spec start(Application) -> 'ok' | {'error', Reason} when
Application :: atom(),
Reason :: term().
@@ -244,16 +285,18 @@ info() ->
set_env(Application, Key, Val) ->
application_controller:set_env(Application, Key, Val).
--spec set_env(Application, Par, Val, Timeout) -> 'ok' when
+-spec set_env(Application, Par, Val, Opts) -> 'ok' when
Application :: atom(),
Par :: atom(),
Val :: term(),
- Timeout :: timeout().
+ Opts :: [{timeout, timeout()} | {persistent, boolean()}].
set_env(Application, Key, Val, infinity) ->
- application_controller:set_env(Application, Key, Val, infinity);
+ set_env(Application, Key, Val, [{timeout, infinity}]);
set_env(Application, Key, Val, Timeout) when is_integer(Timeout), Timeout>=0 ->
- application_controller:set_env(Application, Key, Val, Timeout).
+ set_env(Application, Key, Val, [{timeout, Timeout}]);
+set_env(Application, Key, Val, Opts) when is_list(Opts) ->
+ application_controller:set_env(Application, Key, Val, Opts).
-spec unset_env(Application, Par) -> 'ok' when
Application :: atom(),
@@ -262,15 +305,17 @@ set_env(Application, Key, Val, Timeout) when is_integer(Timeout), Timeout>=0 ->
unset_env(Application, Key) ->
application_controller:unset_env(Application, Key).
--spec unset_env(Application, Par, Timeout) -> 'ok' when
+-spec unset_env(Application, Par, Opts) -> 'ok' when
Application :: atom(),
Par :: atom(),
- Timeout :: timeout().
+ Opts :: [{timeout, timeout()} | {persistent, boolean()}].
unset_env(Application, Key, infinity) ->
- application_controller:unset_env(Application, Key, infinity);
+ unset_env(Application, Key, [{timeout, infinity}]);
unset_env(Application, Key, Timeout) when is_integer(Timeout), Timeout>=0 ->
- application_controller:unset_env(Application, Key, Timeout).
+ unset_env(Application, Key, [{timeout, Timeout}]);
+unset_env(Application, Key, Opts) when is_list(Opts) ->
+ application_controller:unset_env(Application, Key, Opts).
-spec get_env(Par) -> 'undefined' | {'ok', Val} when
Par :: atom(),
diff --git a/lib/kernel/src/application_controller.erl b/lib/kernel/src/application_controller.erl
index 9ed2c7a7d9..ed13035104 100644
--- a/lib/kernel/src/application_controller.erl
+++ b/lib/kernel/src/application_controller.erl
@@ -461,14 +461,16 @@ permit_application(ApplName, Flag) ->
set_env(AppName, Key, Val) ->
- gen_server:call(?AC, {set_env, AppName, Key, Val}).
-set_env(AppName, Key, Val, Timeout) ->
- gen_server:call(?AC, {set_env, AppName, Key, Val}, Timeout).
+ gen_server:call(?AC, {set_env, AppName, Key, Val, []}).
+set_env(AppName, Key, Val, Opts) ->
+ Timeout = proplists:get_value(timeout, Opts, 5000),
+ gen_server:call(?AC, {set_env, AppName, Key, Val, Opts}, Timeout).
unset_env(AppName, Key) ->
- gen_server:call(?AC, {unset_env, AppName, Key}).
-unset_env(AppName, Key, Timeout) ->
- gen_server:call(?AC, {unset_env, AppName, Key}, Timeout).
+ gen_server:call(?AC, {unset_env, AppName, Key, []}).
+unset_env(AppName, Key, Opts) ->
+ Timeout = proplists:get_value(timeout, Opts, 5000),
+ gen_server:call(?AC, {unset_env, AppName, Key, Opts}, Timeout).
%%%-----------------------------------------------------------------
%%% call-back functions from gen_server
@@ -488,7 +490,7 @@ init(Init, Kernel) ->
%% called during start-up of any app.
case check_conf_data(ConfData) of
ok ->
- ets:new(ac_tab, [set, public, named_table]),
+ _ = ets:new(ac_tab, [set, public, named_table]),
S = #state{conf_data = ConfData},
{ok, KAppl} = make_appl(Kernel),
case catch load(S, KAppl) of
@@ -609,8 +611,8 @@ check_para([Else | _ParaList], AppName) ->
| {'change_application_data', _, _}
| {'permit_application', atom() | {'application',atom(),_},_}
| {'start_application', _, _}
- | {'unset_env', _, _}
- | {'set_env', _, _, _}.
+ | {'unset_env', _, _, _}
+ | {'set_env', _, _, _, _}.
-spec handle_call(calls(), {pid(), term()}, state()) ->
{'noreply', state()} | {'reply', term(), state()}.
@@ -858,13 +860,25 @@ handle_call(which_applications, _From, S) ->
end, S#state.running),
{reply, Reply, S};
-handle_call({set_env, AppName, Key, Val}, _From, S) ->
+handle_call({set_env, AppName, Key, Val, Opts}, _From, S) ->
ets:insert(ac_tab, {{env, AppName, Key}, Val}),
- {reply, ok, S};
+ case proplists:get_value(persistent, Opts, false) of
+ true ->
+ Fun = fun(Env) -> lists:keystore(Key, 1, Env, {Key, Val}) end,
+ {reply, ok, S#state{conf_data = change_app_env(S#state.conf_data, AppName, Fun)}};
+ false ->
+ {reply, ok, S}
+ end;
-handle_call({unset_env, AppName, Key}, _From, S) ->
+handle_call({unset_env, AppName, Key, Opts}, _From, S) ->
ets:delete(ac_tab, {env, AppName, Key}),
- {reply, ok, S};
+ case proplists:get_value(persistent, Opts, false) of
+ true ->
+ Fun = fun(Env) -> lists:keydelete(Key, 1, Env) end,
+ {reply, ok, S#state{conf_data = change_app_env(S#state.conf_data, AppName, Fun)}};
+ false ->
+ {reply, ok, S}
+ end;
handle_call({control_application, AppName}, {Pid, _Tag}, S) ->
Control = S#state.control,
@@ -1640,6 +1654,16 @@ merge_env([{App, AppEnv1} | T], Env2, Res) ->
merge_env([], Env2, Res) ->
Env2 ++ Res.
+%% Changes the environment for the given application
+%% If there is no application, an empty one is created
+change_app_env(Env, App, Fun) ->
+ case get_env_key(App, Env) of
+ {value, AppEnv, RestEnv} ->
+ [{App, Fun(AppEnv)} | RestEnv];
+ _ ->
+ [{App, Fun([])} | Env]
+ end.
+
%% Merges envs for an application. Env2 overrides Env1
merge_app_env(Env1, Env2) ->
merge_app_env(Env1, Env2, []).
@@ -1949,10 +1973,10 @@ test_change_apps(Apps, Conf) ->
test_do_change_appl([], _, _) ->
ok;
test_do_change_appl([A|Apps], [], [R|Res]) ->
- do_change_appl(R, #appl{name = A}, []),
+ _ = do_change_appl(R, #appl{name = A}, []),
test_do_change_appl(Apps, [], Res);
test_do_change_appl([A|Apps], [C|Conf], [R|Res]) ->
- do_change_appl(R, #appl{name = A}, C),
+ _ = do_change_appl(R, #appl{name = A}, C),
test_do_change_appl(Apps, Conf, Res).
test_make_apps([], Res) ->
diff --git a/lib/kernel/src/application_master.erl b/lib/kernel/src/application_master.erl
index 3e636197bb..bc15b5a7de 100644
--- a/lib/kernel/src/application_master.erl
+++ b/lib/kernel/src/application_master.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -27,7 +27,7 @@
-include("application_master.hrl").
--record(state, {child, appl_data, children = [], procs = 0, gleader}).
+-record(state, {child, appl_data, children = [], procs = 0, gleader, req=[]}).
%%-----------------------------------------------------------------
%% Func: start_link/1
@@ -125,7 +125,7 @@ init(Parent, Starter, ApplData, Type) ->
State = #state{appl_data = ApplData, gleader = OldGleader},
case start_it(State, Type) of
{ok, Pid} -> % apply(M,F,A) returned ok
- set_timer(ApplData#appl_data.maxT),
+ ok = set_timer(ApplData#appl_data.maxT),
unlink(Starter),
proc_lib:init_ack(Starter, {ok,self()}),
main_loop(Parent, State#state{child = Pid});
@@ -205,22 +205,25 @@ terminate_loop(Child, State) ->
%%-----------------------------------------------------------------
%% The Application Master is linked to *all* processes in the group
-%% (application).
+%% (application).
%%-----------------------------------------------------------------
handle_msg({get_child, Tag, From}, State) ->
- From ! {Tag, get_child_i(State#state.child)},
- State;
+ get_child_i(State, Tag, From);
handle_msg({stop, Tag, From}, State) ->
catch terminate(normal, State),
From ! {Tag, ok},
exit(normal);
+handle_msg({child, Ref, GrandChild, Mod}, #state{req=Reqs0}=State) ->
+ {value, {_, Tag, From}, Reqs} = lists:keytake(Ref, 1, Reqs0),
+ From ! {Tag, {GrandChild, Mod}},
+ State#state{req=Reqs};
handle_msg(_, State) ->
State.
-
-terminate(Reason, State) ->
- terminate_child(State#state.child, State),
- kill_children(State#state.children),
+terminate(Reason, State = #state{child=Child, children=Children, req=Reqs}) ->
+ _ = [From ! {Tag, error} || {_, Tag, From} <- Reqs],
+ terminate_child(Child, State),
+ kill_children(Children),
exit(Reason).
@@ -342,8 +345,8 @@ start_supervisor(Type, M, A) ->
loop_it(Parent, Child, Mod, AppState) ->
receive
- {Parent, get_child} ->
- Parent ! {self(), Child, Mod},
+ {Parent, get_child, Ref} ->
+ Parent ! {child, Ref, Child, Mod},
loop_it(Parent, Child, Mod, AppState);
{Parent, terminate} ->
NewAppState = prep_stop(Mod, AppState),
@@ -382,10 +385,15 @@ prep_stop(Mod, AppState) ->
NewAppState
end.
-get_child_i(Child) ->
- Child ! {self(), get_child},
- receive
- {Child, GrandChild, Mod} -> {GrandChild, Mod}
+get_child_i(#state{child=Child, req=Reqs}=State, Tag, From) ->
+ Ref = erlang:make_ref(),
+ case erlang:is_process_alive(Child) of
+ true ->
+ Child ! {self(), get_child, Ref},
+ State#state{req=[{Ref, Tag, From}|Reqs]};
+ false ->
+ From ! {Tag, error},
+ State
end.
terminate_child_i(Child, State) ->
@@ -418,4 +426,6 @@ kill_all_procs_1([], _, 0) -> ok;
kill_all_procs_1([], _, _) -> kill_all_procs().
set_timer(infinity) -> ok;
-set_timer(Time) -> timer:exit_after(Time, timeout).
+set_timer(Time) ->
+ {ok, _} = timer:exit_after(Time, timeout),
+ ok.
diff --git a/lib/kernel/src/auth.erl b/lib/kernel/src/auth.erl
index 7d463103e3..eda35147d3 100644
--- a/lib/kernel/src/auth.erl
+++ b/lib/kernel/src/auth.erl
@@ -324,7 +324,7 @@ read_cookie(Name, Size) ->
{ok, File} ->
case file:read(File, Size) of
{ok, List} ->
- file:close(File),
+ ok = file:close(File),
check_cookie(List, []);
{error, Reason} ->
make_error(Name, Reason)
@@ -376,7 +376,7 @@ create_cookie(Name) ->
case file:open(Name, [write, raw]) of
{ok, File} ->
R1 = file:write(File, Cookie),
- file:close(File),
+ ok = file:close(File),
R2 = file:raw_write_file_info(Name, make_info(Name)),
case {R1, R2} of
{ok, ok} ->
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index 03fba96d4b..0eda558ed5 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -364,7 +364,7 @@ load_code_server_prerequisites() ->
lists,
os,
unicode],
- [M = M:module_info(module) || M <- Needed],
+ _ = [M = M:module_info(module) || M <- Needed],
ok.
do_stick_dirs() ->
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index 5d74e8620b..fc7ac08699 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -153,7 +153,7 @@ loop(#state{supervisor=Supervisor}=State0) ->
{code_call, Pid, Req} ->
case handle_call(Req, {Pid, call}, State0) of
{reply, Res, State} ->
- reply(Pid, Res),
+ _ = reply(Pid, Res),
loop(State);
{noreply, State} ->
loop(State);
@@ -1410,45 +1410,236 @@ absname_vr([[X, $:]|Name], _, _AbsBase) ->
do_purge(Mod0) ->
Mod = to_atom(Mod0),
case erlang:check_old_code(Mod) of
- false -> false;
- true -> do_purge(processes(), Mod, false)
- end.
-
-do_purge([P|Ps], Mod, Purged) ->
- case erlang:check_process_code(P, Mod) of
+ false ->
+ false;
true ->
- Ref = erlang:monitor(process, P),
- exit(P, kill),
- receive
- {'DOWN',Ref,process,_Pid,_} -> ok
+ Res = check_proc_code(erlang:processes(), Mod, true),
+ try
+ erlang:purge_module(Mod)
+ catch
+ _:_ -> ignore
end,
- do_purge(Ps, Mod, true);
- false ->
- do_purge(Ps, Mod, Purged)
- end;
-do_purge([], Mod, Purged) ->
- catch erlang:purge_module(Mod),
- Purged.
+ Res
+ end.
%% do_soft_purge(Module)
%% Purge old code only if no procs remain that run old code.
%% Return true in that case, false if procs remain (in this
%% case old code is not purged)
-do_soft_purge(Mod) ->
+do_soft_purge(Mod0) ->
+ Mod = to_atom(Mod0),
case erlang:check_old_code(Mod) of
- false -> true;
- true -> do_soft_purge(processes(), Mod)
+ false ->
+ true;
+ true ->
+ case check_proc_code(erlang:processes(), Mod, false) of
+ false ->
+ false;
+ true ->
+ try
+ erlang:purge_module(Mod)
+ catch
+ _:_ -> ignore
+ end,
+ true
+ end
end.
-do_soft_purge([P|Ps], Mod) ->
- case erlang:check_process_code(P, Mod) of
- true -> false;
- false -> do_soft_purge(Ps, Mod)
+%%
+%% check_proc_code(Pids, Mod, Hard) - Send asynchronous
+%% requests to all processes to perform a check_process_code
+%% operation. Each process will check their own state and
+%% reply with the result. If 'Hard' equals
+%% - true, processes that refer 'Mod' will be killed. If
+%% any processes were killed true is returned; otherwise,
+%% false.
+%% - false, and any processes refer 'Mod', false will
+%% returned; otherwise, true.
+%%
+%% Requests will be sent to all processes identified by
+%% Pids at once, but without allowing GC to be performed.
+%% Check process code operations that are aborted due to
+%% GC need, will be restarted allowing GC. However, only
+%% ?MAX_CPC_GC_PROCS outstanding operation allowing GC at
+%% a time will be allowed. This in order not to blow up
+%% memory wise.
+%%
+%% We also only allow ?MAX_CPC_NO_OUTSTANDING_KILLS
+%% outstanding kills. This both in order to avoid flooding
+%% our message queue with 'DOWN' messages and limiting the
+%% amount of memory used to keep references to all
+%% outstanding kills.
+%%
+
+%% We maybe should allow more than two outstanding
+%% GC requests, but for now we play it safe...
+-define(MAX_CPC_GC_PROCS, 2).
+-define(MAX_CPC_NO_OUTSTANDING_KILLS, 10).
+
+-record(cpc_static, {hard, module, tag}).
+
+-record(cpc_kill, {outstanding = [],
+ no_outstanding = 0,
+ waiting = [],
+ killed = false}).
+
+check_proc_code(Pids, Mod, Hard) ->
+ Tag = erlang:make_ref(),
+ CpcS = #cpc_static{hard = Hard,
+ module = Mod,
+ tag = Tag},
+ check_proc_code(CpcS, cpc_init(CpcS, Pids, 0), 0, [], #cpc_kill{}, true).
+
+check_proc_code(#cpc_static{hard = true}, 0, 0, [],
+ #cpc_kill{outstanding = [], waiting = [], killed = Killed},
+ true) ->
+ %% No outstanding requests. We did a hard check, so result is whether or
+ %% not we killed any processes...
+ Killed;
+check_proc_code(#cpc_static{hard = false}, 0, 0, [], _KillState, Success) ->
+ %% No outstanding requests and we did a soft check...
+ Success;
+check_proc_code(#cpc_static{hard = false, tag = Tag} = CpcS, NoReq0, NoGcReq0,
+ [], _KillState, false) ->
+ %% Failed soft check; just cleanup the remaining replies corresponding
+ %% to the requests we've sent...
+ {NoReq1, NoGcReq1} = receive
+ {check_process_code, {Tag, _P, GC}, _Res} ->
+ case GC of
+ false -> {NoReq0-1, NoGcReq0};
+ true -> {NoReq0, NoGcReq0-1}
+ end
+ end,
+ check_proc_code(CpcS, NoReq1, NoGcReq1, [], _KillState, false);
+check_proc_code(#cpc_static{tag = Tag} = CpcS, NoReq0, NoGcReq0, NeedGC0,
+ KillState0, Success) ->
+
+ %% Check if we should request a GC operation
+ {NoGcReq1, NeedGC1} = case NoGcReq0 < ?MAX_CPC_GC_PROCS of
+ GcOpAllowed when GcOpAllowed == false;
+ NeedGC0 == [] ->
+ {NoGcReq0, NeedGC0};
+ _ ->
+ {NoGcReq0+1, cpc_request_gc(CpcS,NeedGC0)}
+ end,
+
+ %% Wait for a cpc reply or 'DOWN' message
+ {NoReq1, NoGcReq2, Pid, Result, KillState1} = cpc_recv(Tag,
+ NoReq0,
+ NoGcReq1,
+ KillState0),
+
+ %% Check the result of the reply
+ case Result of
+ aborted ->
+ %% Operation aborted due to the need to GC in order to
+ %% determine if the process is referring the module.
+ %% Schedule the operation for restart allowing GC...
+ check_proc_code(CpcS, NoReq1, NoGcReq2, [Pid|NeedGC1], KillState1,
+ Success);
+ false ->
+ %% Process not referring the module; done with this process...
+ check_proc_code(CpcS, NoReq1, NoGcReq2, NeedGC1, KillState1,
+ Success);
+ true ->
+ %% Process referring the module...
+ case CpcS#cpc_static.hard of
+ false ->
+ %% ... and soft check. The whole operation failed so
+ %% no point continuing; clean up and fail...
+ check_proc_code(CpcS, NoReq1, NoGcReq2, [], KillState1,
+ false);
+ true ->
+ %% ... and hard check; schedule kill of it...
+ check_proc_code(CpcS, NoReq1, NoGcReq2, NeedGC1,
+ cpc_sched_kill(Pid, KillState1), Success)
+ end;
+ 'DOWN' ->
+ %% Handled 'DOWN' message
+ check_proc_code(CpcS, NoReq1, NoGcReq2, NeedGC1,
+ KillState1, Success)
+ end.
+
+cpc_recv(Tag, NoReq, NoGcReq, #cpc_kill{outstanding = []} = KillState) ->
+ receive
+ {check_process_code, {Tag, Pid, GC}, Res} ->
+ cpc_handle_cpc(NoReq, NoGcReq, GC, Pid, Res, KillState)
end;
-do_soft_purge([], Mod) ->
- catch erlang:purge_module(Mod),
- true.
+cpc_recv(Tag, NoReq, NoGcReq,
+ #cpc_kill{outstanding = [R0, R1, R2, R3, R4 | _]} = KillState) ->
+ receive
+ {'DOWN', R, process, _, _} when R == R0;
+ R == R1;
+ R == R2;
+ R == R3;
+ R == R4 ->
+ cpc_handle_down(NoReq, NoGcReq, R, KillState);
+ {check_process_code, {Tag, Pid, GC}, Res} ->
+ cpc_handle_cpc(NoReq, NoGcReq, GC, Pid, Res, KillState)
+ end;
+cpc_recv(Tag, NoReq, NoGcReq, #cpc_kill{outstanding = [R|_]} = KillState) ->
+ receive
+ {'DOWN', R, process, _, _} ->
+ cpc_handle_down(NoReq, NoGcReq, R, KillState);
+ {check_process_code, {Tag, Pid, GC}, Res} ->
+ cpc_handle_cpc(NoReq, NoGcReq, GC, Pid, Res, KillState)
+ end.
+
+cpc_handle_down(NoReq, NoGcReq, R, #cpc_kill{outstanding = Rs,
+ no_outstanding = N} = KillState) ->
+ {NoReq, NoGcReq, undefined, 'DOWN',
+ cpc_sched_kill_waiting(KillState#cpc_kill{outstanding = cpc_list_rm(R, Rs),
+ no_outstanding = N-1})}.
+
+cpc_list_rm(R, [R|Rs]) ->
+ Rs;
+cpc_list_rm(R0, [R1|Rs]) ->
+ [R1|cpc_list_rm(R0, Rs)].
+
+cpc_handle_cpc(NoReq, NoGcReq, false, Pid, Res, KillState) ->
+ {NoReq-1, NoGcReq, Pid, Res, KillState};
+cpc_handle_cpc(NoReq, NoGcReq, true, Pid, Res, KillState) ->
+ {NoReq, NoGcReq-1, Pid, Res, KillState}.
+
+cpc_sched_kill_waiting(#cpc_kill{waiting = []} = KillState) ->
+ KillState;
+cpc_sched_kill_waiting(#cpc_kill{outstanding = Rs,
+ no_outstanding = N,
+ waiting = [P|Ps]} = KillState) ->
+ R = erlang:monitor(process, P),
+ exit(P, kill),
+ KillState#cpc_kill{outstanding = [R|Rs],
+ no_outstanding = N+1,
+ waiting = Ps,
+ killed = true}.
+
+cpc_sched_kill(Pid, #cpc_kill{no_outstanding = N, waiting = Pids} = KillState)
+ when N >= ?MAX_CPC_NO_OUTSTANDING_KILLS ->
+ KillState#cpc_kill{waiting = [Pid|Pids]};
+cpc_sched_kill(Pid,
+ #cpc_kill{outstanding = Rs, no_outstanding = N} = KillState) ->
+ R = erlang:monitor(process, Pid),
+ exit(Pid, kill),
+ KillState#cpc_kill{outstanding = [R|Rs],
+ no_outstanding = N+1,
+ killed = true}.
+
+cpc_request(#cpc_static{tag = Tag, module = Mod}, Pid, AllowGc) ->
+ erlang:check_process_code(Pid, Mod, [{async, {Tag, Pid, AllowGc}},
+ {allow_gc, AllowGc}]).
+
+cpc_request_gc(CpcS, [Pid|Pids]) ->
+ cpc_request(CpcS, Pid, true),
+ Pids.
+
+cpc_init(_CpcS, [], NoReqs) ->
+ NoReqs;
+cpc_init(CpcS, [Pid|Pids], NoReqs) ->
+ cpc_request(CpcS, Pid, false),
+ cpc_init(CpcS, Pids, NoReqs+1).
+
+% end of check_proc_code() implementation.
is_loaded(M, Db) ->
case ets:lookup(Db, M) of
@@ -1505,13 +1696,13 @@ finish_on_load_1(Mod, File, OnLoadRes, WaitingPids, Db) ->
erlang:finish_after_on_load(Mod, Keep),
Res = case Keep of
false ->
- finish_on_load_report(Mod, OnLoadRes),
+ _ = finish_on_load_report(Mod, OnLoadRes),
{error,on_load_failure};
true ->
ets:insert(Db, {Mod,File}),
{module,Mod}
end,
- [reply(Pid, Res) || Pid <- WaitingPids],
+ _ = [reply(Pid, Res) || Pid <- WaitingPids],
ok.
finish_on_load_report(_Mod, Atom) when is_atom(Atom) ->
diff --git a/lib/kernel/src/disk_log.erl b/lib/kernel/src/disk_log.erl
index c238eff12f..9a7726cfa0 100644
--- a/lib/kernel/src/disk_log.erl
+++ b/lib/kernel/src/disk_log.erl
@@ -1076,13 +1076,13 @@ log_end(S, [], [], Sync) ->
log_end(S, Pids, Bins, Sync) ->
case do_log(get(log), rflat(Bins)) of
N when is_integer(N) ->
- replies(Pids, ok),
+ ok = replies(Pids, ok),
S1 = (state_ok(S))#state{cnt = S#state.cnt+N},
log_end_sync(S1, Sync);
{error, {error, {full, _Name}}, N} when Pids =:= [] ->
log_end_sync(state_ok(S#state{cnt = S#state.cnt + N}), Sync);
{error, Error, N} ->
- replies(Pids, Error),
+ ok = replies(Pids, Error),
state_err(S#state{cnt = S#state.cnt + N}, Error)
end.
@@ -1091,7 +1091,7 @@ log_end_sync(S, []) ->
S;
log_end_sync(S, Sync) ->
Res = do_sync(get(log)),
- replies(Sync, Res),
+ ok = replies(Sync, Res),
state_err(S, Res).
%% Inlined.
@@ -1183,7 +1183,7 @@ do_exit(S, From, Message0, Reason) ->
_ -> Message0
end,
_ = disk_log_server:close(self()),
- replies(From, Message),
+ ok = replies(From, Message),
?PROFILE(ep:done()),
exit(Reason).
@@ -1881,7 +1881,8 @@ replies(Pids, Reply) ->
send_reply(Pids, M).
send_reply(Pid, M) when is_pid(Pid) ->
- Pid ! M;
+ Pid ! M,
+ ok;
send_reply([Pid | Pids], M) ->
Pid ! M,
send_reply(Pids, M);
@@ -2022,7 +2023,7 @@ notify_owners(Note) ->
cache_error(S, Pids) ->
Error = S#state.cache_error,
- replies(Pids, Error),
+ ok = replies(Pids, Error),
state_err(S#state{cache_error = ok}, Error).
state_ok(S) ->
diff --git a/lib/kernel/src/disk_log_1.erl b/lib/kernel/src/disk_log_1.erl
index 9d431bdd30..59f5cad001 100644
--- a/lib/kernel/src/disk_log_1.erl
+++ b/lib/kernel/src/disk_log_1.erl
@@ -295,12 +295,18 @@ read_chunk_ro(FdC, FileName, Pos, MaxBytes) ->
pread(FdC, FileName, Pos + ?HEADSZ, MaxBytes).
%% -> ok | throw(Error)
-close(#cache{fd = Fd, c = []}, _FileName, read_only) ->
- file:close(Fd);
+close(#cache{fd = Fd, c = []}, FileName, read_only) ->
+ case file:close(Fd) of
+ ok -> ok;
+ Error -> file_error(FileName, Error)
+ end;
close(#cache{fd = Fd, c = C}, FileName, read_write) ->
{Reply, _NewFdC} = write_cache(Fd, FileName, C),
mark(Fd, FileName, ?CLOSED),
- file:close(Fd),
+ case file:close(Fd) of
+ ok -> ok;
+ Error -> file_error(FileName, Error)
+ end,
if Reply =:= ok -> ok; true -> throw(Reply) end.
%% Open an internal file. Head is ignored if Mode is read_only.
@@ -320,7 +326,10 @@ int_open(FName, Repair, read_write, Head) ->
{ok, FileHead} ->
case is_head(FileHead) of
yes ->
- file:close(Fd),
+ case file:close(Fd) of
+ ok -> ok;
+ Error2 -> file_error(FName, Error2)
+ end,
case open_update(FName) of
{ok, Fd2} ->
mark(Fd2, FName, ?OPENED),
@@ -333,14 +342,14 @@ int_open(FName, Repair, read_write, Head) ->
yes_not_closed when Repair ->
repair(Fd, FName);
yes_not_closed when not Repair ->
- file:close(Fd),
+ _ = file:close(Fd),
throw({error, {need_repair, FName}});
no ->
- file:close(Fd),
+ _ = file:close(Fd),
throw({error, {not_a_log_file, FName}})
end;
eof ->
- file:close(Fd),
+ _= file:close(Fd),
throw({error, {not_a_log_file, FName}});
Error ->
file_error_close(Fd, FName, Error)
@@ -363,11 +372,11 @@ int_open(FName, _Repair, read_only, _Head) ->
FdC = #cache{fd = Fd},
{ok, {existed, FdC, {0, 0}, P}};
no ->
- file:close(Fd),
+ _= file:close(Fd),
throw({error, {not_a_log_file, FName}})
end;
eof ->
- file:close(Fd),
+ _ = file:close(Fd),
throw({error, {not_a_log_file, FName}});
Error ->
file_error_close(Fd, FName, Error)
@@ -398,7 +407,7 @@ int_log_head(Fd, Head) ->
none ->
{#cache{fd = Fd}, 0, 0};
Error ->
- file:close(Fd),
+ _= file:close(Fd),
throw(Error)
end.
@@ -450,13 +459,13 @@ ext_log_head(Fd, Head) ->
none ->
{#cache{fd = Fd}, {0, 0}};
Error ->
- file:close(Fd),
+ _= file:close(Fd),
throw(Error)
end.
%% -> _Any | throw()
mark(Fd, FileName, What) ->
- position_close2(Fd, FileName, 4),
+ {ok, _} = position_close2(Fd, FileName, 4),
fwrite_close2(Fd, FileName, What).
%% -> {ok, Bin} | Error
@@ -560,7 +569,7 @@ scan_f2(B, FSz, Ack, No, Bad, Size, Tail) ->
end.
done_scan(In, Out, OutName, FName, RecoveredTerms, BadChars) ->
- file:close(In),
+ _ = file:close(In),
case catch fclose(Out, OutName) of
ok ->
case file:rename(OutName, FName) of
@@ -574,21 +583,21 @@ done_scan(In, Out, OutName, FName, RecoveredTerms, BadChars) ->
file_error(FName, Error)
end;
Error ->
- file:delete(OutName),
+ _ = file:delete(OutName),
file_error(FName, Error)
end;
Error ->
- file:delete(OutName),
+ _ = file:delete(OutName),
throw(Error)
end.
-spec repair_err(file:io_device(), #cache{}, file:filename(),
file:filename(), {'error', file:posix()}) -> no_return().
repair_err(In, Out, OutName, ErrFileName, Error) ->
- file:close(In),
+ _= file:close(In),
catch fclose(Out, OutName),
%% OutName is often the culprit, try to remove it anyway...
- file:delete(OutName),
+ _ = file:delete(OutName),
file_error(ErrFileName, Error).
%% Used by wrap_log_reader.
@@ -764,10 +773,10 @@ mf_int_chunk(Handle, {FileNo, Pos}, Bin, N) ->
{ok, {_Alloc, FdC, _HeadSize, _FileSize}} ->
case chunk(FdC, FName, Pos, Bin, N) of
{NewFdC, eof} ->
- file:close(NewFdC#cache.fd),
+ _ = file:close(NewFdC#cache.fd),
mf_int_chunk(Handle, {NFileNo, 0}, [], N);
{NewFdC, Other} ->
- file:close(NewFdC#cache.fd),
+ _ = file:close(NewFdC#cache.fd),
{Handle, conv(Other, FileNo)}
end
end.
@@ -792,10 +801,10 @@ mf_int_chunk_read_only(Handle, {FileNo, Pos}, Bin, N) ->
{ok, {_Alloc, FdC, _HeadSize, _FileSize}} ->
case do_chunk_read_only(FdC, FName, Pos, Bin, N) of
{NewFdC, eof} ->
- file:close(NewFdC#cache.fd),
+ _ = file:close(NewFdC#cache.fd),
mf_int_chunk_read_only(Handle, {NFileNo,0}, [], N);
{NewFdC, Other} ->
- file:close(NewFdC#cache.fd),
+ _ = file:close(NewFdC#cache.fd),
{Handle, conv(Other, FileNo)}
end
end.
@@ -1017,7 +1026,7 @@ ext_file_open(FName, NewFile, OldFile, OldCnt, Head, Repair, Mode) ->
read_index_file(truncate, FName, MaxF) ->
remove_files(FName, 2, MaxF),
- file:delete(?index_file_name(FName)),
+ _ = file:delete(?index_file_name(FName)),
{1, 0, 0, 0};
read_index_file(_, FName, _MaxF) ->
read_index_file(FName).
@@ -1043,7 +1052,7 @@ read_index_file(FName) ->
_ErrorOrEof ->
{1, 0, 0, 0}
end,
- file:close(Fd),
+ _ = file:close(Fd),
R;
_Error ->
{1, 0, 0, 0}
@@ -1096,7 +1105,7 @@ write_index_file(read_write, FName, NewFile, OldFile, OldCnt) ->
%% Very old format, convert to the latest format!
case file:read_file(FileName) of
{ok, <<_CurF, Tail/binary>>} ->
- position_close2(Fd, FileName, bof),
+ {ok, _} = position_close2(Fd, FileName, bof),
Bin = <<0, 0:32, ?VERSION, NewFile:32>>,
NewTail = to_8_bytes(Tail, [], FileName, Fd),
fwrite_close2(Fd, FileName, [Bin | NewTail]),
@@ -1115,7 +1124,7 @@ write_index_file(read_write, FName, NewFile, OldFile, OldCnt) ->
R = file:pread(Fd, NewPos, SzSz),
OldPos = Offset + (OldFile - 1)*SzSz,
pwrite_close2(Fd, FileName, OldPos, OldCntBin),
- file:close(Fd),
+ _ = file:close(Fd),
case R of
{ok, <<Lost:SzSz/unit:8>>} -> Lost;
{ok, _} ->
@@ -1125,7 +1134,7 @@ write_index_file(read_write, FName, NewFile, OldFile, OldCnt) ->
end;
true ->
pwrite_close2(Fd, FileName, NewPos, OldCntBin),
- file:close(Fd),
+ _ = file:close(Fd),
0
end;
E ->
@@ -1137,7 +1146,7 @@ to_8_bytes(<<N:32,T/binary>>, NT, FileName, Fd) ->
to_8_bytes(B, NT, _FileName, _Fd) when byte_size(B) =:= 0 ->
NT;
to_8_bytes(_B, _NT, FileName, Fd) ->
- file:close(Fd),
+ _ = file:close(Fd),
throw({error, {invalid_index_file, FileName}}).
%% -> ok | throw(FileError)
@@ -1147,7 +1156,7 @@ index_file_trunc(FName, N) ->
{ok, Fd} ->
case file:read(Fd, 6) of
eof ->
- file:close(Fd),
+ _ = file:close(Fd),
ok;
{ok, <<0, 0:32, Version>>} when Version =:= ?VERSION ->
truncate_index_file(Fd, FileName, 10, 8, N);
@@ -1166,10 +1175,10 @@ truncate_index_file(Fd, FileName, Offset, N, SzSz) ->
Pos = Offset + N*SzSz,
case Pos > file_size(FileName) of
true ->
- file:close(Fd);
+ ok = file:close(Fd);
false ->
truncate_at_close2(Fd, FileName, {bof, Pos}),
- file:close(Fd)
+ ok = file:close(Fd)
end,
ok.
@@ -1412,7 +1421,8 @@ fwrite(#cache{c = []} = FdC, _FN, B, Size) ->
ok;
_ ->
put(write_cache_timer_is_running, true),
- erlang:send_after(?TIMEOUT, self(), {self(), write_cache})
+ erlang:send_after(?TIMEOUT, self(), {self(), write_cache}),
+ ok
end,
{ok, FdC#cache{sz = Size, c = B}};
fwrite(#cache{sz = Sz, c = C} = FdC, _FN, B, Size) when Sz < ?MAX ->
@@ -1511,7 +1521,7 @@ position_close2(Fd, FileName, Pos) ->
end.
truncate_at_close2(Fd, FileName, Pos) ->
- position_close2(Fd, FileName, Pos),
+ {ok, _} = position_close2(Fd, FileName, Pos),
case file:truncate(Fd) of
ok -> ok;
Error -> file_error_close(Fd, FileName, Error)
@@ -1519,7 +1529,7 @@ truncate_at_close2(Fd, FileName, Pos) ->
fclose(#cache{fd = Fd, c = C}, FileName) ->
%% The cache is empty if the file was opened in read_only mode.
- write_cache_close(Fd, FileName, C),
+ _ = write_cache_close(Fd, FileName, C),
file:close(Fd).
%% -> {Reply, #cache{}}; Reply = ok | Error
@@ -1549,5 +1559,5 @@ file_error(FileName, {error, Error}) ->
-spec file_error_close(file:fd(), file:filename(), {'error', file:posix()}) -> no_return().
file_error_close(Fd, FileName, {error, Error}) ->
- file:close(Fd),
+ _ = file:close(Fd),
throw({error, {file_error, FileName, Error}}).
diff --git a/lib/kernel/src/disk_log_server.erl b/lib/kernel/src/disk_log_server.erl
index 8894ed87e8..684ea5b5db 100644
--- a/lib/kernel/src/disk_log_server.erl
+++ b/lib/kernel/src/disk_log_server.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -83,8 +83,8 @@ accessible_logs() ->
init([]) ->
process_flag(trap_exit, true),
- ets:new(?DISK_LOG_NAME_TABLE, [named_table, set]),
- ets:new(?DISK_LOG_PID_TABLE, [named_table, set]),
+ _ = ets:new(?DISK_LOG_NAME_TABLE, [named_table, set]),
+ _= ets:new(?DISK_LOG_PID_TABLE, [named_table, set]),
{ok, #state{}}.
handle_call({open, W, A}, From, State) ->
@@ -159,15 +159,25 @@ ensure_started() ->
undefined ->
LogSup = {disk_log_sup, {disk_log_sup, start_link, []}, permanent,
1000, supervisor, [disk_log_sup]},
- supervisor:start_child(kernel_safe_sup, LogSup),
+ {ok, _} = ensure_child_started(kernel_safe_sup, LogSup),
LogServer = {disk_log_server,
{disk_log_server, start_link, []},
permanent, 2000, worker, [disk_log_server]},
- supervisor:start_child(kernel_safe_sup, LogServer),
+ {ok, _} = ensure_child_started(kernel_safe_sup, LogServer),
ok;
_ -> ok
end.
+ensure_child_started(Sup,Child) ->
+ case supervisor:start_child(Sup, Child) of
+ {ok,Pid} ->
+ {ok,Pid};
+ {error,{already_started,Pid}} ->
+ {ok,Pid};
+ Error ->
+ Error
+ end.
+
open([{Req, From} | L], State) ->
State2 = case do_open(Req, From, State) of
{pending, State1} ->
diff --git a/lib/kernel/src/dist_ac.erl b/lib/kernel/src/dist_ac.erl
index 5c62aa31e9..a4d4ae386c 100644
--- a/lib/kernel/src/dist_ac.erl
+++ b/lib/kernel/src/dist_ac.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -283,7 +283,7 @@ handle_cast(init_sync, _S) ->
KernelConfig ! dist_ac_took_control,
%% we're really just interested in nodedowns.
- net_kernel:monitor_nodes(true),
+ ok = net_kernel:monitor_nodes(true),
{Known, NAppls, RStarted} = sync_dacs(Appls),
@@ -321,7 +321,7 @@ handle_call({takeover_application, AppName, RestartType}, From, S) ->
case keysearch(AppName, #appl.name, Appls) of
{value, Appl} when element(1, Appl#appl.id) =:= distributed ->
{distributed, Node} = Appl#appl.id,
- ac_takeover(req, AppName, Node, RestartType),
+ _ = ac_takeover(req, AppName, Node, RestartType),
NAppl = Appl#appl{id = takeover},
NAppls = keyreplace(AppName, #appl.name, Appls, NAppl),
TR = S#state.t_reqs,
@@ -341,10 +341,10 @@ handle_call({permit_application, AppName, Bool, LockId, StartInfo}, From, S) ->
%% here, but we have to be backwards-compatible.
case application_controller:get_loaded(AppName) of
{true, _} when not Bool ->
- ac_stop_it(AppName),
+ _ = ac_stop_it(AppName),
{reply, ok, S};
{true, _} when Bool ->
- ac_start_it(req, AppName),
+ _ = ac_start_it(req, AppName),
{reply, ok, S};
false ->
{reply, {error, {not_loaded, AppName}}, S}
@@ -533,7 +533,7 @@ handle_info({dist_ac_app_started, Node, Name, Res}, S) ->
%% Another node started appl. Update appl list.
{distributed, Node}
end,
- ac_started(req, Name, Node),
+ _ = ac_started(req, Name, Node),
NAppl = Appl#appl{id = NId},
NAppls = keyreplace(Name, #appl.name, Appls, NAppl),
TmpWeights = keydelete_all(Name, 1, S#state.tmp_weights),
@@ -622,7 +622,7 @@ handle_info({nodedown, Node}, S) ->
true ->
{true, Appl#appl{id = {failover, Node}}};
false ->
- ac_not_running(Appl#appl.name),
+ _ = ac_not_running(Appl#appl.name),
{true, Appl#appl{id = undefined}}
end;
(_) ->
@@ -656,7 +656,8 @@ handle_info({dist_ac_app_loaded, Node, Name, HisNodes, Permission, HeKnowsMe},
%% he's a new node connecting to us.
Msg = {dist_ac_app_loaded, node(), Name,
Nodes, dist_is_runnable(Appls, Name), true},
- {?DIST_AC, Node} ! Msg;
+ {?DIST_AC, Node} ! Msg,
+ ok;
true ->
ok
end,
@@ -811,29 +812,29 @@ start_appl(AppName, S, Type) ->
start_distributed(Appl, Name, Nodes, PermittedNodes, S, Type) ->
case find_start_node(Nodes, PermittedNodes, Name, S) of
{ok, Node} when Node =:= node() ->
- case Appl#appl.id of
- {failover, FoNode} when Type =:= req ->
- ac_failover(Name, FoNode, undefined);
- {distributed, Node2} when Type =:= req ->
- ac_takeover(req, Name, Node2, undefined);
- _ when Type =:= reply ->
- case lists:keysearch(Name, 2, S#state.remote_started) of
- {value, {Node3, _}} ->
- ac_takeover(reply, Name, Node3, undefined);
- _ ->
- ac_start_it(Type, Name)
- end;
- _ ->
- ac_start_it(Type, Name)
- end,
+ _ = case Appl#appl.id of
+ {failover, FoNode} when Type =:= req ->
+ ac_failover(Name, FoNode, undefined);
+ {distributed, Node2} when Type =:= req ->
+ ac_takeover(req, Name, Node2, undefined);
+ _ when Type =:= reply ->
+ case lists:keysearch(Name, 2, S#state.remote_started) of
+ {value, {Node3, _}} ->
+ ac_takeover(reply, Name, Node3, undefined);
+ _ ->
+ ac_start_it(Type, Name)
+ end;
+ _ ->
+ ac_start_it(Type, Name)
+ end,
{run_waiting, true};
{already_started, Node} ->
- ac_started(Type, Name, Node),
+ _ = ac_started(Type, Name, Node),
{{distributed, Node}, false};
{ok, Node} ->
case keysearch(Name, #appl.name, S#state.appls) of
{value, #appl{id = {distributed, Node}}} ->
- ac_started(Type, Name, Node),
+ _ = ac_started(Type, Name, Node),
{{distributed, Node}, false};
_ ->
wait_dist_start(Node, Appl, Name, Nodes,
@@ -842,7 +843,7 @@ start_distributed(Appl, Name, Nodes, PermittedNodes, S, Type) ->
not_started ->
wait_dist_start2(Appl, Name, Nodes, PermittedNodes, S, Type);
no_permission ->
- ac_not_started(Type, Name),
+ _ = ac_not_started(Type, Name),
{undefined, false}
end.
@@ -850,11 +851,11 @@ wait_dist_start(Node, Appl, Name, Nodes, PermittedNodes, S, Type) ->
monitor_node(Node, true),
receive
{dist_ac_app_started, Node, Name, ok} ->
- ac_started(Type, Name, Node),
+ _ = ac_started(Type, Name, Node),
monitor_node(Node, false),
{{distributed, Node}, false};
{dist_ac_app_started, Node, Name, {error, R}} ->
- ac_error(Type, Name, {Node, R}),
+ _ = ac_error(Type, Name, {Node, R}),
monitor_node(Node, false),
{Appl#appl.id, false};
{dist_ac_weight, Name, _Weigth, Node} ->
@@ -883,10 +884,10 @@ wait_dist_start(Node, Appl, Name, Nodes, PermittedNodes, S, Type) ->
wait_dist_start2(Appl, Name, Nodes, PermittedNodes, S, Type) ->
receive
{dist_ac_app_started, Node, Name, ok} ->
- ac_started(Type, Name, Node),
+ _ = ac_started(Type, Name, Node),
{{distributed, Node}, false};
{dist_ac_app_started, Node, Name, {error, R}} ->
- ac_error(Type, Name, {Node, R}),
+ _ = ac_error(Type, Name, {Node, R}),
{Appl#appl.id, false};
{nodedown, Node} ->
%% A node went down, try to start the app again - there may not
@@ -974,7 +975,7 @@ permit(false, {value, _}, AppName, From, S, _LockId) ->
case dist_get_runnable_nodes(S#state.appls, AppName) of
[] ->
%% There is no runnable node; stop application
- ac_stop_it(AppName),
+ _ = ac_stop_it(AppName),
SReqs = [{AppName, From} | S#state.s_reqs],
{noreply, S#state{s_reqs = SReqs}};
Nodes ->
@@ -1155,7 +1156,8 @@ send_nodes(Nodes, Msg) ->
end, FlatNodes).
send_after(Time, Msg) when is_integer(Time), Time >= 0 ->
- spawn_link(?MODULE, send_timeout, [self(), Time, Msg]);
+ _Pid = spawn_link(?MODULE, send_timeout, [self(), Time, Msg]),
+ ok;
send_after(_,_) -> % infinity
ok.
@@ -1305,7 +1307,7 @@ check_waiting([{From, AppName, false, Nodes} | Reqs],
S, Node, Appls, Res, SReqs) ->
case lists:delete(Node, Nodes) of
[] ->
- ac_stop_it(AppName),
+ _ = ac_stop_it(AppName),
NSReqs = [{AppName, From} | SReqs],
check_waiting(Reqs, Node, S, Appls, Res, NSReqs);
NNodes ->
diff --git a/lib/kernel/src/erl_boot_server.erl b/lib/kernel/src/erl_boot_server.erl
index 0d68d3e198..9a49655a9f 100644
--- a/lib/kernel/src/erl_boot_server.erl
+++ b/lib/kernel/src/erl_boot_server.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -191,7 +191,7 @@ init(Slaves) ->
{ok, UPort} = inet:port(U),
Ref = make_ref(),
Pid = proc_lib:spawn_link(?MODULE, boot_init, [Ref]),
- gen_tcp:controlling_process(L, Pid),
+ ok = gen_tcp:controlling_process(L, Pid),
Pid ! {Ref, L},
%% We trap exit inorder to restart boot_init and udp_port
process_flag(trap_exit, true),
@@ -233,9 +233,19 @@ handle_info({udp, U, IP, Port, Data}, S0) ->
%% erlang version as the boot server node
case {Valid,Data,Token} of
{true,Token,Token} ->
- gen_udp:send(U,IP,Port,[?EBOOT_REPLY,S0#state.priority,
- int16(S0#state.listen_port),
- S0#state.version]),
+ case gen_udp:send(U,IP,Port,[?EBOOT_REPLY,S0#state.priority,
+ int16(S0#state.listen_port),
+ S0#state.version])
+ of
+ ok -> ok;
+ {error, not_owner} ->
+ error_logger:error_msg("** Illegal boot server connection attempt: "
+ "not owner of ~w ** ~n", [U]);
+ {error, Reason} ->
+ Err = file:format_error(Reason),
+ error_logger:error_msg("** Illegal boot server connection attempt: "
+ "~w POSIX error ** ~n", [U, Err])
+ end,
{noreply,S0};
{false,_,_} ->
error_logger:error_msg("** Illegal boot server connection attempt: "
@@ -351,7 +361,14 @@ handle_command(S, PS, Msg) ->
end.
send_file_result(S, Cmd, Result) ->
- gen_tcp:send(S, term_to_binary({Cmd,Result})).
-
-send_result(S, Result) ->
- gen_tcp:send(S, term_to_binary(Result)).
+ send_result(S, {Cmd,Result}).
+
+send_result(S, Term) ->
+ case gen_tcp:send(S, term_to_binary(Term)) of
+ ok ->
+ ok;
+ Error ->
+ error_logger:error_msg("** Boot server could not send result "
+ "to socket: ~w** ~n", [Error]),
+ ok
+ end.
diff --git a/lib/kernel/src/erl_epmd.erl b/lib/kernel/src/erl_epmd.erl
index 91af49f303..b4fae24ef3 100644
--- a/lib/kernel/src/erl_epmd.erl
+++ b/lib/kernel/src/erl_epmd.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -217,17 +217,23 @@ do_register_node(NodeName, TcpPort) ->
Extra = "",
Elen = length(Extra),
Len = 1+2+1+1+2+2+2+length(Name)+2+Elen,
- gen_tcp:send(Socket, [?int16(Len), ?EPMD_ALIVE2_REQ,
- ?int16(TcpPort),
- $M,
- 0,
- ?int16(epmd_dist_high()),
- ?int16(epmd_dist_low()),
- ?int16(length(Name)),
- Name,
- ?int16(Elen),
- Extra]),
- wait_for_reg_reply(Socket, []);
+ Packet = [?int16(Len), ?EPMD_ALIVE2_REQ,
+ ?int16(TcpPort),
+ $M,
+ 0,
+ ?int16(epmd_dist_high()),
+ ?int16(epmd_dist_low()),
+ ?int16(length(Name)),
+ Name,
+ ?int16(Elen),
+ Extra],
+ case gen_tcp:send(Socket, Packet) of
+ ok ->
+ wait_for_reg_reply(Socket, []);
+ Error ->
+ close(Socket),
+ Error
+ end;
Error ->
Error
end.
@@ -294,8 +300,14 @@ get_port(Node, EpmdAddress, Timeout) ->
{ok, Socket} ->
Name = to_string(Node),
Len = 1+length(Name),
- gen_tcp:send(Socket, [?int16(Len),?EPMD_PORT_PLEASE2_REQ, Name]),
- wait_for_port_reply(Socket, []);
+ Msg = [?int16(Len),?EPMD_PORT_PLEASE2_REQ,Name],
+ case gen_tcp:send(Socket, Msg) of
+ ok ->
+ wait_for_port_reply(Socket, []);
+ _Error ->
+ ?port_please_failure2(_Error),
+ noport
+ end;
_Error ->
?port_please_failure2(_Error),
noport
@@ -374,7 +386,7 @@ wait_for_port_reply_name(Socket, Len, Sofar) ->
% io:format("data = ~p~n", _Data),
wait_for_port_reply_name(Socket, Len, Sofar);
{tcp_closed, Socket} ->
- "foobar"
+ ok
end.
@@ -424,19 +436,24 @@ get_names(EpmdAddress) ->
end.
do_get_names(Socket) ->
- gen_tcp:send(Socket, [?int16(1),?EPMD_NAMES]),
- receive
- {tcp, Socket, [P0,P1,P2,P3|T]} ->
- EpmdPort = ?u32(P0,P1,P2,P3),
- case get_epmd_port() of
- EpmdPort ->
- names_loop(Socket, T, []);
- _ ->
- close(Socket),
- {error, address}
+ case gen_tcp:send(Socket, [?int16(1),?EPMD_NAMES]) of
+ ok ->
+ receive
+ {tcp, Socket, [P0,P1,P2,P3|T]} ->
+ EpmdPort = ?u32(P0,P1,P2,P3),
+ case get_epmd_port() of
+ EpmdPort ->
+ names_loop(Socket, T, []);
+ _ ->
+ close(Socket),
+ {error, address}
+ end;
+ {tcp_closed, Socket} ->
+ {ok, []}
end;
- {tcp_closed, Socket} ->
- {ok, []}
+ _ ->
+ close(Socket),
+ {error, address}
end.
names_loop(Socket, Acc, Ps) ->
diff --git a/lib/kernel/src/erl_reply.erl b/lib/kernel/src/erl_reply.erl
index 1a61e630bc..f0be3ee654 100644
--- a/lib/kernel/src/erl_reply.erl
+++ b/lib/kernel/src/erl_reply.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -32,7 +32,7 @@ reply([Addr,Port,Msg]) ->
P = list_to_integer(atom_to_list(Port)),
M = atom_to_list(Msg),
{ok, S} = gen_tcp:connect(Ip,P,[]),
- gen_tcp:send(S,M),
+ ok = gen_tcp:send(S,M),
gen_tcp:close(S),
reply_done;
reply(_) ->
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl
index 92c1eb80dc..b8fbf02feb 100644
--- a/lib/kernel/src/error_logger.erl
+++ b/lib/kernel/src/error_logger.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -245,16 +245,18 @@ notify(Msg) ->
-spec swap_handler(Type :: swap_handler_type()) -> any().
swap_handler(tty) ->
- gen_event:swap_handler(error_logger, {error_logger, swap},
- {error_logger_tty_h, []}),
- simple_logger();
+ R = gen_event:swap_handler(error_logger, {error_logger, swap},
+ {error_logger_tty_h, []}),
+ ok = simple_logger(),
+ R;
swap_handler({logfile, File}) ->
- gen_event:swap_handler(error_logger, {error_logger, swap},
- {error_logger_file_h, File}),
- simple_logger();
+ R = gen_event:swap_handler(error_logger, {error_logger, swap},
+ {error_logger_file_h, File}),
+ ok = simple_logger(),
+ R;
swap_handler(silent) ->
- gen_event:delete_handler(error_logger, error_logger, delete),
- simple_logger();
+ _ = gen_event:delete_handler(error_logger, error_logger, delete),
+ ok = simple_logger();
swap_handler(false) ->
ok. % keep primitive event handler as-is
diff --git a/lib/kernel/src/erts_debug.erl b/lib/kernel/src/erts_debug.erl
index 6654cd9ee7..f7a815882b 100644
--- a/lib/kernel/src/erts_debug.erl
+++ b/lib/kernel/src/erts_debug.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -288,7 +288,7 @@ dff(Name, Fs) when is_list(Name) ->
try
dff(F, Fs)
after
- file:close(F)
+ _ = file:close(F)
end;
{error,Reason} ->
{error,{badopen,Reason}}
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index 36289053eb..23cf74f80f 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -95,7 +95,8 @@
Delay :: non_neg_integer()}
| 'delayed_write' | {'read_ahead', Size :: pos_integer()}
| 'read_ahead' | 'compressed'
- | {'encoding', unicode:encoding()}.
+ | {'encoding', unicode:encoding()}
+ | sync.
-type deep_list() :: [char() | atom() | deep_list()].
-type name() :: string() | atom() | deep_list().
-type name_all() :: string() | atom() | deep_list() | (RawFilename :: binary()).
@@ -110,7 +111,8 @@
-type date_time() :: calendar:datetime().
-type posix_file_advise() :: 'normal' | 'sequential' | 'random'
| 'no_reuse' | 'will_need' | 'dont_need'.
--type sendfile_option() :: {chunk_size, non_neg_integer()}.
+-type sendfile_option() :: {chunk_size, non_neg_integer()}
+ | {use_threads, boolean()}.
-type file_info_option() :: {'time', 'local'} | {'time', 'universal'}
| {'time', 'posix'}.
%%% BIFs
@@ -376,7 +378,7 @@ write_file(Name, Bin, ModeList) when is_list(ModeList) ->
ok ->
close(Handle);
E1 ->
- close(Handle),
+ _ = close(Handle),
E1
end;
E2 ->
@@ -770,7 +772,7 @@ copy_int({SourceName, SourceOpts}, Dest, Length)
case open(Source, [read | SourceOpts]) of
{ok, Handle} ->
Result = copy_opened_int(Handle, Dest, Length, 0),
- close(Handle),
+ _ = close(Handle),
Result;
{error, _} = Error ->
Error
@@ -786,9 +788,16 @@ copy_int(Source, {DestName, DestOpts}, Length)
Dest ->
case open(Dest, [write | DestOpts]) of
{ok, Handle} ->
- Result = copy_opened_int(Source, Handle, Length, 0),
- close(Handle),
- Result;
+ case copy_opened_int(Source, Handle, Length, 0) of
+ {ok, _} = OK ->
+ case close(Handle) of
+ ok -> OK;
+ Error -> Error
+ end;
+ Error ->
+ _ = close(Handle),
+ Error
+ end;
{error, _} = Error ->
Error
end
@@ -957,7 +966,7 @@ consult(File) ->
case open(File, [read]) of
{ok, Fd} ->
R = consult_stream(Fd),
- close(Fd),
+ _ = close(Fd),
R;
Error ->
Error
@@ -977,10 +986,10 @@ path_consult(Path, File) ->
{ok, Fd, Full} ->
case consult_stream(Fd) of
{ok, List} ->
- close(Fd),
+ _ = close(Fd),
{ok, List, Full};
E1 ->
- close(Fd),
+ _ = close(Fd),
E1
end;
E2 ->
@@ -1005,7 +1014,7 @@ eval(File, Bs) ->
case open(File, [read]) of
{ok, Fd} ->
R = eval_stream(Fd, ignore, Bs),
- close(Fd),
+ _ = close(Fd),
R;
Error ->
Error
@@ -1035,10 +1044,10 @@ path_eval(Path, File, Bs) ->
{ok, Fd, Full} ->
case eval_stream(Fd, ignore, Bs) of
ok ->
- close(Fd),
+ _ = close(Fd),
{ok, Full};
E1 ->
- close(Fd),
+ _ = close(Fd),
E1
end;
E2 ->
@@ -1065,7 +1074,7 @@ script(File, Bs) ->
case open(File, [read]) of
{ok, Fd} ->
R = eval_stream(Fd, return, Bs),
- close(Fd),
+ _ = close(Fd),
R;
Error ->
Error
@@ -1098,10 +1107,10 @@ path_script(Path, File, Bs) ->
{ok,Fd,Full} ->
case eval_stream(Fd, return, Bs) of
{ok,R} ->
- close(Fd),
+ _ = close(Fd),
{ok, R, Full};
E1 ->
- close(Fd),
+ _ = close(Fd),
E1
end;
E2 ->
@@ -1221,8 +1230,7 @@ change_time(Name, {{AY, AM, AD}, {AH, AMin, ASec}}=Atime,
sendfile(File, _Sock, _Offet, _Bytes, _Opts) when is_pid(File) ->
{error, badarg};
sendfile(File, Sock, Offset, Bytes, []) ->
- sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [],
- false, false, false);
+ sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [], []);
sendfile(File, Sock, Offset, Bytes, Opts) ->
ChunkSize0 = proplists:get_value(chunk_size, Opts, ?MAX_CHUNK_SIZE),
ChunkSize = if ChunkSize0 > ?MAX_CHUNK_SIZE ->
@@ -1232,8 +1240,7 @@ sendfile(File, Sock, Offset, Bytes, Opts) ->
%% Support for headers, trailers and options has been removed because the
%% Darwin and BSD API for using it does not play nice with
%% non-blocking sockets. See unix_efile.c for more info.
- sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [],
- false,false,false).
+ sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [], Opts).
%% sendfile/2
-spec sendfile(Filename, Socket) ->
@@ -1247,23 +1254,23 @@ sendfile(Filename, Sock) ->
{error, Reason};
{ok, Fd} ->
Res = sendfile(Fd, Sock, 0, 0, []),
- file:close(Fd),
+ _ = file:close(Fd),
Res
end.
%% Internal sendfile functions
sendfile(#file_descriptor{ module = Mod } = Fd, Sock, Offset, Bytes,
- ChunkSize, Headers, Trailers, Nodiskio, MNowait, Sync)
+ ChunkSize, Headers, Trailers, Opts)
when is_port(Sock) ->
case Mod:sendfile(Fd, Sock, Offset, Bytes, ChunkSize, Headers, Trailers,
- Nodiskio, MNowait, Sync) of
+ Opts) of
{error, enotsup} ->
sendfile_fallback(Fd, Sock, Offset, Bytes, ChunkSize,
Headers, Trailers);
Else ->
Else
end;
-sendfile(_,_,_,_,_,_,_,_,_,_) ->
+sendfile(_,_,_,_,_,_,_,_) ->
{error, badarg}.
%%%
@@ -1298,7 +1305,7 @@ sendfile_fallback(File, Sock, Offset, Bytes, ChunkSize) ->
{ok, CurrPos} = file:position(File, {cur, 0}),
{ok, _NewPos} = file:position(File, {bof, Offset}),
Res = sendfile_fallback_int(File, Sock, Bytes, ChunkSize, 0),
- file:position(File, {bof, CurrPos}),
+ _ = file:position(File, {bof, CurrPos}),
Res.
diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl
index 0bcb1a658b..0e9ff5bc0f 100644
--- a/lib/kernel/src/file_io_server.erl
+++ b/lib/kernel/src/file_io_server.erl
@@ -162,29 +162,29 @@ server_loop(#state{mref = Mref} = State) ->
{file_request, From, ReplyAs, Request} when is_pid(From) ->
case file_request(Request, State) of
{reply, Reply, NewState} ->
- file_reply(From, ReplyAs, Reply),
+ _ = file_reply(From, ReplyAs, Reply),
server_loop(NewState);
{error, Reply, NewState} ->
%% error is the same as reply, except that
%% it breaks the io_request_loop further down
- file_reply(From, ReplyAs, Reply),
+ _ = file_reply(From, ReplyAs, Reply),
server_loop(NewState);
{stop, Reason, Reply, _NewState} ->
- file_reply(From, ReplyAs, Reply),
+ _ = file_reply(From, ReplyAs, Reply),
exit(Reason)
end;
{io_request, From, ReplyAs, Request} when is_pid(From) ->
case io_request(Request, State) of
{reply, Reply, NewState} ->
- io_reply(From, ReplyAs, Reply),
+ _ = io_reply(From, ReplyAs, Reply),
server_loop(NewState);
{error, Reply, NewState} ->
%% error is the same as reply, except that
%% it breaks the io_request_loop further down
- io_reply(From, ReplyAs, Reply),
+ _ = io_reply(From, ReplyAs, Reply),
server_loop(NewState);
{stop, Reason, Reply, _NewState} ->
- io_reply(From, ReplyAs, Reply),
+ _ = io_reply(From, ReplyAs, Reply),
exit(Reason)
end;
{'DOWN', Mref, _, _, Reason} ->
diff --git a/lib/kernel/src/file_server.erl b/lib/kernel/src/file_server.erl
index d036dbb516..eabf0401a3 100644
--- a/lib/kernel/src/file_server.erl
+++ b/lib/kernel/src/file_server.erl
@@ -78,7 +78,8 @@ init([]) ->
process_flag(trap_exit, true),
case ?PRIM_FILE:start() of
{ok, Handle} ->
- ets:new(?FILE_IO_SERVER_TABLE, [named_table]),
+ ?FILE_IO_SERVER_TABLE =
+ ets:new(?FILE_IO_SERVER_TABLE, [named_table]),
{ok, Handle};
{error, Reason} ->
{stop, Reason}
diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl
index 58d84ae924..adaa3159ec 100644
--- a/lib/kernel/src/gen_sctp.erl
+++ b/lib/kernel/src/gen_sctp.erl
@@ -36,7 +36,7 @@
-type assoc_id() :: term().
-type option() ::
- {active, true | false | once} |
+ {active, true | false | once | -32768..32767} |
{buffer, non_neg_integer()} |
{dontroute, boolean()} |
{high_msgq_watermark, pos_integer()} |
@@ -274,7 +274,7 @@ do_connect(S, Addr, Port, Opts, Timeout, ConnWait) when is_port(S), is_list(Opts
Mod:connect(S, IP, Port, Opts, ConnectTimer);
Error -> Error
after
- inet:stop_timer(Timer)
+ _ = inet:stop_timer(Timer)
end
catch
error:badarg ->
@@ -423,7 +423,11 @@ error_string(9) ->
error_string(10) ->
"Cookie Received While Shutting Down";
error_string(11) ->
+ "Restart of an Association with New Addresses";
+error_string(12) ->
"User Initiated Abort";
+error_string(13) ->
+ "Protocol Violation";
%% For more info on principal SCTP error codes: phone +44 7981131933
error_string(N) when is_integer(N) ->
unknown_error;
diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl
index a98ed4c238..bc8ffbe5e3 100644
--- a/lib/kernel/src/gen_tcp.erl
+++ b/lib/kernel/src/gen_tcp.erl
@@ -30,7 +30,7 @@
-include("file.hrl").
-type option() ::
- {active, true | false | once} |
+ {active, true | false | once | -32768..32767} |
{buffer, non_neg_integer()} |
{delay_send, boolean()} |
{deliver, port | term} |
@@ -139,7 +139,7 @@ connect(Address, Port, Opts) ->
connect(Address, Port, Opts, Time) ->
Timer = inet:start_timer(Time),
Res = (catch connect1(Address,Port,Opts,Timer)),
- inet:stop_timer(Timer),
+ _ = inet:stop_timer(Timer),
case Res of
{ok,S} -> {ok,S};
{error, einval} -> exit(badarg);
diff --git a/lib/kernel/src/gen_udp.erl b/lib/kernel/src/gen_udp.erl
index e82b11d2ef..70dceb3679 100644
--- a/lib/kernel/src/gen_udp.erl
+++ b/lib/kernel/src/gen_udp.erl
@@ -26,7 +26,7 @@
-include("inet_int.hrl").
-type option() ::
- {active, true | false | once} |
+ {active, true | false | once | -32768..32767} |
{add_membership, {inet:ip_address(), inet:ip_address()}} |
{broadcast, boolean()} |
{buffer, non_neg_integer()} |
diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl
index b24a9d5eac..ef878b8d0c 100644
--- a/lib/kernel/src/global.erl
+++ b/lib/kernel/src/global.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -2069,7 +2069,8 @@ random_sleep(Times) ->
case get(random_seed) of
undefined ->
{A1, A2, A3} = now(),
- random:seed(A1, A2, A3 + erlang:phash(node(), 100000));
+ _ = random:seed(A1, A2, A3 + erlang:phash(node(), 100000)),
+ ok;
_ -> ok
end,
%% First time 1/4 seconds, then doubling each time up to 8 seconds max.
diff --git a/lib/kernel/src/global_group.erl b/lib/kernel/src/global_group.erl
index 025a9b8a5b..da8b573749 100644
--- a/lib/kernel/src/global_group.erl
+++ b/lib/kernel/src/global_group.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -1149,9 +1149,14 @@ do_unlink(Pid, State) ->
%%%====================================================================================
%%% Send a nodeup/down messages to monitoring Pids in the own global group.
%%%====================================================================================
-send_monitor([P|T], M, no_conf) -> safesend_nc(P, M), send_monitor(T, M, no_conf);
-send_monitor([P|T], M, SyncState) -> safesend(P, M), send_monitor(T, M, SyncState);
-send_monitor([], _, _) -> ok.
+send_monitor([P|T], M, no_conf) ->
+ _ = safesend_nc(P, M),
+ send_monitor(T, M, no_conf);
+send_monitor([P|T], M, SyncState) ->
+ _ = safesend(P, M),
+ send_monitor(T, M, SyncState);
+send_monitor([], _, _) ->
+ ok.
safesend(Name, {Msg, Node}) when is_atom(Name) ->
case lists:member(Node, get_own_nodes()) of
diff --git a/lib/kernel/src/group.erl b/lib/kernel/src/group.erl
index ff835e1047..b36dbf33dd 100644
--- a/lib/kernel/src/group.erl
+++ b/lib/kernel/src/group.erl
@@ -309,15 +309,17 @@ io_requests([], Stat, _) ->
%% The ACK contains the return value.
io_reply(From, ReplyAs, Reply) ->
- From ! {io_reply,ReplyAs,Reply}.
+ From ! {io_reply,ReplyAs,Reply},
+ ok.
%% send_drv(Drv, Message)
%% send_drv_reqs(Drv, Requests)
send_drv(Drv, Msg) ->
- Drv ! {self(),Msg}.
+ Drv ! {self(),Msg},
+ ok.
-send_drv_reqs(_Drv, []) -> [];
+send_drv_reqs(_Drv, []) -> ok;
send_drv_reqs(Drv, Rs) ->
send_drv(Drv, {requests,Rs}).
diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl
index 87cb9d7f51..daed6dd488 100644
--- a/lib/kernel/src/heart.erl
+++ b/lib/kernel/src/heart.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -182,20 +182,24 @@ wait_ack(Port) ->
end.
loop(Parent, Port, Cmd) ->
- send_heart_beat(Port),
+ _ = send_heart_beat(Port),
receive
- {From, set_cmd, NewCmd} when length(NewCmd) < 2047 ->
- send_heart_cmd(Port, NewCmd),
- wait_ack(Port),
- From ! {heart, ok},
- loop(Parent, Port, NewCmd);
- {From, set_cmd, NewCmd} ->
- From ! {heart, {error, {bad_cmd, NewCmd}}},
- loop(Parent, Port, Cmd);
+ {From, set_cmd, NewCmd0} ->
+ Enc = file:native_name_encoding(),
+ case catch unicode:characters_to_binary(NewCmd0,Enc,Enc) of
+ NewCmd when is_binary(NewCmd), byte_size(NewCmd) < 2047 ->
+ _ = send_heart_cmd(Port, NewCmd),
+ _ = wait_ack(Port),
+ From ! {heart, ok},
+ loop(Parent, Port, NewCmd);
+ _ ->
+ From ! {heart, {error, {bad_cmd, NewCmd0}}},
+ loop(Parent, Port, Cmd)
+ end;
{From, clear_cmd} ->
From ! {heart, ok},
- send_heart_cmd(Port, ""),
- wait_ack(Port),
+ _ = send_heart_cmd(Port, ""),
+ _ = wait_ack(Port),
loop(Parent, Port, "");
{From, get_cmd} ->
From ! {heart, get_heart_cmd(Port)},
@@ -222,7 +226,7 @@ loop(Parent, Port, Cmd) ->
-spec no_reboot_shutdown(port()) -> no_return().
no_reboot_shutdown(Port) ->
- send_shutdown(Port),
+ _ = send_shutdown(Port),
receive
{'EXIT', Port, Reason} when Reason =/= badsig ->
exit(normal)
@@ -232,10 +236,10 @@ do_cycle_port_program(Caller, Parent, Port, Cmd) ->
unregister(?HEART_PORT_NAME),
case catch start_portprogram() of
{ok, NewPort} ->
- send_shutdown(Port),
+ _ = send_shutdown(Port),
receive
{'EXIT', Port, _Reason} ->
- send_heart_cmd(NewPort, Cmd),
+ _ = send_heart_cmd(NewPort, Cmd),
Caller ! {heart, ok},
loop(Parent, NewPort, Cmd)
after
@@ -243,7 +247,7 @@ do_cycle_port_program(Caller, Parent, Port, Cmd) ->
%% Huh! Two heart port programs running...
%% well, the old one has to be sick not to respond
%% so we'll settle for the new one...
- send_heart_cmd(NewPort, Cmd),
+ _ = send_heart_cmd(NewPort, Cmd),
Caller ! {heart, {error, stop_error}},
loop(Parent, NewPort, Cmd)
end;
diff --git a/lib/kernel/src/hipe_unified_loader.erl b/lib/kernel/src/hipe_unified_loader.erl
index e676ca997d..e111cb800e 100644
--- a/lib/kernel/src/hipe_unified_loader.erl
+++ b/lib/kernel/src/hipe_unified_loader.erl
@@ -85,7 +85,7 @@ chunk_name(Architecture) ->
%%========================================================================
-spec load_native_code(Mod, binary()) -> 'no_native' | {'module', Mod}
- when is_subtype(Mod, atom()).
+ when Mod :: atom().
%% @doc
%% Loads the native code of a module Mod.
%% Returns {module,Mod} on success (for compatibility with
@@ -148,8 +148,8 @@ version_check(Version, Mod) when is_atom(Mod) ->
%%========================================================================
--spec load_module(Mod, binary(), _) -> 'bad_crc' | {'module',Mod}
- when is_subtype(Mod,atom()).
+-spec load_module(Mod, binary(), _) -> 'bad_crc' | {'module', Mod}
+ when Mod :: atom().
load_module(Mod, Bin, Beam) ->
erlang:system_flag(multi_scheduling, block),
try
@@ -169,8 +169,8 @@ load_module(Mod, Bin, Beam, OldReferencesToPatch) ->
%%========================================================================
--spec load(Mod, binary()) -> 'bad_crc' | {'module',Mod}
- when is_subtype(Mod,atom()).
+-spec load(Mod, binary()) -> 'bad_crc' | {'module', Mod} when Mod :: atom().
+
load(Mod, Bin) ->
erlang:system_flag(multi_scheduling, block),
try
@@ -204,15 +204,17 @@ load_common(Mod, Bin, Beam, OldReferencesToPatch) ->
bad_crc;
true ->
%% Create data segment
- {ConstAddr,ConstMap2} = create_data_segment(ConstAlign, ConstSize, ConstMap),
+ {ConstAddr,ConstMap2} =
+ create_data_segment(ConstAlign, ConstSize, ConstMap),
%% Find callees for which we may need trampolines.
CalleeMFAs = find_callee_mfas(Refs),
%% Write the code to memory.
- {CodeAddress,Trampolines} = enter_code(CodeSize, CodeBinary, CalleeMFAs, Mod, Beam),
+ {CodeAddress,Trampolines} =
+ enter_code(CodeSize, CodeBinary, CalleeMFAs, Mod, Beam),
%% Construct CalleeMFA-to-trampoline mapping.
TrampolineMap = mk_trampoline_map(CalleeMFAs, Trampolines),
%% Patch references to code labels in data seg.
- patch_consts(LabelMap, ConstAddr, CodeAddress),
+ ok = patch_consts(LabelMap, ConstAddr, CodeAddress),
%% Find out which functions are being loaded (and where).
%% Note: Addresses are sorted descending.
{MFAs,Addresses} = exports(ExportMap, CodeAddress),
@@ -221,19 +223,21 @@ load_common(Mod, Bin, Beam, OldReferencesToPatch) ->
ok = remove_refs_from(MFAs),
%% Patch all dynamic references in the code.
%% Function calls, Atoms, Constants, System calls
- patch(Refs, CodeAddress, ConstMap2, Addresses, TrampolineMap),
+ ok = patch(Refs, CodeAddress, ConstMap2, Addresses, TrampolineMap),
%% Tell the system where the loaded funs are.
%% (patches the BEAM code to redirect to native.)
case Beam of
[] ->
- export_funs(Addresses);
+ export_funs(Addresses),
+ ok;
BeamBinary when is_binary(BeamBinary) ->
%% Find all closures in the code.
ClosurePatches = find_closure_patches(Refs),
AddressesOfClosuresToPatch =
calculate_addresses(ClosurePatches, CodeAddress, Addresses),
export_funs(Addresses),
- export_funs(Mod, BeamBinary, Addresses, AddressesOfClosuresToPatch)
+ export_funs(Mod, BeamBinary, Addresses, AddressesOfClosuresToPatch),
+ ok
end,
%% Redirect references to the old module to the new module's BEAM stub.
patch_to_emu_step2(OldReferencesToPatch),
@@ -322,7 +326,7 @@ trampoline_map_get(MFA, Map) -> gb_trees:get(MFA, Map).
trampoline_map_lookup(_, []) -> []; % archs not using trampolines
trampoline_map_lookup(Primop, Map) ->
case gb_trees:lookup(Primop, Map) of
- {value,X} -> X;
+ {value, X} -> X;
_ -> []
end.
@@ -369,7 +373,7 @@ offsets_to_addresses(Os, Base) ->
find_closure_patches([{Type,Refs} | Rest]) ->
case ?EXT2PATCH_TYPE(Type) of
load_address ->
- find_closure_refs(Refs,Rest);
+ find_closure_refs(Refs, Rest);
_ ->
find_closure_patches(Rest)
end;
@@ -404,16 +408,17 @@ export_funs([FunDef | Addresses]) ->
hipe_bifs:set_native_address(MFA, Address, IsClosure),
export_funs(Addresses);
export_funs([]) ->
- true.
+ ok.
export_funs(Mod, Beam, Addresses, ClosuresToPatch) ->
- Fs = [{F,A,Address} || #fundef{address=Address, mfa={_M,F,A}} <- Addresses],
- code:make_stub_module(Mod, Beam, {Fs,ClosuresToPatch}).
+ Fs = [{F,A,Address} || #fundef{address=Address, mfa={_M,F,A}} <- Addresses],
+ Mod = code:make_stub_module(Mod, Beam, {Fs,ClosuresToPatch}),
+ ok.
%%========================================================================
%% Patching
%% @spec patch(refs(), BaseAddress::integer(), ConstAndZone::term(),
-%% Addresses::term(), TrampolineMap::term()) -> term()
+%% Addresses::term(), TrampolineMap::term()) -> 'ok'.
%% @type refs()=[{RefType::integer(), Reflist::reflist()} | refs()]
%%
%% @type reflist()= [{Data::term(), Offsets::offests()}|reflist()]
@@ -426,7 +431,7 @@ export_funs(Mod, Beam, Addresses, ClosuresToPatch) ->
%%
patch([{Type,SortedRefs}|Rest], CodeAddress, ConstMap2, Addresses, TrampolineMap) ->
- ?debug_msg("Patching ~w at [~w+offset] with ~w\n",
+ ?debug_msg("Patching ~w at [~w+offset] with ~w\n",
[Type,CodeAddress,SortedRefs]),
case ?EXT2PATCH_TYPE(Type) of
call_local ->
@@ -437,7 +442,7 @@ patch([{Type,SortedRefs}|Rest], CodeAddress, ConstMap2, Addresses, TrampolineMap
patch_all(Other, SortedRefs, CodeAddress, {ConstMap2,CodeAddress}, Addresses)
end,
patch(Rest, CodeAddress, ConstMap2, Addresses, TrampolineMap);
-patch([], _, _, _, _) -> true.
+patch([], _, _, _, _) -> ok.
%%----------------------------------------------------------------
%% Handle a 'call_local' or 'call_remote' patch.
@@ -459,14 +464,14 @@ patch_call([{DestMFA,Offsets}|SortedRefs], BaseAddress, Addresses, RemoteOrLocal
end,
patch_call(SortedRefs, BaseAddress, Addresses, RemoteOrLocal, TrampolineMap);
patch_call([], _, _, _, _) ->
- true.
+ ok.
patch_bif_call_list([Offset|Offsets], BaseAddress, BifAddress, Trampoline) ->
CallAddress = BaseAddress+Offset,
?ASSERT(assert_local_patch(CallAddress)),
patch_call_insn(CallAddress, BifAddress, Trampoline),
patch_bif_call_list(Offsets, BaseAddress, BifAddress, Trampoline);
-patch_bif_call_list([], _, _, _) -> [].
+patch_bif_call_list([], _, _, _) -> ok.
patch_mfa_call_list([Offset|Offsets], BaseAddress, DestMFA, DestAddress, Addresses, RemoteOrLocal, Trampoline) ->
CallAddress = BaseAddress+Offset,
@@ -474,7 +479,7 @@ patch_mfa_call_list([Offset|Offsets], BaseAddress, DestMFA, DestAddress, Address
?ASSERT(assert_local_patch(CallAddress)),
patch_call_insn(CallAddress, DestAddress, Trampoline),
patch_mfa_call_list(Offsets, BaseAddress, DestMFA, DestAddress, Addresses, RemoteOrLocal, Trampoline);
-patch_mfa_call_list([], _, _, _, _, _, _) -> [].
+patch_mfa_call_list([], _, _, _, _, _, _) -> ok.
patch_call_insn(CallAddress, DestAddress, Trampoline) ->
%% This assertion is false when we're called from redirect/2.
@@ -487,7 +492,7 @@ patch_call_insn(CallAddress, DestAddress, Trampoline) ->
patch_all(Type, [{Dest,Offsets}|Rest], BaseAddress, ConstAndZone, Addresses)->
patch_all_offsets(Type, Dest, Offsets, BaseAddress, ConstAndZone, Addresses),
patch_all(Type, Rest, BaseAddress, ConstAndZone, Addresses);
-patch_all(_, [], _, _, _) -> true.
+patch_all(_, [], _, _, _) -> ok.
patch_all_offsets(Type, Data, [Offset|Offsets], BaseAddress,
ConstAndZone, Addresses) ->
@@ -497,7 +502,7 @@ patch_all_offsets(Type, Data, [Offset|Offsets], BaseAddress,
patch_offset(Type, Data, Address, ConstAndZone, Addresses),
?debug_msg("Patching done\n",[]),
patch_all_offsets(Type, Data, Offsets, BaseAddress, ConstAndZone, Addresses);
-patch_all_offsets(_, _, [], _, _, _) -> true.
+patch_all_offsets(_, _, [], _, _, _) -> ok.
%%----------------------------------------------------------------
%% Handle any patch type except 'call_local' or 'call_remote'.
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl
index 3ea530a366..41d422d7d4 100644
--- a/lib/kernel/src/inet.erl
+++ b/lib/kernel/src/inet.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -24,6 +24,7 @@
%% socket
-export([peername/1, sockname/1, port/1, send/2,
+ peernames/1, peernames/2, socknames/1, socknames/2,
setopts/2, getopts/2,
getifaddrs/0, getifaddrs/1,
getif/1, getif/0, getiflist/0, getiflist/1,
@@ -32,7 +33,7 @@
ip/1, stats/0, options/0,
pushf/3, popf/1, close/1, gethostname/0, gethostname/1,
parse_ipv4_address/1, parse_ipv6_address/1, parse_ipv4strict_address/1,
- parse_ipv6strict_address/1, parse_address/1, parse_strict_address/1]).
+ parse_ipv6strict_address/1, parse_address/1, parse_strict_address/1, ntoa/1]).
-export([connect_options/2, listen_options/2, udp_options/2, sctp_options/2]).
@@ -120,6 +121,17 @@
'addr' | 'broadaddr' | 'dstaddr' |
'mtu' | 'netmask' | 'flags' |'hwaddr'.
+-type if_getopt_result() ::
+ {'addr', ip_address()} |
+ {'broadaddr', ip_address()} |
+ {'dstaddr', ip_address()} |
+ {'mtu', non_neg_integer()} |
+ {'netmask', ip_address()} |
+ {'flags', ['up' | 'down' | 'broadcast' | 'no_broadcast' |
+ 'pointtopoint' | 'no_pointtopoint' |
+ 'running' | 'multicast' | 'loopback']} |
+ {'hwaddr', ether_address()}.
+
-type address_family() :: 'inet' | 'inet6'.
-type socket_protocol() :: 'tcp' | 'udp' | 'sctp'.
-type socket_type() :: 'stream' | 'dgram' | 'seqpacket'.
@@ -146,6 +158,7 @@ close(Socket) ->
ok
end.
+
-spec peername(Socket) -> {ok, {Address, Port}} | {error, posix()} when
Socket :: socket(),
Address :: ip_address(),
@@ -162,6 +175,24 @@ setpeername(Socket, {IP,Port}) ->
setpeername(Socket, undefined) ->
prim_inet:setpeername(Socket, undefined).
+-spec peernames(Socket) -> {ok, [{Address, Port}]} | {error, posix()} when
+ Socket :: socket(),
+ Address :: ip_address(),
+ Port :: non_neg_integer().
+
+peernames(Socket) ->
+ prim_inet:peernames(Socket).
+
+-spec peernames(Socket, Assoc) ->
+ {ok, [{Address, Port}]} | {error, posix()} when
+ Socket :: socket(),
+ Assoc :: #sctp_assoc_change{} | gen_sctp:assoc_id(),
+ Address :: ip_address(),
+ Port :: non_neg_integer().
+
+peernames(Socket, Assoc) ->
+ prim_inet:peernames(Socket, Assoc).
+
-spec sockname(Socket) -> {ok, {Address, Port}} | {error, posix()} when
Socket :: socket(),
@@ -179,6 +210,25 @@ setsockname(Socket, {IP,Port}) ->
setsockname(Socket, undefined) ->
prim_inet:setsockname(Socket, undefined).
+-spec socknames(Socket) -> {ok, [{Address, Port}]} | {error, posix()} when
+ Socket :: socket(),
+ Address :: ip_address(),
+ Port :: non_neg_integer().
+
+socknames(Socket) ->
+ prim_inet:socknames(Socket).
+
+-spec socknames(Socket, Assoc) ->
+ {ok, [{Address, Port}]} | {error, posix()} when
+ Socket :: socket(),
+ Assoc :: #sctp_assoc_change{} | gen_sctp:assoc_id(),
+ Address :: ip_address(),
+ Port :: non_neg_integer().
+
+socknames(Socket, Assoc) ->
+ prim_inet:socknames(Socket, Assoc).
+
+
-spec port(Socket) -> {'ok', Port} | {'error', any()} when
Socket :: socket(),
Port :: port_number().
@@ -200,7 +250,14 @@ send(Socket, Packet) ->
Options :: [socket_setopt()].
setopts(Socket, Opts) ->
- prim_inet:setopts(Socket, Opts).
+ SocketOpts =
+ [case Opt of
+ {netns,NS} ->
+ {netns,filename2binary(NS)};
+ _ ->
+ Opt
+ end || Opt <- Opts],
+ prim_inet:setopts(Socket, SocketOpts).
-spec getopts(Socket, Options) ->
{'ok', OptionValues} | {'error', posix()} when
@@ -209,7 +266,18 @@ setopts(Socket, Opts) ->
OptionValues :: [socket_setopt()].
getopts(Socket, Opts) ->
- prim_inet:getopts(Socket, Opts).
+ case prim_inet:getopts(Socket, Opts) of
+ {ok,OptionValues} ->
+ {ok,
+ [case OptionValue of
+ {netns,Bin} ->
+ {netns,binary2filename(Bin)};
+ _ ->
+ OptionValue
+ end || OptionValue <- OptionValues]};
+ Other ->
+ Other
+ end.
-spec getifaddrs(Socket :: socket()) ->
{'ok', [string()]} | {'error', posix()}.
@@ -248,13 +316,13 @@ getiflist() ->
-spec ifget(Socket :: socket(),
Name :: string() | atom(),
Opts :: [if_getopt()]) ->
- {'ok', [if_setopt()]} | {'error', posix()}.
+ {'ok', [if_getopt_result()]} | {'error', posix()}.
ifget(Socket, Name, Opts) ->
prim_inet:ifget(Socket, Name, Opts).
-spec ifget(Name :: string() | atom(), Opts :: [if_getopt()]) ->
- {'ok', [if_setopt()]} | {'error', posix()}.
+ {'ok', [if_getopt_result()]} | {'error', posix()}.
ifget(Name, Opts) ->
withsocket(fun(S) -> prim_inet:ifget(S, Name, Opts) end).
@@ -389,7 +457,7 @@ gethostbyname(Name,Family) ->
gethostbyname(Name,Family,Timeout) ->
Timer = start_timer(Timeout),
Res = gethostbyname_tm(Name,Family,Timer),
- stop_timer(Timer),
+ _ = stop_timer(Timer),
Res.
gethostbyname_tm(Name,Family,Timer) ->
@@ -420,7 +488,7 @@ gethostbyaddr(Address) ->
gethostbyaddr(Address,Timeout) ->
Timer = start_timer(Timeout),
Res = gethostbyaddr_tm(Address, Timer),
- stop_timer(Timer),
+ _ = stop_timer(Timer),
Res.
gethostbyaddr_tm(Address,Timer) ->
@@ -475,7 +543,7 @@ getaddr(Address, Family) ->
getaddr(Address, Family, Timeout) ->
Timer = start_timer(Timeout),
Res = getaddr_tm(Address, Family, Timer),
- stop_timer(Timer),
+ _ = stop_timer(Timer),
Res.
getaddr_tm(Address, Family, Timer) ->
@@ -501,7 +569,7 @@ getaddrs(Address, Family) ->
getaddrs(Address, Family, Timeout) ->
Timer = start_timer(Timeout),
Res = getaddrs_tm(Address, Family, Timer),
- stop_timer(Timer),
+ _ = stop_timer(Timer),
Res.
-spec getservbyport(Port :: port_number(), Protocol :: atom() | string()) ->
@@ -529,6 +597,12 @@ getservbyname(Name, Protocol) when is_atom(Name) ->
Error -> Error
end.
+-spec ntoa(IpAddress) -> Address | {error, einval} when
+ Address :: string(),
+ IpAddress :: ip_address().
+ntoa(Addr) ->
+ inet_parse:ntoa(Addr).
+
-spec parse_ipv4_address(Address) ->
{ok, IPv4Address} | {error, einval} when
Address :: string(),
@@ -634,6 +708,17 @@ con_opt([Opt | Opts], R, As) ->
{tcp_module,_} -> con_opt(Opts, R, As);
inet -> con_opt(Opts, R, As);
inet6 -> con_opt(Opts, R, As);
+ {netns,NS} ->
+ BinNS = filename2binary(NS),
+ case prim_inet:is_sockopt_val(netns, BinNS) of
+ true ->
+ con_opt(Opts, R#connect_opts { fd = [{netns,BinNS}] }, As);
+ false ->
+ {error, badarg}
+ end;
+ {active,N} when is_integer(N), N < 32768, N >= -32768 ->
+ NOpts = lists:keydelete(active, 1, R#connect_opts.opts),
+ con_opt(Opts, R#connect_opts { opts = [{active,N}|NOpts] }, As);
{Name,Val} when is_atom(Name) -> con_add(Name, Val, R, Opts, As);
_ -> {error, badarg}
end;
@@ -692,6 +777,17 @@ list_opt([Opt | Opts], R, As) ->
{tcp_module,_} -> list_opt(Opts, R, As);
inet -> list_opt(Opts, R, As);
inet6 -> list_opt(Opts, R, As);
+ {netns,NS} ->
+ BinNS = filename2binary(NS),
+ case prim_inet:is_sockopt_val(netns, BinNS) of
+ true ->
+ list_opt(Opts, R#listen_opts { fd = [{netns,BinNS}] }, As);
+ false ->
+ {error, badarg}
+ end;
+ {active,N} when is_integer(N), N < 32768, N >= -32768 ->
+ NOpts = lists:keydelete(active, 1, R#listen_opts.opts),
+ list_opt(Opts, R#listen_opts { opts = [{active,N}|NOpts] }, As);
{Name,Val} when is_atom(Name) -> list_add(Name, Val, R, Opts, As);
_ -> {error, badarg}
end;
@@ -738,6 +834,17 @@ udp_opt([Opt | Opts], R, As) ->
{udp_module,_} -> udp_opt(Opts, R, As);
inet -> udp_opt(Opts, R, As);
inet6 -> udp_opt(Opts, R, As);
+ {netns,NS} ->
+ BinNS = filename2binary(NS),
+ case prim_inet:is_sockopt_val(netns, BinNS) of
+ true ->
+ list_opt(Opts, R#udp_opts { fd = [{netns,BinNS}] }, As);
+ false ->
+ {error, badarg}
+ end;
+ {active,N} when is_integer(N), N < 32768, N >= -32768 ->
+ NOpts = lists:keydelete(active, 1, R#udp_opts.opts),
+ udp_opt(Opts, R#udp_opts { opts = [{active,N}|NOpts] }, As);
{Name,Val} when is_atom(Name) -> udp_add(Name, Val, R, Opts, As);
_ -> {error, badarg}
end;
@@ -756,7 +863,7 @@ udp_add(Name, Val, R, Opts, As) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Currently supported options include:
% (*) {mode, list|binary} or just list|binary
-% (*) {active, true|false|once}
+% (*) {active, true|false|once|N}
% (*) {sctp_module, inet_sctp|inet6_sctp} or just inet|inet6
% (*) options set via setsockopt.
% The full list is below in sctp_options/0 .
@@ -807,6 +914,20 @@ sctp_opt([Opt|Opts], Mod, R, As) ->
{sctp_module,_} -> sctp_opt (Opts, Mod, R, As); % Done with
inet -> sctp_opt (Opts, Mod, R, As); % Done with
inet6 -> sctp_opt (Opts, Mod, R, As); % Done with
+ {netns,NS} ->
+ BinNS = filename2binary(NS),
+ case prim_inet:is_sockopt_val(netns, BinNS) of
+ true ->
+ sctp_opt(
+ Opts, Mod,
+ R#sctp_opts { fd = [{netns,BinNS}] },
+ As);
+ false ->
+ {error, badarg}
+ end;
+ {active,N} when is_integer(N), N < 32768, N >= -32768 ->
+ NOpts = lists:keydelete(active, 1, R#sctp_opts.opts),
+ sctp_opt(Opts, Mod, R#sctp_opts { opts = [{active,N}|NOpts] }, As);
{Name,Val} -> sctp_opt (Opts, Mod, R, As, Name, Val);
_ -> {error,badarg}
end;
@@ -851,6 +972,39 @@ add_opt(Name, Val, Opts, As) ->
end.
+%% Passthrough all unknown - catch type errors later
+filename2binary(List) when is_list(List) ->
+ OutEncoding = file:native_name_encoding(),
+ try unicode:characters_to_binary(List, unicode, OutEncoding) of
+ Bin when is_binary(Bin) ->
+ Bin;
+ _ ->
+ List
+ catch
+ error:badarg ->
+ List
+ end;
+filename2binary(Bin) ->
+ Bin.
+
+binary2filename(Bin) ->
+ InEncoding = file:native_name_encoding(),
+ case unicode:characters_to_list(Bin, InEncoding) of
+ Filename when is_list(Filename) ->
+ Filename;
+ _ ->
+ %% For getopt/setopt of netns this should only happen if
+ %% a binary with wrong encoding was used when setting the
+ %% option, hence the user shall eat his/her own medicine.
+ %%
+ %% I.e passthrough here too for now.
+ %% Future usecases will most probably not want this,
+ %% rather Unicode error or warning
+ %% depending on emulator flag instead.
+ Bin
+ end.
+
+
translate_ip(any, inet) -> {0,0,0,0};
translate_ip(loopback, inet) -> {127,0,0,1};
translate_ip(any, inet6) -> {0,0,0,0,0,0,0,0};
@@ -1063,7 +1217,7 @@ gethostbyaddr_tm_native(Addr, Timer, Opts) ->
Result -> Result
end.
--spec open(Fd :: integer(),
+-spec open(Fd_or_OpenOpts :: integer() | list(),
Addr :: ip_address(),
Port :: port_number(),
Opts :: [socket_setopt()],
@@ -1073,8 +1227,14 @@ gethostbyaddr_tm_native(Addr, Timer, Opts) ->
Module :: atom()) ->
{'ok', socket()} | {'error', posix()}.
-open(Fd, Addr, Port, Opts, Protocol, Family, Type, Module) when Fd < 0 ->
- case prim_inet:open(Protocol, Family, Type) of
+open(FdO, Addr, Port, Opts, Protocol, Family, Type, Module)
+ when is_integer(FdO), FdO < 0;
+ is_list(FdO) ->
+ OpenOpts =
+ if is_list(FdO) -> FdO;
+ true -> []
+ end,
+ case prim_inet:open(Protocol, Family, Type, OpenOpts) of
{ok,S} ->
case prim_inet:setopts(S, Opts) of
ok ->
@@ -1097,7 +1257,8 @@ open(Fd, Addr, Port, Opts, Protocol, Family, Type, Module) when Fd < 0 ->
Error ->
Error
end;
-open(Fd, _Addr, _Port, Opts, Protocol, Family, Type, Module) ->
+open(Fd, _Addr, _Port, Opts, Protocol, Family, Type, Module)
+ when is_integer(Fd) ->
fdopen(Fd, Opts, Protocol, Family, Type, Module).
bindx(S, [Addr], Port0) ->
@@ -1345,7 +1506,7 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
{ok, A0} ->
case A0 of
false -> ok;
- _ -> prim_inet:setopt(S, active, false)
+ _ -> ok = prim_inet:setopt(S, active, false)
end,
case tcp_sync_input(S, NewOwner, false) of
true -> %% socket already closed,
@@ -1356,7 +1517,7 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
unlink(S), %% unlink from port
case A0 of
false -> ok;
- _ -> prim_inet:setopt(S, active, A0)
+ _ -> ok = prim_inet:setopt(S, active, A0)
end,
ok
catch
@@ -1399,13 +1560,12 @@ udp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
{error, not_owner};
_ ->
{ok, A0} = prim_inet:getopt(S, active),
- prim_inet:setopt(S, active, false),
+ ok = prim_inet:setopt(S, active, false),
udp_sync_input(S, NewOwner),
try erlang:port_connect(S, NewOwner) of
true ->
unlink(S),
- prim_inet:setopt(S, active, A0),
- ok
+ ok = prim_inet:setopt(S, active, A0)
catch
error:Reason ->
{error, Reason}
diff --git a/lib/kernel/src/inet6_tcp_dist.erl b/lib/kernel/src/inet6_tcp_dist.erl
index 2cb0e10c87..459fdc2ad5 100644
--- a/lib/kernel/src/inet6_tcp_dist.erl
+++ b/lib/kernel/src/inet6_tcp_dist.erl
@@ -92,7 +92,7 @@ accept_loop(Kernel, Listen) ->
case inet6_tcp:accept(Listen) of
{ok, Socket} ->
Kernel ! {accept,self(),Socket,inet6,tcp},
- controller(Kernel, Socket),
+ _ = controller(Kernel, Socket),
accept_loop(Kernel, Listen);
Error ->
exit(Error)
diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl
index a7679c531b..2ebdc0f554 100644
--- a/lib/kernel/src/inet_db.erl
+++ b/lib/kernel/src/inet_db.erl
@@ -1117,7 +1117,7 @@ handle_call(Request, From, #state{db=Db}=State) ->
{set_cache_refresh, Time} when is_integer(Time), Time > 0 ->
Time1 = ((Time+999) div 1000)*1000, %% round up
ets:insert(Db, {cache_refresh_interval, Time1}),
- stop_timer(State#state.cache_timer),
+ _ = stop_timer(State#state.cache_timer),
{reply, ok, State#state{cache_timer = init_timer()}};
clear_hosts ->
@@ -1131,7 +1131,7 @@ handle_call(Request, From, #state{db=Db}=State) ->
reset ->
reset_db(Db),
- stop_timer(State#state.cache_timer),
+ _ = stop_timer(State#state.cache_timer),
{reply, ok, State#state{cache_timer = init_timer()}};
{add_rc_list, List} ->
@@ -1181,7 +1181,7 @@ handle_info(_Info, State) ->
-spec terminate(term(), state()) -> 'ok'.
terminate(_Reason, State) ->
- stop_timer(State#state.cache_timer),
+ _ = stop_timer(State#state.cache_timer),
ok.
%%%----------------------------------------------------------------------
@@ -1240,8 +1240,9 @@ do_add_host(Byname, Byaddr, Names, Type, IP) ->
ok.
do_del_host(Byname, Byaddr, IP) ->
- [ets:delete_object(Byname, {tolower(Name),Type,Addr}) ||
- {Name,Type,Addr} <- ets:lookup(Byaddr, IP)],
+ _ =
+ [ets:delete_object(Byname, {tolower(Name),Type,Addr}) ||
+ {Name,Type,Addr} <- ets:lookup(Byaddr, IP)],
ets:delete(Byaddr, IP),
ok.
diff --git a/lib/kernel/src/inet_gethost_native.erl b/lib/kernel/src/inet_gethost_native.erl
index 65d4c84e3b..4320987078 100644
--- a/lib/kernel/src/inet_gethost_native.erl
+++ b/lib/kernel/src/inet_gethost_native.erl
@@ -237,7 +237,7 @@ handle_message({Port, {data, Data}}, State = #state{port = Port}) ->
State;
Req ->
lists:foreach(fun({P,R,TR}) ->
- ?CANCEL_TIMER(TR),
+ _= ?CANCEL_TIMER(TR),
P ! {R,
{ok,
BinReply}}
@@ -276,7 +276,7 @@ handle_message({timeout, Pid, RID}, State) ->
{last, {LP,LR,_}} ->
LP ! {LR, {error,timeout}},
%% Remove the whole request structure...
- pick_request(State, RID),
+ _ = pick_request(State, RID),
%% Also cancel the request to the port program...
(catch port_command(State#state.port,
<<RID:32,?OP_CANCEL_REQUEST>>))
@@ -517,7 +517,7 @@ do_start(Sup, C) ->
{error, {{already_started, Pid}, _Child}} when is_pid(Pid) ->
ok;
{error, already_present} ->
- supervisor:delete_child(Sup, Child),
+ _ = supervisor:delete_child(Sup, Child),
do_start(Sup, C)
end.
diff --git a/lib/kernel/src/inet_int.hrl b/lib/kernel/src/inet_int.hrl
index 67a99913a1..889b596a22 100644
--- a/lib/kernel/src/inet_int.hrl
+++ b/lib/kernel/src/inet_int.hrl
@@ -46,6 +46,7 @@
-define(INET_PASSIVE, 0).
-define(INET_ACTIVE, 1).
-define(INET_ONCE, 2). % Active once then passive
+-define(INET_MULTI, 3). % Active N then passive
%% state codes (getstatus, INET_REQ_GETSTATUS)
-define(INET_F_OPEN, 16#0001).
@@ -86,6 +87,8 @@
-define(INET_REQ_ACCEPT, 26).
-define(INET_REQ_LISTEN, 27).
-define(INET_REQ_IGNOREFD, 28).
+-define(INET_REQ_GETLADDRS, 29).
+-define(INET_REQ_GETPADDRS, 30).
%% TCP requests
%%-define(TCP_REQ_ACCEPT, 40). MOVED
@@ -143,6 +146,7 @@
-define(INET_LOPT_TCP_SEND_TIMEOUT_CLOSE, 35).
-define(INET_LOPT_MSGQ_HIWTRMRK, 36).
-define(INET_LOPT_MSGQ_LOWTRMRK, 37).
+-define(INET_LOPT_NETNS, 38).
% Specific SCTP options: separate range:
-define(SCTP_OPT_RTOINFO, 100).
-define(SCTP_OPT_ASSOCINFO, 101).
diff --git a/lib/kernel/src/inet_parse.erl b/lib/kernel/src/inet_parse.erl
index 619c78a6ca..a88c94a453 100644
--- a/lib/kernel/src/inet_parse.erl
+++ b/lib/kernel/src/inet_parse.erl
@@ -288,7 +288,7 @@ parse_file(_, File, Fn) ->
case file:open(File, [read]) of
{ok, Fd} ->
Result = parse_fd(File,Fd, 1, Fn, []),
- file:close(Fd),
+ _ = file:close(Fd),
Result;
Error -> Error
end.
@@ -722,7 +722,9 @@ ntoa({0,0,0,0,0,16#ffff,A,B}) ->
"::FFFF:" ++ dig_to_dec(A) ++ "." ++ dig_to_dec(B);
ntoa({_,_,_,_,_,_,_,_}=T) ->
%% Find longest sequence of zeros, at least 2, to replace with "::"
- ntoa(tuple_to_list(T), []).
+ ntoa(tuple_to_list(T), []);
+ntoa(_) ->
+ {error, einval}.
%% Find first double zero
ntoa([], R) ->
diff --git a/lib/kernel/src/inet_res.erl b/lib/kernel/src/inet_res.erl
index 94a9f7c64d..6037da1d22 100644
--- a/lib/kernel/src/inet_res.erl
+++ b/lib/kernel/src/inet_res.erl
@@ -139,7 +139,7 @@ resolve(Name, Class, Type, Opts, Timeout) ->
{ok, Nm} ->
Timer = inet:start_timer(Timeout),
Res = res_query(Nm, Class, Type, Opts, Timer),
- inet:stop_timer(Timer),
+ _ = inet:stop_timer(Timer),
Res;
Error ->
Error
@@ -339,7 +339,7 @@ gethostbyaddr(IP) -> gethostbyaddr_tm(IP,false).
gethostbyaddr(IP,Timeout) ->
Timer = inet:start_timer(Timeout),
Res = gethostbyaddr_tm(IP,Timer),
- inet:stop_timer(Timer),
+ _ = inet:stop_timer(Timer),
Res.
gethostbyaddr_tm({A,B,C,D} = IP, Timer) when ?ip(A,B,C,D) ->
@@ -424,7 +424,7 @@ gethostbyname(Name,Family) ->
gethostbyname(Name,Family,Timeout) ->
Timer = inet:start_timer(Timeout),
Res = gethostbyname_tm(Name,Family,Timer),
- inet:stop_timer(Timer),
+ _ = inet:stop_timer(Timer),
Res.
gethostbyname_tm(Name,inet,Timer) ->
@@ -483,7 +483,7 @@ getbyname(Name, Type) ->
getbyname(Name, Type, Timeout) ->
Timer = inet:start_timer(Timeout),
Res = getbyname_tm(Name, Type, Timer),
- inet:stop_timer(Timer),
+ _ = inet:stop_timer(Timer),
Res.
getbyname_tm(Name, Type, Timer) when is_list(Name) ->
@@ -921,18 +921,25 @@ query_tcp(Timeout, Id, Buffer, IP, Port, Verbose) ->
[{active,false},{packet,2},binary,Family],
Timeout) of
{ok, S} ->
- gen_tcp:send(S, Buffer),
- case gen_tcp:recv(S, 0, Timeout) of
- {ok, Answer} ->
- gen_tcp:close(S),
- case decode_answer(Answer, Id, Verbose) of
- {ok, _} = OK -> OK;
- {error, badid} -> {error, servfail};
- Error -> Error
+ case gen_tcp:send(S, Buffer) of
+ ok ->
+ case gen_tcp:recv(S, 0, Timeout) of
+ {ok, Answer} ->
+ gen_tcp:close(S),
+ case decode_answer(Answer, Id, Verbose) of
+ {ok, _} = OK -> OK;
+ {error, badid} -> {error, servfail};
+ Error -> Error
+ end;
+ Error ->
+ gen_tcp:close(S),
+ ?verbose(Verbose, "TCP server recv error: ~p\n",
+ [Error]),
+ Error
end;
Error ->
gen_tcp:close(S),
- ?verbose(Verbose, "TCP server recv error: ~p\n",
+ ?verbose(Verbose, "TCP server send error: ~p\n",
[Error]),
Error
end;
diff --git a/lib/kernel/src/inet_sctp.erl b/lib/kernel/src/inet_sctp.erl
index 2d799d79fa..93528d305d 100644
--- a/lib/kernel/src/inet_sctp.erl
+++ b/lib/kernel/src/inet_sctp.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -135,7 +135,7 @@ connect_get_assoc(S, Addr, Port, Active, Timer) ->
{sctp,S,Addr,Port,{_,#sctp_assoc_change{state=St}=Ev}} ->
case Active of
once ->
- prim_inet:setopt(S, active, once);
+ ok = prim_inet:setopt(S, active, once);
_ -> ok
end,
if St =:= comm_up ->
diff --git a/lib/kernel/src/inet_tcp_dist.erl b/lib/kernel/src/inet_tcp_dist.erl
index 8005eff58c..63f236b069 100644
--- a/lib/kernel/src/inet_tcp_dist.erl
+++ b/lib/kernel/src/inet_tcp_dist.erl
@@ -119,7 +119,7 @@ accept_loop(Kernel, Listen) ->
case inet_tcp:accept(Listen) of
{ok, Socket} ->
Kernel ! {accept,self(),Socket,inet,tcp},
- controller(Kernel, Socket),
+ _ = controller(Kernel, Socket),
accept_loop(Kernel, Listen);
Error ->
exit(Error)
diff --git a/lib/kernel/src/kernel.appup.src b/lib/kernel/src/kernel.appup.src
index 54628800a8..f8f4cc1ec2 100644
--- a/lib/kernel/src/kernel.appup.src
+++ b/lib/kernel/src/kernel.appup.src
@@ -1,7 +1,7 @@
%% -*- erlang -*-
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -16,12 +16,10 @@
%%
%% %CopyrightEnd%
{"%VSN%",
- %% Up from - max two major revisions back
- [{<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R16
- {<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15
- {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}],%% R14
- %% Down to - max two major revisions back
- [{<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R16
- {<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15
- {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}] %% R14
+ %% Up from - max one major revision back
+ [{<<"3\\.0(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R17
+ {<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}],%% R16
+ %% Down to - max one major revision back
+ [{<<"3\\.0(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R17
+ {<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}] %% R16
}.
diff --git a/lib/kernel/src/kernel.erl b/lib/kernel/src/kernel.erl
index 1e07620a3e..ecdb32424a 100644
--- a/lib/kernel/src/kernel.erl
+++ b/lib/kernel/src/kernel.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -32,8 +32,13 @@ start(_, []) ->
case supervisor:start_link({local, kernel_sup}, kernel, []) of
{ok, Pid} ->
Type = get_error_logger_type(),
- error_logger:swap_handler(Type),
- {ok, Pid, []};
+ case error_logger:swap_handler(Type) of
+ ok -> {ok, Pid, []};
+ Error ->
+ %% Not necessary since the node will crash anyway:
+ exit(Pid, shutdown),
+ Error
+ end;
Error -> Error
end.
diff --git a/lib/kernel/src/kernel_config.erl b/lib/kernel/src/kernel_config.erl
index 48141cfa03..56defcb167 100644
--- a/lib/kernel/src/kernel_config.erl
+++ b/lib/kernel/src/kernel_config.erl
@@ -121,7 +121,7 @@ send_timeout(Timeout, Pid) ->
end.
wait_nodes(Mandatory, Optional) ->
- net_kernel:monitor_nodes(true),
+ ok = net_kernel:monitor_nodes(true),
lists:foreach(fun(Node) ->
case net_adm:ping(Node) of
pong -> self() ! {nodeup, Node};
@@ -129,7 +129,9 @@ wait_nodes(Mandatory, Optional) ->
end
end,
Mandatory ++ Optional),
- rec_nodes(Mandatory, Optional).
+ R = rec_nodes(Mandatory, Optional),
+ ok = net_kernel:monitor_nodes(false),
+ R.
rec_nodes([], []) -> ok;
rec_nodes(Mandatory, Optional) ->
diff --git a/lib/kernel/src/net_adm.erl b/lib/kernel/src/net_adm.erl
index 9b2dac9544..3f5eac7822 100644
--- a/lib/kernel/src/net_adm.erl
+++ b/lib/kernel/src/net_adm.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -133,7 +133,7 @@ dns_hostname(Hostname) ->
-spec ping_list([atom()]) -> [atom()].
ping_list(Nodelist) ->
- net_kernel:monitor_nodes(true),
+ ok = net_kernel:monitor_nodes(true),
Sofar = ping_first(Nodelist, nodes()),
collect_new(Sofar, Nodelist).
@@ -159,7 +159,7 @@ collect_new(Sofar, Nodelist) ->
collect_new([Node | Sofar], Nodelist)
end
after 3000 ->
- net_kernel:monitor_nodes(false),
+ ok = net_kernel:monitor_nodes(false),
Sofar
end.
diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl
index dd0071b914..04a0d94ebf 100644
--- a/lib/kernel/src/net_kernel.erl
+++ b/lib/kernel/src/net_kernel.erl
@@ -306,21 +306,21 @@ do_connect(Node, Type, WaitForBarred) -> %% Type = normal | hidden
end.
passive_connect_monitor(Parent, Node) ->
- monitor_nodes(true,[{node_type,all}]),
+ ok = monitor_nodes(true,[{node_type,all}]),
case lists:member(Node,nodes([connected])) of
true ->
- monitor_nodes(false,[{node_type,all}]),
+ ok = monitor_nodes(false,[{node_type,all}]),
Parent ! {self(),true};
_ ->
Ref = make_ref(),
Tref = erlang:send_after(connecttime(),self(),Ref),
receive
Ref ->
- monitor_nodes(false,[{node_type,all}]),
+ ok = monitor_nodes(false,[{node_type,all}]),
Parent ! {self(), false};
{nodeup,Node,_} ->
- monitor_nodes(false,[{node_type,all}]),
- erlang:cancel_timer(Tref),
+ ok = monitor_nodes(false,[{node_type,all}]),
+ _ = erlang:cancel_timer(Tref),
Parent ! {self(),true}
end
end.
@@ -734,7 +734,7 @@ handle_info(transition_period_end,
how = How}} = State) ->
?tckr_dbg(transition_period_ended),
case How of
- shorter -> Tckr ! {new_ticktime, T};
+ shorter -> Tckr ! {new_ticktime, T}, done;
_ -> done
end,
{noreply,State#state{tick = #tick{ticker = Tckr, time = T}}};
@@ -1573,9 +1573,10 @@ async_gen_server_reply(From, Msg) ->
ok ->
ok;
nosuspend ->
- spawn(fun() -> catch erlang:send(Pid, M, [noconnect]) end);
+ _ = spawn(fun() -> catch erlang:send(Pid, M, [noconnect]) end),
+ ok;
noconnect ->
ok; % The gen module takes care of this case.
- {'EXIT', _}=EXIT ->
- EXIT
+ {'EXIT', _} ->
+ ok
end.
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
index ded03361ee..9ffa9adeab 100644
--- a/lib/kernel/src/os.erl
+++ b/lib/kernel/src/os.erl
@@ -26,7 +26,7 @@
%%% BIFs
--export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0]).
+-export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0, unsetenv/1]).
-spec getenv() -> [string()].
@@ -58,6 +58,12 @@ putenv(_, _) ->
timestamp() ->
erlang:nif_error(undef).
+-spec unsetenv(VarName) -> true when
+ VarName :: string().
+
+unsetenv(_) ->
+ erlang:nif_error(undef).
+
%%% End of BIFs
-spec type() -> {Osfamily, Osname} when
@@ -183,20 +189,25 @@ extensions() ->
Command :: atom() | io_lib:chars().
cmd(Cmd) ->
validate(Cmd),
- case type() of
- {unix, _} ->
- unix_cmd(Cmd);
- {win32, Wtype} ->
- Command0 = case {os:getenv("COMSPEC"),Wtype} of
- {false,windows} -> lists:concat(["command.com /c", Cmd]);
- {false,_} -> lists:concat(["cmd /c", Cmd]);
- {Cspec,_} -> lists:concat([Cspec," /c",Cmd])
- end,
- %% open_port/2 awaits string() in Command, but io_lib:chars() can be
- %% deep lists according to io_lib module description.
- Command = lists:flatten(Command0),
- Port = open_port({spawn, Command}, [stream, in, eof, hide]),
- get_data(Port, [])
+ Bytes = case type() of
+ {unix, _} ->
+ unix_cmd(Cmd);
+ {win32, Wtype} ->
+ Command0 = case {os:getenv("COMSPEC"),Wtype} of
+ {false,windows} -> lists:concat(["command.com /c", Cmd]);
+ {false,_} -> lists:concat(["cmd /c", Cmd]);
+ {Cspec,_} -> lists:concat([Cspec," /c",Cmd])
+ end,
+ %% open_port/2 awaits string() in Command, but io_lib:chars() can be
+ %% deep lists according to io_lib module description.
+ Command = lists:flatten(Command0),
+ Port = open_port({spawn, Command}, [stream, in, eof, hide]),
+ get_data(Port, [])
+ end,
+ String = unicode:characters_to_list(list_to_binary(Bytes)),
+ if %% Convert to unicode list if possible otherwise return bytes
+ is_list(String) -> String;
+ true -> Bytes
end.
unix_cmd(Cmd) ->
@@ -278,8 +289,8 @@ start_port_srv_handle({Ref,Client}) ->
error:Reason ->
{Reason,erlang:get_stacktrace()}
end,
- Client ! {Ref,Reply}.
-
+ Client ! {Ref,Reply},
+ ok.
start_port_srv_loop() ->
receive
@@ -287,7 +298,7 @@ start_port_srv_loop() ->
is_pid(Client) ->
start_port_srv_handle(Request);
_Junk ->
- ignore
+ ok
end,
start_port_srv_loop().
@@ -337,7 +348,7 @@ mk_cmd(Cmd) when is_atom(Cmd) -> % backward comp.
mk_cmd(Cmd) ->
%% We insert a new line after the command, in case the command
%% contains a comment character.
- io_lib:format("(~ts\n) </dev/null; echo \"\^D\"\n", [Cmd]).
+ [$(, unicode:characters_to_binary(Cmd), "\n) </dev/null; echo \"\^D\"\n"].
validate(Atom) when is_atom(Atom) ->
@@ -345,7 +356,7 @@ validate(Atom) when is_atom(Atom) ->
validate(List) when is_list(List) ->
validate1(List).
-validate1([C|Rest]) when is_integer(C), 0 =< C, C < 256 ->
+validate1([C|Rest]) when is_integer(C) ->
validate1(Rest);
validate1([List|Rest]) when is_list(List) ->
validate1(List),
diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl
index 1ff10eb303..b562d4ffd2 100644
--- a/lib/kernel/src/pg2.erl
+++ b/lib/kernel/src/pg2.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -45,7 +45,7 @@ start() ->
-spec create(Name :: name()) -> 'ok'.
create(Name) ->
- ensure_started(),
+ _ = ensure_started(),
case ets:member(pg2_table, {group, Name}) of
false ->
global:trans({{?MODULE, Name}, self()},
@@ -60,7 +60,7 @@ create(Name) ->
-spec delete(Name :: name()) -> 'ok'.
delete(Name) ->
- ensure_started(),
+ _ = ensure_started(),
global:trans({{?MODULE, Name}, self()},
fun() ->
gen_server:multi_call(?MODULE, {delete, Name})
@@ -71,7 +71,7 @@ delete(Name) ->
when Name :: name().
join(Name, Pid) when is_pid(Pid) ->
- ensure_started(),
+ _ = ensure_started(),
case ets:member(pg2_table, {group, Name}) of
false ->
{error, {no_such_group, Name}};
@@ -88,7 +88,7 @@ join(Name, Pid) when is_pid(Pid) ->
when Name :: name().
leave(Name, Pid) when is_pid(Pid) ->
- ensure_started(),
+ _ = ensure_started(),
case ets:member(pg2_table, {group, Name}) of
false ->
{error, {no_such_group, Name}};
@@ -105,7 +105,7 @@ leave(Name, Pid) when is_pid(Pid) ->
when Name :: name().
get_members(Name) ->
- ensure_started(),
+ _ = ensure_started(),
case ets:member(pg2_table, {group, Name}) of
true ->
group_members(Name);
@@ -117,7 +117,7 @@ get_members(Name) ->
when Name :: name().
get_local_members(Name) ->
- ensure_started(),
+ _ = ensure_started(),
case ets:member(pg2_table, {group, Name}) of
true ->
local_group_members(Name);
@@ -128,7 +128,7 @@ get_local_members(Name) ->
-spec which_groups() -> [Name :: name()].
which_groups() ->
- ensure_started(),
+ _ = ensure_started(),
all_groups().
-spec get_closest_pid(Name) -> pid() | {'error', Reason} when
@@ -165,7 +165,7 @@ get_closest_pid(Name) ->
init([]) ->
Ns = nodes(),
- net_kernel:monitor_nodes(true),
+ ok = net_kernel:monitor_nodes(true),
lists:foreach(fun(N) ->
{?MODULE, N} ! {new_pg2, node()},
self() ! {nodeup, N}
@@ -283,7 +283,7 @@ member_died(Ref) ->
join_group(Name, Pid) ->
Ref_Pid = {ref, Pid},
- try _ = ets:update_counter(pg2_table, Ref_Pid, {4, +1})
+ try _ = ets:update_counter(pg2_table, Ref_Pid, {4, +1}), true
catch _:_ ->
{RPid, Ref} = do_monitor(Pid),
true = ets:insert(pg2_table, {Ref_Pid, RPid, Ref, 1}),
diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl
index ced6f47bfe..2300b7e901 100644
--- a/lib/kernel/src/rpc.erl
+++ b/lib/kernel/src/rpc.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -66,7 +66,7 @@
%%------------------------------------------------------------------------
--type state() :: gb_tree().
+-type state() :: gb_trees:tree(pid(), {pid(), reference()}).
%%------------------------------------------------------------------------
@@ -158,20 +158,20 @@ handle_info({Caller, {reply, Reply}}, S) ->
{noreply, S}
end;
handle_info({From, {sbcast, Name, Msg}}, S) ->
- case catch Name ! Msg of %% use catch to get the printout
- {'EXIT', _} ->
- From ! {?NAME, node(), {nonexisting_name, Name}};
- _ ->
- From ! {?NAME, node(), node()}
- end,
+ _ = case catch Name ! Msg of %% use catch to get the printout
+ {'EXIT', _} ->
+ From ! {?NAME, node(), {nonexisting_name, Name}};
+ _ ->
+ From ! {?NAME, node(), node()}
+ end,
{noreply, S};
handle_info({From, {send, Name, Msg}}, S) ->
- case catch Name ! {From, Msg} of %% use catch to get the printout
- {'EXIT', _} ->
- From ! {?NAME, node(), {nonexisting_name, Name}};
- _ ->
- ok %% It's up to Name to respond !!!!!
- end,
+ _ = case catch Name ! {From, Msg} of %% use catch to get the printout
+ {'EXIT', _} ->
+ From ! {?NAME, node(), {nonexisting_name, Name}};
+ _ ->
+ ok %% It's up to Name to respond !!!!!
+ end,
{noreply, S};
handle_info({From, {call,Mod,Fun,Args,Gleader}}, S) ->
%% Special for hidden C node's, uugh ...
@@ -407,7 +407,7 @@ cast(Node, Mod, Fun, Args) ->
true.
-%% Asynchronous broadcast, returns nothing, it's just send'n prey
+%% Asynchronous broadcast, returns nothing, it's just send 'n' pray
-spec abcast(Name, Msg) -> abcast when
Name :: atom(),
Msg :: term().
@@ -423,7 +423,7 @@ abcast(Name, Mess) ->
abcast([Node|Tail], Name, Mess) ->
Dest = {Name,Node},
case catch erlang:send(Dest, Mess, [noconnect]) of
- noconnect -> spawn(erlang, send, [Dest,Mess]);
+ noconnect -> spawn(erlang, send, [Dest,Mess]), ok;
_ -> ok
end,
abcast(Tail, Name, Mess);
diff --git a/lib/kernel/src/seq_trace.erl b/lib/kernel/src/seq_trace.erl
index a90b7b07c8..38a61f4644 100644
--- a/lib/kernel/src/seq_trace.erl
+++ b/lib/kernel/src/seq_trace.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -125,7 +125,7 @@ get_system_tracer() ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set_token2([{Type,Val}|T]) ->
- erlang:seq_trace(Type, Val),
+ _ = erlang:seq_trace(Type, Val),
set_token2(T);
set_token2([]) ->
ok.
diff --git a/lib/kernel/src/standard_error.erl b/lib/kernel/src/standard_error.erl
index e41dcd01fc..10cf77e0d4 100644
--- a/lib/kernel/src/standard_error.erl
+++ b/lib/kernel/src/standard_error.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -69,7 +69,7 @@ run(P) ->
server_loop(Port) ->
receive
{io_request,From,ReplyAs,Request} when is_pid(From) ->
- do_io_request(Request, From, ReplyAs, Port),
+ _ = do_io_request(Request, From, ReplyAs, Port),
server_loop(Port);
{'EXIT',Port,badsig} -> % Ignore badsig errors
server_loop(Port);
@@ -175,7 +175,7 @@ io_reply(From, ReplyAs, Reply) ->
%% put_chars
put_chars(Chars, Port) when is_binary(Chars) ->
- put_port(Chars, Port),
+ _ = put_port(Chars, Port),
{ok,ok};
put_chars(Chars, Port) ->
case catch list_to_binary(Chars) of
diff --git a/lib/kernel/src/user.erl b/lib/kernel/src/user.erl
index c897d46bc2..40376ef752 100644
--- a/lib/kernel/src/user.erl
+++ b/lib/kernel/src/user.erl
@@ -103,11 +103,11 @@ catch_loop(Port, Shell, Q) ->
{unknown_exit,{Shell,Reason},_} -> % shell has exited
case Reason of
normal ->
- put_chars("*** ", Port, []);
+ put_port(<<"*** ">>, Port);
_ ->
- put_chars("*** ERROR: ", Port, [])
+ put_port(<<"*** ERROR: ">>, Port)
end,
- put_chars("Shell process terminated! ***\n", Port, []),
+ put_port(<<"Shell process terminated! ***\n">>, Port),
catch_loop(Port, start_new_shell());
{unknown_exit,_,Q1} ->
catch_loop(Port, Shell, Q1);
@@ -181,7 +181,7 @@ get_fd_geometry(Port) ->
do_io_request(Req, From, ReplyAs, Port, Q0) ->
case io_request(Req, Port, Q0) of
{_Status,Reply,Q1} ->
- io_reply(From, ReplyAs, Reply),
+ _ = io_reply(From, ReplyAs, Reply),
Q1;
{exit,What} ->
ok = send_port(Port, close),
diff --git a/lib/kernel/src/user_drv.erl b/lib/kernel/src/user_drv.erl
index bb654495d3..a91c23539d 100644
--- a/lib/kernel/src/user_drv.erl
+++ b/lib/kernel/src/user_drv.erl
@@ -418,7 +418,7 @@ list_commands(Iport, Oport) ->
true ->
[];
false ->
- [{put_chars,unicode," q - quit erlang\n"}]
+ [{put_chars, unicode," q - quit erlang\n"}]
end,
io_requests([{put_chars, unicode," c [nn] - connect to job\n"},
{put_chars, unicode," i [nn] - interrupt job\n"},
@@ -488,21 +488,19 @@ set_unicode_state(Iport, Bool) ->
%% io_request(Request, InPort, OutPort)
%% io_requests(Requests, InPort, OutPort)
-
-io_request({put_chars, unicode,Cs}, _Iport, Oport) ->
- Oport ! {self(),{command,[?OP_PUTC|unicode:characters_to_binary(Cs,utf8)]}};
-io_request({move_rel,N}, _Iport, Oport) ->
- Oport ! {self(),{command,[?OP_MOVE|put_int16(N, [])]}};
-io_request({insert_chars,unicode,Cs}, _Iport, Oport) ->
- Oport ! {self(),{command,[?OP_INSC|unicode:characters_to_binary(Cs,utf8)]}};
-io_request({delete_chars,N}, _Iport, Oport) ->
- Oport ! {self(),{command,[?OP_DELC|put_int16(N, [])]}};
-io_request(beep, _Iport, Oport) ->
- Oport ! {self(),{command,[?OP_BEEP]}};
-io_request({requests,Rs}, Iport, Oport) ->
- io_requests(Rs, Iport, Oport);
-io_request(_R, _Iport, _Oport) ->
- ok.
+%% Note: InPort is unused.
+
+io_request(Request, Iport, Oport) ->
+ try io_command(Request) of
+ Command ->
+ Oport ! {self(),Command},
+ ok
+ catch
+ {requests,Rs} ->
+ io_requests(Rs, Iport, Oport);
+ _ ->
+ ok
+ end.
io_requests([R|Rs], Iport, Oport) ->
io_request(R, Iport, Oport),
@@ -513,6 +511,19 @@ io_requests([], _Iport, _Oport) ->
put_int16(N, Tail) ->
[(N bsr 8)band 255,N band 255|Tail].
+io_command({put_chars, unicode,Cs}) ->
+ {command,[?OP_PUTC|unicode:characters_to_binary(Cs,utf8)]};
+io_command({move_rel,N}) ->
+ {command,[?OP_MOVE|put_int16(N, [])]};
+io_command({insert_chars,unicode,Cs}) ->
+ {command,[?OP_INSC|unicode:characters_to_binary(Cs,utf8)]};
+io_command({delete_chars,N}) ->
+ {command,[?OP_DELC|put_int16(N, [])]};
+io_command(beep) ->
+ {command,[?OP_BEEP]};
+io_command(Else) ->
+ throw(Else).
+
%% gr_new()
%% gr_get_num(Group, Index)
%% gr_get_info(Group, Pid)
diff --git a/lib/kernel/src/wrap_log_reader.erl b/lib/kernel/src/wrap_log_reader.erl
index 689269fc28..7e1f4aa07f 100644
--- a/lib/kernel/src/wrap_log_reader.erl
+++ b/lib/kernel/src/wrap_log_reader.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -149,7 +149,7 @@ open_int(File, FileNo, FirstFileNo) ->
{ok, Head} ->
case disk_log_1:is_head(Head) of
no ->
- file:close(Fd),
+ _ = file:close(Fd),
{error, {not_a_log_file, FName}};
_ -> % yes or yes_not_closed
case last_mod_time(FName) of
@@ -161,12 +161,12 @@ open_int(File, FileNo, FirstFileNo) ->
first_no = FirstFileNo},
{ok, WR};
{error, E} ->
- file:close(Fd),
+ _ = file:close(Fd),
{error, {file_error, FName, E}}
end
end;
_Other ->
- file:close(Fd),
+ _ = file:close(Fd),
{error, {not_a_log_file, FName}}
end;
_Other ->
@@ -280,7 +280,7 @@ read_next_file(WR, N, NewFileNo, Bad) ->
true ->
case open_int(File, NewFileNo, FirstFileNo) of
{ok, NWR} ->
- close(WR), %% Now we can safely close the old file.
+ _ = close(WR), %% Now we can safely close the old file.
chunk(NWR, N, Bad);
Error ->
Error
diff --git a/lib/kernel/test/Makefile b/lib/kernel/test/Makefile
index cb11d4e899..f1b8a105ed 100644
--- a/lib/kernel/test/Makefile
+++ b/lib/kernel/test/Makefile
@@ -145,7 +145,7 @@ release_tests_spec: make_emakefile
$(INSTALL_DIR) "$(RELSYSDIR)"
$(INSTALL_DATA) $(ERL_FILES) "$(RELSYSDIR)"
$(INSTALL_DATA) $(APP_FILES) "$(RELSYSDIR)"
- $(INSTALL_DATA) kernel.spec $(EMAKEFILE)\
+ $(INSTALL_DATA) kernel.spec kernel_smoke.spec $(EMAKEFILE)\
$(COVERFILE) "$(RELSYSDIR)"
chmod -R u+w "$(RELSYSDIR)"
@tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -)
diff --git a/lib/kernel/test/application_SUITE.erl b/lib/kernel/test/application_SUITE.erl
index 1ff291be54..c6cbd1a0ef 100644
--- a/lib/kernel/test/application_SUITE.erl
+++ b/lib/kernel/test/application_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -33,10 +33,10 @@
permit_false_start_local/1, permit_false_start_dist/1, script_start/1,
nodedown_start/1, init2973/0, loop2973/0, loop5606/1]).
--export([config_change/1,
+-export([config_change/1, persistent_env/1,
distr_changed_tc1/1, distr_changed_tc2/1,
- ensure_started/1,
- shutdown_func/1, do_shutdown/1, shutdown_timeout/1]).
+ ensure_started/1, ensure_all_started/1,
+ shutdown_func/1, do_shutdown/1, shutdown_timeout/1, shutdown_deadlock/1]).
-define(TESTCASE, testcase_name).
-define(testcase, ?config(?TESTCASE, Config)).
@@ -52,8 +52,10 @@ all() ->
[failover, failover_comp, permissions, load,
load_use_cache, ensure_started, {group, reported_bugs}, start_phases,
script_start, nodedown_start, permit_false_start_local,
- permit_false_start_dist, get_key, get_env,
- {group, distr_changed}, config_change, shutdown_func, shutdown_timeout].
+ permit_false_start_dist, get_key, get_env, ensure_all_started,
+ {group, distr_changed}, config_change, shutdown_func, shutdown_timeout,
+ shutdown_deadlock,
+ persistent_env].
groups() ->
[{reported_bugs, [],
@@ -960,7 +962,7 @@ nodedown_start(Conf) when is_list(Conf) ->
ensure_started(suite) -> [];
ensure_started(doc) -> ["Test application:ensure_started/1."];
-ensure_started(Conf) ->
+ensure_started(_Conf) ->
{ok, Fd} = file:open("app1.app", [write]),
w_app1(Fd),
@@ -978,6 +980,85 @@ ensure_started(Conf) ->
ok = application:unload(app1),
ok.
+ensure_all_started(suite) -> [];
+ensure_all_started(doc) -> ["Test application:ensure_all_started/1-2."];
+ensure_all_started(_Conf) ->
+
+ {ok, Fd1} = file:open("app1.app", [write]),
+ w_app1(Fd1),
+ file:close(Fd1),
+ {ok, Fd9} = file:open("app9.app", [write]),
+ w_app9(Fd9),
+ file:close(Fd9),
+ {ok, Fd10} = file:open("app10.app", [write]),
+ w_app10_dep9(Fd10),
+ file:close(Fd10),
+ {ok, FdErr} = file:open("app_chain_error.app", [write]),
+ w_app(FdErr, app_chain_error()),
+ file:close(FdErr),
+ {ok, FdErr2} = file:open("app_chain_error2.app", [write]),
+ w_app(FdErr2, app_chain_error2()),
+ file:close(FdErr2),
+
+ %% Single app start/stop
+ false = lists:keyfind(app1, 1, application:which_applications()),
+ {ok, [app1]} = application:ensure_all_started(app1), % app1 started
+ {app1, _, _} = lists:keyfind(app1, 1, application:which_applications()),
+ {ok, []} = application:ensure_all_started(app1), % no start needed
+ ok = application:stop(app1),
+ false = lists:keyfind(app1, 1, application:which_applications()),
+ ok = application:unload(app1),
+
+ %% App or dependency not found.
+ Name = hopefully_not_an_existing_app_file,
+ {error,{Name, {"no such file or directory", _ }}} =
+ application:ensure_all_started(Name),
+
+ %% Start dependencies.
+ {error, {not_started, app9}} = application:start(app10),
+ {ok, [app9,app10]} = application:ensure_all_started(app10, temporary),
+ {app9, _, _} = lists:keyfind(app9, 1, application:which_applications()),
+ {app10, _, _} = lists:keyfind(app10, 1, application:which_applications()),
+ %% Only report apps/dependencies that actually needed to start
+ ok = application:stop(app10),
+ ok = application:unload(app10),
+ {ok, [app10]} = application:ensure_all_started(app10, temporary),
+ ok = application:stop(app9),
+ ok = application:unload(app9),
+ ok = application:stop(app10),
+ ok = application:unload(app10),
+
+ %% Deeper failure chain. We have the following dependencies:
+ %% app_chain_error -> app_chain_error2
+ %% app_chain_error2 -> app10
+ %% app_chain_error2 -> hopefully_not_an_existing_app
+ %% app10 -> app 9
+ %% First we have none running and we expect to have neither app9
+ %% nor app10 running after failing to start
+ %% hopefully_not_an_existing_app
+ {error, {hopefully_not_an_existing_app, {"no such file or directory", _}}}=
+ application:ensure_all_started(app_chain_error),
+ false = lists:keyfind(app9, 1, application:which_applications()),
+ false = lists:keyfind(app10, 1, application:which_applications()),
+ false = lists:keyfind(app_chain_error2,1,application:which_applications()),
+ false = lists:keyfind(app_chain_error, 1, application:which_applications()),
+ %% Here we will have app9 already running, and app10 should be
+ %% able to boot fine.
+ %% In this dependency failing, we expect app9 to still be running, but
+ %% not app10 after failing to start hopefully_not_an_existing_app
+ {ok, [app9]} = application:ensure_all_started(app9, temporary),
+ {error, {hopefully_not_an_existing_app, {"no such file or directory", _}}}=
+ application:ensure_all_started(app_chain_error),
+ {app9, _, _} = lists:keyfind(app9, 1, application:which_applications()),
+ false = lists:keyfind(app10, 1, application:which_applications()),
+ false = lists:keyfind(app_chain_error2,1,application:which_applications()),
+ false = lists:keyfind(app_chain_error, 1, application:which_applications()),
+ ok = application:stop(app9),
+ ok = application:unload(app9),
+ ok = application:unload(app10),
+ ok = application:unload(app_chain_error2),
+ ok = application:unload(app_chain_error),
+ ok.
%%%-----------------------------------------------------------------
%%% Testing of reported bugs and other tickets.
@@ -1908,6 +1989,50 @@ get_appls([_ | T], Res) ->
get_appls([], Res) ->
Res.
+persistent_env(suite) ->
+ [];
+persistent_env(doc) ->
+ ["Test set_env/4 and unset_env/3 with persistent true"];
+persistent_env(Conf) when is_list(Conf) ->
+ ok = application:set_env(appinc, own2, persist, [{persistent, true}]),
+ ok = application:set_env(appinc, key1, persist, [{persistent, true}]),
+
+ %% own_env1 and own2 are set in appinc
+ ok = application:load(appinc()),
+ {ok, value1} = application:get_env(appinc, own_env1),
+ {ok, persist} = application:get_env(appinc, own2),
+ {ok, persist} = application:get_env(appinc, key1),
+
+ %% Changing the environment after loaded reflects and should persist
+ ok = application:set_env(appinc, own_env1, persist, [{persistent, true}]),
+ {ok, persist} = application:get_env(appinc, own_env1),
+ {ok, persist} = application:get_env(appinc, own2),
+ {ok, persist} = application:get_env(appinc, key1),
+
+ %% On reload, own_env1, own2 and key1 should all persist
+ ok = application:unload(appinc),
+ ok = application:load(appinc()),
+ {ok, persist} = application:get_env(appinc, own_env1),
+ {ok, persist} = application:get_env(appinc, own2),
+ {ok, persist} = application:get_env(appinc, key1),
+
+ %% Unset own_env1 and key1, own2 should still persist
+ ok = application:unset_env(appinc, own_env1, [{persistent, true}]),
+ ok = application:unset_env(appinc, key1, [{persistent, true}]),
+ undefined = application:get_env(appinc, own_env1),
+ {ok, persist} = application:get_env(appinc, own2),
+ undefined = application:get_env(appinc, key1),
+
+ %% own_env1 should be back to its application value on reload
+ ok = application:unload(appinc),
+ ok = application:load(appinc()),
+ {ok, value1} = application:get_env(appinc, own_env1),
+ {ok, persist} = application:get_env(appinc, own2),
+ undefined = application:get_env(appinc, key1),
+
+ %% Clean up
+ ok = application:unload(appinc).
+
%%%-----------------------------------------------------------------
%%% Tests the 'shutdown_func' kernel config parameter
%%%-----------------------------------------------------------------
@@ -1972,7 +2097,32 @@ shutdown_timeout(Config) when is_list(Config) ->
end,
ok.
+%%%-----------------------------------------------------------------
+%%% Provokes a (previous) application shutdown deadlock
+%%%-----------------------------------------------------------------
+shutdown_deadlock(Config) when is_list(Config) ->
+ DataDir = ?config(data_dir,Config),
+ code:add_path(filename:join([DataDir,deadlock])),
+ %% ok = rpc:call(Cp1, application, start, [sasl]),
+ ok = application:start(deadlock),
+ Tester = self(),
+ application:set_env(deadlock, fail_stop, Tester),
+ spawn(fun() -> Tester ! {stop, application:stop(deadlock)} end),
+ receive
+ {deadlock, Server} ->
+ spawn(fun() ->
+ Master = application_controller:get_master(deadlock),
+ Child = application_master:get_child(Master),
+ Tester ! {child, Child}
+ end),
+ timer:sleep(100),
+ erlang:display({self(), "Sending Continue", Server}),
+ Server ! continue
+ end,
+ [_|_] = application:which_applications(),
+ application:unload(deadlock), % clean up!
+ ok.
%%-----------------------------------------------------------------
@@ -2125,6 +2275,24 @@ app_start_error() ->
{applications, [kernel]},
{mod, {app_start_error, []}}]}.
+app_chain_error() ->
+ {application, app_chain_error,
+ [{description, "ERTS CXC 138 ce"},
+ {vsn, "2.0"},
+ {modules, []},
+ {registered, []},
+ {applications, [kernel, app_chain_error2]},
+ {mod, {ch_sup, {app_chain_error, 20,20}}}]}.
+
+app_chain_error2() ->
+ {application, app_chain_error2,
+ [{description, "ERTS CXC 138 ce2"},
+ {vsn, "2.0"},
+ {modules, []},
+ {registered, []},
+ {applications, [kernel, app10, hopefully_not_an_existing_app]},
+ {mod, {ch_sup, {app_chain_error2, 21,21}}}]}.
+
app_group_leader() ->
{application, group_leader,
[{description, "GROUP_LEADER CXC 138 11"},
@@ -2374,6 +2542,12 @@ w_app7(Fd) ->
w_app8(Fd) ->
io:format(Fd, "~p.\n", [app8()]).
+w_app9(Fd) ->
+ io:format(Fd, "~p.\n", [app9()]).
+
+w_app10_dep9(Fd) ->
+ io:format(Fd, "~p.\n", [app10_dep9()]).
+
w_app_start_error(Fd) ->
io:format(Fd, "~p.\n", [app_start_error()]).
diff --git a/lib/kernel/test/application_SUITE_data/deadlock/deadlock.app b/lib/kernel/test/application_SUITE_data/deadlock/deadlock.app
index 0c1001bed6..233c7a3f76 100644
--- a/lib/kernel/test/application_SUITE_data/deadlock/deadlock.app
+++ b/lib/kernel/test/application_SUITE_data/deadlock/deadlock.app
@@ -4,5 +4,5 @@
{applications, [kernel, stdlib, sasl]},
{modules, [deadlock]},
{mod, {deadlock, []}},
- {env, [{fail_start, false}]}
+ {env, [{fail_start, false}, {fail_stop, false}]}
]}.
diff --git a/lib/kernel/test/application_SUITE_data/deadlock/deadlock.erl b/lib/kernel/test/application_SUITE_data/deadlock/deadlock.erl
index 5f68bf9078..3ef6105371 100644
--- a/lib/kernel/test/application_SUITE_data/deadlock/deadlock.erl
+++ b/lib/kernel/test/application_SUITE_data/deadlock/deadlock.erl
@@ -21,7 +21,7 @@ init([sup]) ->
{ok, {{one_for_one, 5, 10}, [
{
sasl_syslog_dm, {?MODULE, start_link, []},
- permanent, brutal_kill, worker,
+ permanent, 25000, worker,
[deadlock]
}
]}};
@@ -32,6 +32,8 @@ init([sup]) ->
init([child]) ->
case application:get_env(deadlock, fail_start) of
{ok, false} ->
+ process_flag(trap_exit, true),
+ io:format("~p: Traps exit~n",[?MODULE]),
%% we must not fail on the first init, otherwise supervisor
%% terminates immediately
{ok, []};
@@ -50,6 +52,14 @@ handle_info(_Msg, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
+ case application:get_env(deadlock, fail_stop) of
+ {ok, false} -> ok;
+ {ok, Tester} ->
+ Tester ! {deadlock, self()},
+ io:format("~p: Waiting in terminate (~p)~n",[?MODULE,Tester]),
+ receive continue -> ok end
+ end,
+ io:format("~p: terminates~n", [?MODULE]),
ok.
code_change(_OldVsn, State, _Extra) ->
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index fc17db2745..42b81d16b3 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -23,7 +23,8 @@
-export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]).
-export([set_path/1, get_path/1, add_path/1, add_paths/1, del_path/1,
replace_path/1, load_file/1, load_abs/1, ensure_loaded/1,
- delete/1, purge/1, soft_purge/1, is_loaded/1, all_loaded/1,
+ delete/1, purge/1, purge_many_exits/1, soft_purge/1, is_loaded/1,
+ all_loaded/1,
load_binary/1, dir_req/1, object_code/1, set_path_file/1,
upgrade/1,
sticky_dir/1, pa_pz_option/1, add_del_path/1,
@@ -35,7 +36,7 @@
on_load_embedded/1, on_load_errors/1, big_boot_embedded/1,
native_early_modules/1, get_mode/1]).
--export([init_per_testcase/2, end_per_testcase/2,
+-export([init_per_testcase/2, end_per_testcase/2,
init_per_suite/1, end_per_suite/1,
sticky_compiler/1]).
@@ -48,10 +49,10 @@
suite() -> [{ct_hooks,[ts_install_cth]}].
-all() ->
+all() ->
[set_path, get_path, add_path, add_paths, del_path,
replace_path, load_file, load_abs, ensure_loaded,
- delete, purge, soft_purge, is_loaded, all_loaded,
+ delete, purge, purge_many_exits, soft_purge, is_loaded, all_loaded,
load_binary, dir_req, object_code, set_path_file,
upgrade,
pa_pz_option, add_del_path, dir_disappeared,
@@ -62,7 +63,7 @@ all() ->
on_load_binary, on_load_embedded, on_load_errors,
big_boot_embedded, native_early_modules, get_mode].
-groups() ->
+groups() ->
[].
init_per_group(_GroupName, Config) ->
@@ -76,10 +77,10 @@ init_per_suite(Config) ->
%% the module name does not match the filename, so
%% we must compile to a binary and write the Beam file
%% ourselves.
- ?line Dir = filename:dirname(code:which(?MODULE)),
- ?line File = filename:join(Dir, "code_a_test"),
- ?line {ok,code_b_test,Code} = compile:file(File, [binary]),
- ?line ok = file:write_file(File++".beam", Code),
+ Dir = filename:dirname(code:which(?MODULE)),
+ File = filename:join(Dir, "code_a_test"),
+ {ok,code_b_test,Code} = compile:file(File, [binary]),
+ ok = file:write_file(File++".beam", Code),
Config.
end_per_suite(Config) ->
@@ -98,7 +99,7 @@ init_per_testcase(_Func, Config) ->
P=code:get_path(),
[{watchdog, Dog}, {code_path, P}|Config].
-end_per_testcase(TC, Config) when TC == mult_lib_roots;
+end_per_testcase(TC, Config) when TC == mult_lib_roots;
TC == big_boot_embedded ->
{ok, HostName} = inet:gethostname(),
NodeName = list_to_atom(atom_to_list(TC)++"@"++HostName),
@@ -121,51 +122,49 @@ set_path(doc) -> [];
set_path(Config) when is_list(Config) ->
P = code:get_path(),
NonExDir = filename:join(?config(priv_dir, Config), ?t:temp_name("hej")),
- ?line {'EXIT',_} = (catch code:set_path({a})),
- ?line {error, bad_directory} = (catch code:set_path([{a}])),
- ?line {error, bad_directory} = code:set_path(NonExDir),
- ?line P = code:get_path(), % still the same path.
- ?line true = code:set_path(P), % set the same path again.
- ?line P = code:get_path(), % still the same path.
+ {'EXIT',_} = (catch code:set_path({a})),
+ {error, bad_directory} = (catch code:set_path([{a}])),
+ {error, bad_directory} = code:set_path(NonExDir),
+ P = code:get_path(), % still the same path.
+ true = code:set_path(P), % set the same path again.
+ P = code:get_path(), % still the same path.
LibDir = code:lib_dir(),
- ?line true = code:set_path([LibDir | P]),
- ?line [LibDir | P] = code:get_path(),
- ?line true = code:set_path([LibDir]),
- ?line [LibDir] = code:get_path(),
+ true = code:set_path([LibDir | P]),
+ [LibDir | P] = code:get_path(),
+ true = code:set_path([LibDir]),
+ [LibDir] = code:get_path(),
ok.
get_path(suite) -> [];
get_path(doc) -> [];
get_path(Config) when is_list(Config) ->
- ?line P = code:get_path(),
+ P = code:get_path(),
% test that all directories are strings (lists).
- ?line [] = lists:filter(fun(Dir) when is_list(Dir) ->
- false;
- (_) ->
- true
- end,
- P),
+ [] = lists:filter(fun
+ (Dir) when is_list(Dir) -> false;
+ (_) -> true
+ end, P),
ok.
add_path(suite) -> [];
add_path(doc) -> [];
add_path(Config) when is_list(Config) ->
P = code:get_path(),
- ?line {'EXIT',_} = (catch code:add_path({})),
- ?line {'EXIT',_} = (catch code:add_patha({})),
- ?line {'EXIT',_} = (catch code:add_pathz({})),
- ?line {error, bad_directory} = code:add_path("xyz"),
- ?line {error, bad_directory} = code:add_patha("xyz"),
- ?line {error, bad_directory} = code:add_pathz("xyz"),
+ {'EXIT',_} = (catch code:add_path({})),
+ {'EXIT',_} = (catch code:add_patha({})),
+ {'EXIT',_} = (catch code:add_pathz({})),
+ {error, bad_directory} = code:add_path("xyz"),
+ {error, bad_directory} = code:add_patha("xyz"),
+ {error, bad_directory} = code:add_pathz("xyz"),
LibDir = code:lib_dir(),
- ?line true = code:add_path(LibDir),
- ?line LibDir = lists:last(code:get_path()),
+ true = code:add_path(LibDir),
+ LibDir = lists:last(code:get_path()),
code:set_path(P),
- ?line true = code:add_pathz(LibDir),
- ?line LibDir = lists:last(code:get_path()),
+ true = code:add_pathz(LibDir),
+ LibDir = lists:last(code:get_path()),
code:set_path(P),
- ?line true = code:add_patha(LibDir),
- ?line [LibDir|_] = code:get_path(),
+ true = code:add_patha(LibDir),
+ [LibDir|_] = code:get_path(),
code:set_path(P),
ok.
@@ -173,134 +172,134 @@ add_paths(suite) -> [];
add_paths(doc) -> [];
add_paths(Config) when is_list(Config) ->
P = code:get_path(),
- ?line ok = code:add_paths([{}]),
- ?line ok = code:add_pathsa([{}]),
- ?line ok = code:add_pathsz([{}]),
- ?line ok = code:add_paths(["xyz"]),
- ?line ok = code:add_pathsa(["xyz"]),
- ?line ok = code:add_pathsz(["xyz"]),
+ ok = code:add_paths([{}]),
+ ok = code:add_pathsa([{}]),
+ ok = code:add_pathsz([{}]),
+ ok = code:add_paths(["xyz"]),
+ ok = code:add_pathsa(["xyz"]),
+ ok = code:add_pathsz(["xyz"]),
P = code:get_path(), % check that no directory is added.
LibDir = code:lib_dir(),
- ?line ok = code:add_paths([LibDir]),
- ?line LibDir = lists:last(code:get_path()),
+ ok = code:add_paths([LibDir]),
+ LibDir = lists:last(code:get_path()),
code:set_path(P),
- ?line ok = code:add_pathsz([LibDir]),
- ?line LibDir = lists:last(code:get_path()),
+ ok = code:add_pathsz([LibDir]),
+ LibDir = lists:last(code:get_path()),
code:set_path(P),
- ?line ok = code:add_pathsa([LibDir]),
- ?line [LibDir|P] = code:get_path(),
+ ok = code:add_pathsa([LibDir]),
+ [LibDir|P] = code:get_path(),
code:set_path(P),
RootDir = code:root_dir(),
Res = P ++ [LibDir, RootDir],
- ?line ok = code:add_paths([LibDir, RootDir]),
- ?line Res = code:get_path(),
+ ok = code:add_paths([LibDir, RootDir]),
+ Res = code:get_path(),
code:set_path(P),
- ?line ok = code:add_pathsz([LibDir, RootDir]),
- ?line Res = code:get_path(),
+ ok = code:add_pathsz([LibDir, RootDir]),
+ Res = code:get_path(),
code:set_path(P),
- ?line ok = code:add_pathsa([LibDir, RootDir]),
- ?line [RootDir, LibDir|P] = code:get_path(),
+ ok = code:add_pathsa([LibDir, RootDir]),
+ [RootDir, LibDir|P] = code:get_path(),
code:set_path(P),
- ?line ok = code:add_paths([LibDir, "xyz"]),
+ ok = code:add_paths([LibDir, "xyz"]),
Res1 = P ++ [LibDir],
- ?line Res1 = code:get_path(),
+ Res1 = code:get_path(),
code:set_path(P),
- ?line ok = code:add_pathsz([LibDir, "xyz"]),
- ?line Res1 = code:get_path(),
+ ok = code:add_pathsz([LibDir, "xyz"]),
+ Res1 = code:get_path(),
code:set_path(P),
- ?line ok = code:add_pathsa([LibDir, "xyz"]),
- ?line [LibDir|P] = code:get_path(),
+ ok = code:add_pathsa([LibDir, "xyz"]),
+ [LibDir|P] = code:get_path(),
code:set_path(P),
ok.
del_path(suite) -> [];
del_path(doc) -> [];
del_path(Config) when is_list(Config) ->
- ?line P = code:get_path(),
+ P = code:get_path(),
test_server:format("Initial code:get_path()=~p~n",[P]),
- ?line {'EXIT',_} = (catch code:del_path(3)),
- ?line false = code:del_path(my_dummy_name),
- ?line false = code:del_path("/kdlk/my_dummy_dir"),
+ {'EXIT',_} = (catch code:del_path(3)),
+ false = code:del_path(my_dummy_name),
+ false = code:del_path("/kdlk/my_dummy_dir"),
Dir = filename:join([code:lib_dir(kernel),"ebin"]),
test_server:format("kernel dir: ~p~n",[Dir]),
- ?line true = code:del_path(kernel),
+ true = code:del_path(kernel),
NewP = code:get_path(),
test_server:format("Path after removing 'kernel':~p~n",[NewP]),
ReferenceP = lists:delete(Dir,P),
test_server:format("Reference path:~p~n",[ReferenceP]),
- ?line NewP = ReferenceP, % check that dir is deleted
+ NewP = ReferenceP, % check that dir is deleted
code:set_path(P),
- ?line true = code:del_path(Dir),
+ true = code:del_path(Dir),
NewP1 = code:get_path(),
- ?line NewP1 = lists:delete(Dir,P), % check that dir is deleted
+ NewP1 = lists:delete(Dir,P), % check that dir is deleted
code:set_path(P),
ok.
replace_path(suite) -> [];
replace_path(doc) -> [];
replace_path(Config) when is_list(Config) ->
- ?line PrivDir = ?config(priv_dir, Config),
- ?line P = code:get_path(),
- ?line {'EXIT',_} = (catch code:replace_path(3,"")),
- ?line {error, bad_name} = code:replace_path(dummy_name,""),
- ?line {error, bad_name} = code:replace_path(kernel,
+ PrivDir = ?config(priv_dir, Config),
+ P = code:get_path(),
+ {'EXIT',_} = (catch code:replace_path(3,"")),
+ {error, bad_name} = code:replace_path(dummy_name,""),
+ {error, bad_name} = code:replace_path(kernel,
"/kdlk/my_dummy_dir"),
- ?line {error, bad_directory} = code:replace_path(kernel,
+ {error, bad_directory} = code:replace_path(kernel,
"/kdlk/kernel-1.2"),
- ?line P = code:get_path(), % Check that path is not changed.
+ P = code:get_path(), % Check that path is not changed.
- ?line ok = file:set_cwd(PrivDir),
+ ok = file:set_cwd(PrivDir),
%% Replace an existing application.
file:make_dir("./kernel-2.11"),
{ok, Cwd} = file:get_cwd(),
NewDir = Cwd ++ "/kernel-2.11",
- ?line true = code:replace_path(kernel, NewDir),
- ?line NewDir = code:lib_dir(kernel),
- ?line true = code:set_path(P), %Reset path
- ?line ok = file:del_dir("./kernel-2.11"),
+ true = code:replace_path(kernel, NewDir),
+ NewDir = code:lib_dir(kernel),
+ true = code:set_path(P), %Reset path
+ ok = file:del_dir("./kernel-2.11"),
%% Add a completly new application.
NewAppName = 'blurf_blarfer',
- ?line NewAppDir = filename:join(Cwd, atom_to_list(NewAppName) ++ "-6.33.1"),
- ?line ok = file:make_dir(NewAppDir),
- ?line true = code:replace_path(NewAppName, NewAppDir),
- ?line NewAppDir = code:lib_dir(NewAppName),
- ?line NewAppDir = lists:last(code:get_path()),
- ?line true = code:set_path(P), %Reset path
- ?line ok = file:del_dir(NewAppDir),
+ NewAppDir = filename:join(Cwd, atom_to_list(NewAppName) ++ "-6.33.1"),
+ ok = file:make_dir(NewAppDir),
+ true = code:replace_path(NewAppName, NewAppDir),
+ NewAppDir = code:lib_dir(NewAppName),
+ NewAppDir = lists:last(code:get_path()),
+ true = code:set_path(P), %Reset path
+ ok = file:del_dir(NewAppDir),
ok.
dir_disappeared(suite) -> [];
dir_disappeared(doc) -> ["OTP-3977"];
dir_disappeared(Config) when is_list(Config) ->
- ?line PrivDir = ?config(priv_dir, Config),
- ?line Dir = filename:join(PrivDir, "temp"),
- ?line ok = file:make_dir(Dir),
- ?line true = code:add_path(Dir),
- ?line ok = file:del_dir(Dir),
- ?line non_existing = code:which(bubbelskrammel),
+ PrivDir = ?config(priv_dir, Config),
+ Dir = filename:join(PrivDir, "temp"),
+ ok = file:make_dir(Dir),
+ true = code:add_path(Dir),
+ ok = file:del_dir(Dir),
+ non_existing = code:which(bubbelskrammel),
ok.
load_file(suite) -> [];
load_file(doc) -> [];
load_file(Config) when is_list(Config) ->
- ?line {error, nofile} = code:load_file(duuuumy_mod),
- ?line {error, badfile} = code:load_file(code_a_test),
- ?line {'EXIT', _} = (catch code:load_file(123)),
- ?line {module, code_b_test} = code:load_file(code_b_test),
+ {error, nofile} = code:load_file(duuuumy_mod),
+ {error, badfile} = code:load_file(code_a_test),
+ {'EXIT', _} = (catch code:load_file(123)),
+ {module, code_b_test} = code:load_file(code_b_test),
TestDir = test_dir(),
code:stick_dir(TestDir),
- ?line {error, sticky_directory} = code:load_file(code_b_test),
+ {error, sticky_directory} = code:load_file(code_b_test),
code:unstick_dir(TestDir),
ok.
@@ -311,30 +310,30 @@ load_abs(suite) -> [];
load_abs(doc) -> [];
load_abs(Config) when is_list(Config) ->
TestDir = test_dir(),
- ?line {error, nofile} = code:load_abs(TestDir ++ "/duuuumy_mod"),
- ?line {error, badfile} = code:load_abs(TestDir ++ "/code_a_test"),
- ?line {'EXIT', _} = (catch code:load_abs({})),
- ?line {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"),
+ {error, nofile} = code:load_abs(TestDir ++ "/duuuumy_mod"),
+ {error, badfile} = code:load_abs(TestDir ++ "/code_a_test"),
+ {'EXIT', _} = (catch code:load_abs({})),
+ {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"),
code:stick_dir(TestDir),
- ?line {error, sticky_directory} = code:load_abs(TestDir ++ "/code_b_test"),
+ {error, sticky_directory} = code:load_abs(TestDir ++ "/code_b_test"),
code:unstick_dir(TestDir),
ok.
ensure_loaded(suite) -> [];
ensure_loaded(doc) -> [];
ensure_loaded(Config) when is_list(Config) ->
- ?line {module, lists} = code:ensure_loaded(lists),
+ {module, lists} = code:ensure_loaded(lists),
case init:get_argument(mode) of
{ok, [["embedded"]]} ->
- ?line {error, embedded} = code:ensure_loaded(code_b_test),
- ?line {error, badarg} = code:ensure_loaded(34),
+ {error, embedded} = code:ensure_loaded(code_b_test),
+ {error, badarg} = code:ensure_loaded(34),
ok;
_ ->
- ?line {error, nofile} = code:ensure_loaded(duuuumy_mod),
- ?line {error, badfile} = code:ensure_loaded(code_a_test),
- ?line {'EXIT', _} = (catch code:ensure_loaded(34)),
- ?line {module, code_b_test} = code:ensure_loaded(code_b_test),
- ?line {module, code_b_test} = code:ensure_loaded(code_b_test),
+ {error, nofile} = code:ensure_loaded(duuuumy_mod),
+ {error, badfile} = code:ensure_loaded(code_a_test),
+ {'EXIT', _} = (catch code:ensure_loaded(34)),
+ {module, code_b_test} = code:ensure_loaded(code_b_test),
+ {module, code_b_test} = code:ensure_loaded(code_b_test),
ok
end.
@@ -343,15 +342,15 @@ delete(doc) -> [];
delete(Config) when is_list(Config) ->
OldFlag = process_flag(trap_exit, true),
code:purge(code_b_test),
- ?line Pid = code_b_test:do_spawn(),
- ?line true = code:delete(code_b_test),
- ?line {'EXIT',_} = (catch code:delete(122)),
- ?line false = code_b_test:check_exit(Pid),
- ?line false = code:delete(code_b_test),
- ?line false = code_b_test:check_exit(Pid),
+ Pid = code_b_test:do_spawn(),
+ true = code:delete(code_b_test),
+ {'EXIT',_} = (catch code:delete(122)),
+ false = code_b_test:check_exit(Pid),
+ false = code:delete(code_b_test),
+ false = code_b_test:check_exit(Pid),
exit(Pid,kill),
- ?line true = code_b_test:check_exit(Pid),
- ?line false = code:delete(code_b_test),
+ true = code_b_test:check_exit(Pid),
+ false = code:delete(code_b_test),
code:purge(code_b_test),
process_flag(trap_exit, OldFlag),
ok.
@@ -361,31 +360,67 @@ purge(doc) -> [];
purge(Config) when is_list(Config) ->
OldFlag = process_flag(trap_exit, true),
code:purge(code_b_test),
- ?line {'EXIT',_} = (catch code:purge({})),
- ?line false = code:purge(code_b_test),
- ?line Pid = code_b_test:do_spawn(),
- ?line true = code:delete(code_b_test),
- ?line false = code_b_test:check_exit(Pid),
- ?line true = code:purge(code_b_test),
- ?line true = code_b_test:check_exit(Pid),
+ {'EXIT',_} = (catch code:purge({})),
+ false = code:purge(code_b_test),
+ Pid = code_b_test:do_spawn(),
+ true = code:delete(code_b_test),
+ false = code_b_test:check_exit(Pid),
+ true = code:purge(code_b_test),
+ true = code_b_test:check_exit(Pid),
process_flag(trap_exit, OldFlag),
ok.
+purge_many_exits(Config) when is_list(Config) ->
+ OldFlag = process_flag(trap_exit, true),
+ code:purge(code_b_test),
+ {'EXIT',_} = (catch code:purge({})),
+ false = code:purge(code_b_test),
+ TPids = lists:map(fun (_) ->
+ {code_b_test:do_spawn(),
+ spawn_link(fun () ->
+ receive
+ after infinity -> ok
+ end
+ end)}
+ end,
+ lists:seq(1, 1000)),
+ % Give them time to start...
+ receive after 1000 -> ok end,
+ true = code:delete(code_b_test),
+ lists:foreach(fun ({Pid1, Pid2}) ->
+ true = erlang:is_process_alive(Pid1),
+ false = code_b_test:check_exit(Pid1),
+ true = erlang:is_process_alive(Pid2)
+ end, TPids),
+ true = code:purge(code_b_test),
+ lists:foreach(fun ({Pid1, Pid2}) ->
+ false = erlang:is_process_alive(Pid1),
+ true = code_b_test:check_exit(Pid1),
+ true = erlang:is_process_alive(Pid2),
+ exit(Pid2, kill)
+ end, TPids),
+ lists:foreach(fun ({_Pid1, Pid2}) ->
+ receive {'EXIT', Pid2, _} -> ok end
+ end, TPids),
+ process_flag(trap_exit, OldFlag),
+ ok.
+
+
soft_purge(suite) -> [];
soft_purge(doc) -> [];
soft_purge(Config) when is_list(Config) ->
OldFlag = process_flag(trap_exit, true),
code:purge(code_b_test),
- ?line {'EXIT',_} = (catch code:soft_purge(23)),
- ?line true = code:soft_purge(code_b_test),
- ?line Pid = code_b_test:do_spawn(),
- ?line true = code:delete(code_b_test),
- ?line false = code_b_test:check_exit(Pid),
- ?line false = code:soft_purge(code_b_test),
- ?line false = code_b_test:check_exit(Pid),
+ {'EXIT',_} = (catch code:soft_purge(23)),
+ true = code:soft_purge(code_b_test),
+ Pid = code_b_test:do_spawn(),
+ true = code:delete(code_b_test),
+ false = code_b_test:check_exit(Pid),
+ false = code:soft_purge(code_b_test),
+ false = code_b_test:check_exit(Pid),
exit(Pid,kill),
- ?line true = code_b_test:check_exit(Pid),
- ?line true = code:soft_purge(code_b_test),
+ true = code_b_test:check_exit(Pid),
+ true = code:soft_purge(code_b_test),
process_flag(trap_exit, OldFlag),
ok.
@@ -394,12 +429,12 @@ is_loaded(doc) -> [];
is_loaded(Config) when is_list(Config) ->
code:purge(code_b_test),
code:delete(code_b_test),
- ?line false = code:is_loaded(duuuuuumy_mod),
- ?line {'EXIT',_} = (catch code:is_loaded(23)),
- ?line {file, preloaded} = code:is_loaded(init),
+ false = code:is_loaded(duuuuuumy_mod),
+ {'EXIT',_} = (catch code:is_loaded(23)),
+ {file, preloaded} = code:is_loaded(init),
TestDir = test_dir(),
- ?line {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"),
- ?line {file, _Loaded} = code:is_loaded(code_b_test),
+ {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"),
+ {file, _Loaded} = code:is_loaded(code_b_test),
code:purge(code_b_test),
code:delete(code_b_test),
ok.
@@ -413,21 +448,19 @@ all_loaded(Config) when is_list(Config) ->
end.
all_loaded_1() ->
- ?line Preloaded = [{M,preloaded} || M <- lists:sort(erlang:pre_loaded())],
+ Preloaded = [{M,preloaded} || M <- lists:sort(erlang:pre_loaded())],
- ?line Loaded0 = lists:sort(code:all_loaded()),
- ?line all_unique(Loaded0),
- ?line Loaded1 = lists:keysort(2, Loaded0),
- ?line Loaded2 = match_and_remove(Preloaded, Loaded1),
+ Loaded0 = lists:sort(code:all_loaded()),
+ all_unique(Loaded0),
+ Loaded1 = lists:keysort(2, Loaded0),
+ Loaded2 = match_and_remove(Preloaded, Loaded1),
ObjExt = code:objfile_extension(),
- ?line [] = lists:filter(fun({Mod,AbsName}) when is_atom(Mod),
- is_list(AbsName) ->
- Mod =/= list_to_atom(filename:basename(AbsName,
- ObjExt));
- (_) -> true
- end,
- Loaded2),
+ [] = lists:filter(fun
+ ({Mod,AbsName}) when is_atom(Mod), is_list(AbsName) ->
+ Mod =/= list_to_atom(filename:basename(AbsName, ObjExt));
+ (_) -> true
+ end, Loaded2),
ok.
match_and_remove([], List) -> List;
@@ -442,19 +475,19 @@ load_binary(doc) -> [];
load_binary(Config) when is_list(Config) ->
TestDir = test_dir(),
File = TestDir ++ "/code_b_test" ++ code:objfile_extension(),
- ?line {ok,Bin} = file:read_file(File),
- ?line {'EXIT',_} = (catch code:load_binary(12, File, Bin)),
- ?line {'EXIT',_} = (catch code:load_binary(code_b_test, 12, Bin)),
- ?line {'EXIT',_} = (catch code:load_binary(code_b_test, File, 12)),
- ?line {module, code_b_test} = code:load_binary(code_b_test, File, Bin),
+ {ok,Bin} = file:read_file(File),
+ {'EXIT',_} = (catch code:load_binary(12, File, Bin)),
+ {'EXIT',_} = (catch code:load_binary(code_b_test, 12, Bin)),
+ {'EXIT',_} = (catch code:load_binary(code_b_test, File, 12)),
+ {module, code_b_test} = code:load_binary(code_b_test, File, Bin),
code:stick_dir(TestDir),
- ?line {error, sticky_directory} = code:load_binary(code_b_test, File, Bin),
+ {error, sticky_directory} = code:load_binary(code_b_test, File, Bin),
code:unstick_dir(TestDir),
code:purge(code_b_test),
code:delete(code_b_test),
ok.
-upgrade(Config) ->
+upgrade(Config) ->
DataDir = ?config(data_dir, Config),
%%T = [beam, hipe],
@@ -462,28 +495,28 @@ upgrade(Config) ->
[upgrade_do(DataDir, Client, U1, U2, O1, O2)
|| Client<-T, U1<-T, U2<-T, O1<-T, O2<-T],
-
+
ok.
upgrade_do(DataDir, Client, U1, U2, O1, O2) ->
- compile_load(upgrade_client, DataDir, undefined, Client),
+ compile_load(upgrade_client, DataDir, undefined, Client),
upgrade_client:run(DataDir, U1, U2, O1, O2),
ok.
compile_load(Mod, Dir, Ver, CodeType) ->
Version = case Ver of
- undefined ->
- io:format("Compiling '~p' as ~p\n", [Mod, CodeType]),
- [];
- _ ->
- io:format("Compiling version ~p of '~p' as ~p\n",
- [Ver, Mod, CodeType]),
- [{d,list_to_atom("VERSION_" ++ integer_to_list(Ver))}]
- end,
+ undefined ->
+ io:format("Compiling '~p' as ~p\n", [Mod, CodeType]),
+ [];
+ _ ->
+ io:format("Compiling version ~p of '~p' as ~p\n",
+ [Ver, Mod, CodeType]),
+ [{d,list_to_atom("VERSION_" ++ integer_to_list(Ver))}]
+ end,
Target = case CodeType of
- beam -> [];
- hipe -> [native]
- end,
+ beam -> [];
+ hipe -> [native]
+ end,
CompOpts = [binary, report] ++ Target ++ Version,
Src = filename:join(Dir, atom_to_list(Mod) ++ ".erl"),
@@ -497,17 +530,17 @@ compile_load(Mod, Dir, Ver, CodeType) ->
dir_req(suite) -> [];
dir_req(doc) -> [];
dir_req(Config) when is_list(Config) ->
- ?line {ok,[[Root0]]} = init:get_argument(root),
- ?line Root = filename:join([Root0]), % Normalised form.
- ?line Root = code:root_dir(),
+ {ok,[[Root0]]} = init:get_argument(root),
+ Root = filename:join([Root0]), % Normalised form.
+ Root = code:root_dir(),
LibDir = Root ++ "/lib",
- ?line LibDir = code:lib_dir(),
- ?line code:compiler_dir(),
- ?line {error, bad_name} = code:lib_dir(duuumy),
- ?line KernLib = code:lib_dir(kernel),
- ?line Priv = KernLib ++ "/priv",
- ?line Priv = code:priv_dir(kernel),
- ?line {error, bad_name} = code:priv_dir(duuumy),
+ LibDir = code:lib_dir(),
+ code:compiler_dir(),
+ {error, bad_name} = code:lib_dir(duuumy),
+ KernLib = code:lib_dir(kernel),
+ Priv = KernLib ++ "/priv",
+ Priv = code:priv_dir(kernel),
+ {error, bad_name} = code:priv_dir(duuumy),
ok.
object_code(suite) -> [];
@@ -517,19 +550,19 @@ object_code(Config) when is_list(Config) ->
P = code:get_path(),
P = code:get_path(),
code:add_path(TestDir),
- ?line {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"),
+ {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"),
LoadedFile = filename:absname(TestDir ++ "/code_b_test" ++
code:objfile_extension()),
- ?line case code:get_object_code(code_b_test) of
+ case code:get_object_code(code_b_test) of
{code_b_test,Bin,LoadedFile} when is_binary(Bin) ->
ok
end,
code:purge(code_b_test),
code:delete(code_b_test),
- ?line error = code:get_object_code(dddddddduuuuuuumy),
- ?line {'EXIT',_} = (catch code:get_object_code(23)),
- ?line code:set_path(P),
- ?line P=code:get_path(),
+ error = code:get_object_code(dddddddduuuuuuumy),
+ {'EXIT',_} = (catch code:get_object_code(23)),
+ code:set_path(P),
+ P=code:get_path(),
ok.
set_path_file(suite) -> [];
@@ -537,17 +570,17 @@ set_path_file(doc) -> ["Test that set_path does not accept ",
"files as pathnames (known previous bug)"];
set_path_file(Config) when is_list(Config) ->
File=filename:join(?config(priv_dir, Config), "testfil"),
- ?line ok=file:write_file(File, list_to_binary("lite data")),
- ?line {error, bad_directory}=code:set_path([File]).
+ ok=file:write_file(File, list_to_binary("lite data")),
+ {error, bad_directory}=code:set_path([File]).
sticky_dir(suite) -> [];
sticky_dir(doc) -> ["Test that a module with the same name as a module in ",
"a sticky directory cannot be loaded."];
sticky_dir(Config) when is_list(Config) ->
MyDir=filename:dirname(code:which(?MODULE)),
- ?line {ok, Node}=?t:start_node(sticky_dir, slave,[{args, "-pa \""++MyDir++"\""}]),
+ {ok, Node}=?t:start_node(sticky_dir, slave,[{args, "-pa \""++MyDir++"\""}]),
File=filename:join([?config(data_dir, Config), "calendar"]),
- ?line Ret=rpc:call(Node, ?MODULE, sticky_compiler, [File]),
+ Ret=rpc:call(Node, ?MODULE, sticky_compiler, [File]),
case Ret of
fail ->
?t:fail("c:c allowed a sticky module to be compiled and loaded.");
@@ -607,70 +640,70 @@ add_del_path(Config) when is_list(Config) ->
Dir1 = filename:join(DDir,"dummy_app-1.0/ebin"),
Dir2 = filename:join(DDir,"dummy_app-2.0/ebin"),
code:add_patha(Dir1),
- ?line PrivDir1 = filename:join(DDir,"dummy_app-1.0/priv"),
- ?line PrivDir1 = code:priv_dir(dummy_app),
- ?line code:add_path(Dir2), % put last in path
- ?line PrivDir1 = code:priv_dir(dummy_app),
- ?line code:del_path(Dir2),
- ?line PrivDir1 = code:priv_dir(dummy_app),
+ PrivDir1 = filename:join(DDir,"dummy_app-1.0/priv"),
+ PrivDir1 = code:priv_dir(dummy_app),
+ code:add_path(Dir2), % put last in path
+ PrivDir1 = code:priv_dir(dummy_app),
+ code:del_path(Dir2),
+ PrivDir1 = code:priv_dir(dummy_app),
ok.
clash(Config) when is_list(Config) ->
DDir = ?config(data_dir,Config)++"clash/",
P = code:get_path(),
- [TestServerPath|_] = [Path || Path <- code:get_path(),
- re:run(Path,"test_server/?$",[]) /= nomatch],
+ [TestServerPath|_] = [Path || Path <- code:get_path(),
+ re:run(Path,"test_server/?$",[unicode]) /= nomatch],
%% test non-clashing entries
%% remove TestServerPath to prevent clash with test-server path
- ?line true = code:del_path(TestServerPath),
- ?line true = code:add_path(DDir++"foobar-0.1/ebin"),
- ?line true = code:add_path(DDir++"zork-0.8/ebin"),
+ true = code:del_path(TestServerPath),
+ true = code:add_path(DDir++"foobar-0.1/ebin"),
+ true = code:add_path(DDir++"zork-0.8/ebin"),
test_server:capture_start(),
- ?line ok = code:clash(),
+ ok = code:clash(),
test_server:capture_stop(),
- ?line [OKMsg|_] = test_server:capture_get(),
- ?line true = lists:prefix("** Found 0 name clashes", OKMsg),
- ?line true = code:set_path(P),
+ [OKMsg|_] = test_server:capture_get(),
+ true = lists:prefix("** Found 0 name clashes", OKMsg),
+ true = code:set_path(P),
%% test clashing entries
%% remove TestServerPath to prevent clash with test-server path
- ?line true = code:del_path(TestServerPath),
- ?line true = code:add_path(DDir++"foobar-0.1/ebin"),
- ?line true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"),
+ true = code:del_path(TestServerPath),
+ true = code:add_path(DDir++"foobar-0.1/ebin"),
+ true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"),
test_server:capture_start(),
- ?line ok = code:clash(),
+ ok = code:clash(),
test_server:capture_stop(),
- ?line [ClashMsg|_] = test_server:capture_get(),
- ?line {match, [" hides "]} = re:run(ClashMsg, "\\*\\* .*( hides ).*",
+ [ClashMsg|_] = test_server:capture_get(),
+ {match, [" hides "]} = re:run(ClashMsg, "\\*\\* .*( hides ).*",
[{capture,all_but_first,list}]),
- ?line true = code:set_path(P),
+ true = code:set_path(P),
%% test "Bad path can't read"
%% remove TestServerPath to prevent clash with test-server path
Priv = ?config(priv_dir, Config),
- ?line true = code:del_path(TestServerPath),
+ true = code:del_path(TestServerPath),
TmpEzFile = Priv++"foobar-0.tmp.ez",
- ?line {ok, _} = file:copy(DDir++"foobar-0.1.ez", TmpEzFile),
- ?line true = code:add_path(TmpEzFile++"/foobar-0.1/ebin"),
+ {ok, _} = file:copy(DDir++"foobar-0.1.ez", TmpEzFile),
+ true = code:add_path(TmpEzFile++"/foobar-0.1/ebin"),
case os:type() of
{win32,_} ->
- %% The file wont be deleted on windows until it's closed, why we
+ %% The file wont be deleted on windows until it's closed, why we
%% need to rename instead.
- ?line ok = file:rename(TmpEzFile,TmpEzFile++".moved");
+ ok = file:rename(TmpEzFile,TmpEzFile++".moved");
_ ->
- ?line ok = file:delete(TmpEzFile)
+ ok = file:delete(TmpEzFile)
end,
test_server:capture_start(),
- ?line ok = code:clash(),
+ ok = code:clash(),
test_server:capture_stop(),
- ?line [BadPathMsg|_] = test_server:capture_get(),
- ?line true = lists:prefix("** Bad path can't read", BadPathMsg),
- ?line true = code:set_path(P),
+ [BadPathMsg|_] = test_server:capture_get(),
+ true = lists:prefix("** Bad path can't read", BadPathMsg),
+ true = code:set_path(P),
file:delete(TmpEzFile++".moved"), %% Only effect on windows
ok.
@@ -687,7 +720,7 @@ ext_mod_dep(Config) when is_list(Config) ->
xref:add_directory(s, filename:join(code:lib_dir(kernel),"ebin")),
xref:add_directory(s, filename:join(code:lib_dir(stdlib),"ebin")),
case catch ext_mod_dep2() of
- {'EXIT', Reason} ->
+ {'EXIT', Reason} ->
xref:stop(s),
exit(Reason);
Else ->
@@ -699,7 +732,7 @@ ext_mod_dep(Config) when is_list(Config) ->
end.
ext_mod_dep2() ->
- Exports0 = code_server:module_info(exports) --
+ Exports0 = code_server:module_info(exports) --
[{module_info,0},{module_info,1}],
Exports = [{code_server,M,A} || {M,A} <- Exports0],
case analyse(Exports, [], [], 0) of
@@ -709,17 +742,17 @@ ext_mod_dep2() ->
{not_verified,ErrCnt}
end.
-analyse([], [], Visited, ErrCnt) ->
+analyse([], [], Visited, ErrCnt) ->
{Visited,ErrCnt};
analyse([], [This={M,F,A}|Path], Visited, ErrCnt0) ->
%% The code_server has been granted to use the following modules,
- %% These modules should be loaded by code.erl before
+ %% These modules should be loaded by code.erl before
%% the code_server is started.
OK = [erlang, os, prim_file, erl_prim_loader, init, ets,
code_server, lists, lists_sort, unicode, binary, filename,
gb_sets, gb_trees, hipe_unified_loader, hipe_bifs,
prim_zip, zlib],
- ErrCnt1 =
+ ErrCnt1 =
case lists:member(M, OK) or erlang:is_builtin(M,F,A) of
true ->
0;
@@ -729,7 +762,7 @@ analyse([], [This={M,F,A}|Path], Visited, ErrCnt0) ->
{Visited, ErrCnt1+ErrCnt0};
analyse([MFA|R], Path, Visited0, ErrCnt0) ->
case lists:member(MFA,Visited0) of
- false ->
+ false ->
{Visited,ErrCnt1} = analyse2(MFA, Path, Visited0),
analyse(R, Path, Visited, ErrCnt1+ErrCnt0);
true ->
@@ -814,7 +847,7 @@ check_funs({'$M_EXPR','$F_EXPR',_},
{code_server,start_link,1}]) -> 0;
check_funs({'$M_EXPR','$F_EXPR',_},
[{erlang,spawn_link,1},{code_server,start_link,1}]) -> 0;
-check_funs({'$M_EXPR',module_info,1},
+check_funs({'$M_EXPR',module_info,1},
[{hipe_unified_loader,patch_to_emu_step1,1} | _]) -> 0;
check_funs({'$M_EXPR','$F_EXPR',2},
[{lists,foldl,3},
@@ -829,7 +862,7 @@ check_funs({'$M_EXPR','$F_EXPR',1},
check_funs({'$M_EXPR',warning_msg,2},
[{code_server,finish_on_load_report,2} | _]) -> 0;
%% This is cheating! /raimo
-%%
+%%
%% check_funs(This = {M,_,_}, Path) ->
%% case catch atom_to_list(M) of
%% [$h,$i,$p,$e | _] ->
@@ -861,9 +894,9 @@ load_cached(suite) ->
load_cached(doc) ->
[];
load_cached(Config) when is_list(Config) ->
- ?line Priv = ?config(priv_dir, Config),
- ?line WD = filename:dirname(code:which(?MODULE)),
- ?line {ok,Node} =
+ Priv = ?config(priv_dir, Config),
+ WD = filename:dirname(code:which(?MODULE)),
+ {ok,Node} =
?t:start_node(code_cache_node, peer, [{args,
"-pa \"" ++ WD ++ "\""},
{erl, [this]}]),
@@ -873,7 +906,7 @@ load_cached(Config) when is_list(Config) ->
_ -> false
end
end,
- ?line Tabs = rpc:call(Node, ets, all, []),
+ Tabs = rpc:call(Node, ets, all, []),
case rpc:call(Node, lists, any, [CCTabCreated,Tabs]) of
true ->
?t:stop_node(Node),
@@ -881,25 +914,25 @@ load_cached(Config) when is_list(Config) ->
false ->
ok
end,
- ?line rpc:call(Node, code, del_path, [Priv]),
- ?line rpc:call(Node, code, add_pathz, [Priv]),
+ rpc:call(Node, code, del_path, [Priv]),
+ rpc:call(Node, code, add_pathz, [Priv]),
FullModName = Priv ++ "/code_cache_test",
- ?line {ok,Dev} = file:open(FullModName ++ ".erl", [write]),
- ?line io:format(Dev, "-module(code_cache_test). -export([a/0]). a() -> ok.~n", []),
- ?line ok = file:close(Dev),
- ?line {ok,code_cache_test} = compile:file(FullModName, [{outdir,Priv}]),
+ {ok,Dev} = file:open(FullModName ++ ".erl", [write]),
+ io:format(Dev, "-module(code_cache_test). -export([a/0]). a() -> ok.~n", []),
+ ok = file:close(Dev),
+ {ok,code_cache_test} = compile:file(FullModName, [{outdir,Priv}]),
F = fun load_loop/2,
N = 1000,
- ?line {T0,T1} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]),
+ {T0,T1} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]),
TNoCache = now_diff(T1, T0),
- ?line rpc:call(Node, code, rehash, []),
- ?line {T2,T3} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]),
- ?line TCache = now_diff(T3, T2),
+ rpc:call(Node, code, rehash, []),
+ {T2,T3} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]),
+ TCache = now_diff(T3, T2),
AvgNoCache = TNoCache/N,
AvgCache = TCache/N,
- ?line io:format("Avg. load time (no_cache/cache): ~w/~w~n", [AvgNoCache,AvgCache]),
+ io:format("Avg. load time (no_cache/cache): ~w/~w~n", [AvgNoCache,AvgCache]),
?t:stop_node(Node),
if AvgNoCache =< AvgCache ->
?t:fail("Cache not working properly.");
@@ -916,7 +949,7 @@ load_loop(N, M, T0) ->
code:delete(M),
code:purge(M),
load_loop(N-1, M, T0).
-
+
now_diff({A2, B2, C2}, {A1, B1, C1}) ->
((A2-A1)*1000000 + B2-B1)*1000000 + C2-C1.
@@ -925,30 +958,30 @@ start_node_with_cache(suite) ->
start_node_with_cache(doc) ->
[];
start_node_with_cache(Config) when is_list(Config) ->
- ?line {ok,Node} =
- ?t:start_node(code_cache_node, peer, [{args,
+ {ok,Node} =
+ ?t:start_node(code_cache_node, peer, [{args,
"-code_path_cache"},
{erl, [this]}]),
- ?line Tabs = rpc:call(Node, ets, all, []),
+ Tabs = rpc:call(Node, ets, all, []),
io:format("Tabs: ~w~n", [Tabs]),
CCTabCreated = fun(Tab) ->
case rpc:call(Node, ets, info, [Tab,name]) of
code_cache -> true;
_ -> false
end
- end,
- ?line true = lists:any(CCTabCreated, Tabs),
+ end,
+ true = lists:any(CCTabCreated, Tabs),
?t:stop_node(Node),
ok.
-
+
add_and_rehash(suite) ->
[];
add_and_rehash(doc) ->
[];
add_and_rehash(Config) when is_list(Config) ->
- ?line Priv = ?config(priv_dir, Config),
- ?line WD = filename:dirname(code:which(?MODULE)),
- ?line {ok,Node} =
+ Priv = ?config(priv_dir, Config),
+ WD = filename:dirname(code:which(?MODULE)),
+ {ok,Node} =
?t:start_node(code_cache_node, peer, [{args,
"-pa \"" ++ WD ++ "\""},
{erl, [this]}]),
@@ -958,7 +991,7 @@ add_and_rehash(Config) when is_list(Config) ->
_ -> false
end
end,
- ?line Tabs0 = rpc:call(Node, ets, all, []),
+ Tabs0 = rpc:call(Node, ets, all, []),
case rpc:call(Node, lists, any, [CCTabCreated,Tabs0]) of
true ->
?t:stop_node(Node),
@@ -966,36 +999,36 @@ add_and_rehash(Config) when is_list(Config) ->
false ->
ok
end,
- ?line ok = rpc:call(Node, code, rehash, []), % create cache
- ?line Tabs1 = rpc:call(Node, ets, all, []),
- ?line true = rpc:call(Node, lists, any, [CCTabCreated,Tabs1]), % cache table created
- ?line ok = rpc:call(Node, code, rehash, []),
+ ok = rpc:call(Node, code, rehash, []), % create cache
+ Tabs1 = rpc:call(Node, ets, all, []),
+ true = rpc:call(Node, lists, any, [CCTabCreated,Tabs1]), % cache table created
+ ok = rpc:call(Node, code, rehash, []),
OkDir = filename:join(Priv, ""),
BadDir = filename:join(Priv, "guggemuffsussiputt"),
- ?line CP = [OkDir | rpc:call(Node, code, get_path, [])],
- ?line true = rpc:call(Node, code, set_path, [CP]),
+ CP = [OkDir | rpc:call(Node, code, get_path, [])],
+ true = rpc:call(Node, code, set_path, [CP]),
CP1 = [BadDir | CP],
- ?line {error,_} = rpc:call(Node, code, set_path, [CP1]),
- ?line true = rpc:call(Node, code, del_path, [OkDir]),
- ?line true = rpc:call(Node, code, add_path, [OkDir]),
- ?line true = rpc:call(Node, code, add_path, [OkDir]),
- ?line {error,_} = rpc:call(Node, code, add_path, [BadDir]),
- ?line ok = rpc:call(Node, code, rehash, []),
+ {error,_} = rpc:call(Node, code, set_path, [CP1]),
+ true = rpc:call(Node, code, del_path, [OkDir]),
+ true = rpc:call(Node, code, add_path, [OkDir]),
+ true = rpc:call(Node, code, add_path, [OkDir]),
+ {error,_} = rpc:call(Node, code, add_path, [BadDir]),
+ ok = rpc:call(Node, code, rehash, []),
?t:stop_node(Node),
ok.
-
+
where_is_file_no_cache(suite) ->
[];
where_is_file_no_cache(doc) ->
[];
where_is_file_no_cache(Config) when is_list(Config) ->
- ?line {T,KernelBeamFile} = timer:tc(code, where_is_file, ["kernel.beam"]),
+ {T,KernelBeamFile} = timer:tc(code, where_is_file, ["kernel.beam"]),
io:format("Load time: ~w ms~n", [T]),
- ?line KernelEbinDir = filename:dirname(KernelBeamFile),
- ?line AppFile = filename:join(KernelEbinDir, "kernel.app"),
- ?line AppFile = code:where_is_file("kernel.app"),
- ?line non_existing = code:where_is_file("kernel"), % no such file
+ KernelEbinDir = filename:dirname(KernelBeamFile),
+ AppFile = filename:join(KernelEbinDir, "kernel.app"),
+ AppFile = code:where_is_file("kernel.app"),
+ non_existing = code:where_is_file("kernel"), % no such file
ok.
where_is_file_cached(suite) ->
@@ -1003,97 +1036,97 @@ where_is_file_cached(suite) ->
where_is_file_cached(doc) ->
[];
where_is_file_cached(Config) when is_list(Config) ->
- ?line {ok,Node} =
- ?t:start_node(code_cache_node, peer, [{args,
+ {ok,Node} =
+ ?t:start_node(code_cache_node, peer, [{args,
"-code_path_cache"},
{erl, [this]}]),
- ?line Tabs = rpc:call(Node, ets, all, []),
+ Tabs = rpc:call(Node, ets, all, []),
io:format("Tabs: ~w~n", [Tabs]),
CCTabCreated = fun(Tab) ->
case rpc:call(Node, ets, info, [Tab,name]) of
code_cache -> true;
_ -> false
end
- end,
- ?line true = lists:any(CCTabCreated, Tabs),
- ?line KernelBeamFile = rpc:call(Node, code, where_is_file, ["kernel.beam"]),
- ?line {T,KernelBeamFile} = rpc:call(Node, timer, tc, [code,where_is_file,["kernel.beam"]]),
+ end,
+ true = lists:any(CCTabCreated, Tabs),
+ KernelBeamFile = rpc:call(Node, code, where_is_file, ["kernel.beam"]),
+ {T,KernelBeamFile} = rpc:call(Node, timer, tc, [code,where_is_file,["kernel.beam"]]),
io:format("Load time: ~w ms~n", [T]),
- ?line KernelEbinDir = rpc:call(Node, filename, dirname, [KernelBeamFile]),
- ?line AppFile = rpc:call(Node, filename, join, [KernelEbinDir,"kernel.app"]),
- ?line AppFile = rpc:call(Node, code, where_is_file, ["kernel.app"]),
- ?line non_existing = rpc:call(Node, code, where_is_file, ["kernel"]), % no such file
+ KernelEbinDir = rpc:call(Node, filename, dirname, [KernelBeamFile]),
+ AppFile = rpc:call(Node, filename, join, [KernelEbinDir,"kernel.app"]),
+ AppFile = rpc:call(Node, code, where_is_file, ["kernel.app"]),
+ non_existing = rpc:call(Node, code, where_is_file, ["kernel"]), % no such file
?t:stop_node(Node),
ok.
-
+
purge_stacktrace(suite) ->
[];
purge_stacktrace(doc) ->
["Test that stacktrace is deleted when purging a referred module"];
purge_stacktrace(Config) when is_list(Config) ->
- ?line code:purge(code_b_test),
+ code:purge(code_b_test),
try code_b_test:call(fun(b) -> ok end, a)
catch
error:function_clause ->
- ?line code:load_file(code_b_test),
- ?line case erlang:get_stacktrace() of
+ code:load_file(code_b_test),
+ case erlang:get_stacktrace() of
[{?MODULE,_,[a],_},
{code_b_test,call,2,_},
{?MODULE,purge_stacktrace,1,_}|_] ->
- ?line false = code:purge(code_b_test),
- ?line [] = erlang:get_stacktrace()
+ false = code:purge(code_b_test),
+ [] = erlang:get_stacktrace()
end
end,
try code_b_test:call(nofun, 2)
catch
error:function_clause ->
- ?line code:load_file(code_b_test),
- ?line case erlang:get_stacktrace() of
+ code:load_file(code_b_test),
+ case erlang:get_stacktrace() of
[{code_b_test,call,[nofun,2],_},
{?MODULE,purge_stacktrace,1,_}|_] ->
- ?line false = code:purge(code_b_test),
- ?line [] = erlang:get_stacktrace()
+ false = code:purge(code_b_test),
+ [] = erlang:get_stacktrace()
end
end,
Args = [erlang,error,[badarg]],
try code_b_test:call(erlang, error, [badarg,Args])
catch
error:badarg ->
- ?line code:load_file(code_b_test),
- ?line case erlang:get_stacktrace() of
+ code:load_file(code_b_test),
+ case erlang:get_stacktrace() of
[{code_b_test,call,Args,_},
{?MODULE,purge_stacktrace,1,_}|_] ->
- ?line false = code:purge(code_b_test),
- ?line [] = erlang:get_stacktrace()
+ false = code:purge(code_b_test),
+ [] = erlang:get_stacktrace()
end
end,
ok.
mult_lib_roots(Config) when is_list(Config) ->
- ?line DataDir = filename:join(?config(data_dir, Config), "mult_lib_roots"),
- ?line mult_lib_compile(DataDir, "my_dummy_app-b/ebin/lists"),
- ?line mult_lib_compile(DataDir,
+ DataDir = filename:join(?config(data_dir, Config), "mult_lib_roots"),
+ mult_lib_compile(DataDir, "my_dummy_app-b/ebin/lists"),
+ mult_lib_compile(DataDir,
"my_dummy_app-c/ebin/code_SUITE_mult_root_module"),
%% Set up ERL_LIBS and start a slave node.
ErlLibs = filename:join(DataDir, "first_root") ++ mult_lib_sep() ++
filename:join(DataDir, "second_root"),
- ?line {ok,Node} =
+ {ok,Node} =
?t:start_node(mult_lib_roots, slave,
[{args,"-env ERL_LIBS "++ErlLibs}]),
- ?line TSPath = filename:dirname(code:which(test_server)),
- ?line Path0 = rpc:call(Node, code, get_path, []),
- ?line [TSPath,"."|Path1] = Path0,
- ?line [Kernel|Path2] = Path1,
- ?line [Stdlib|Path3] = Path2,
- ?line mult_lib_verify_lib(Kernel, "kernel"),
- ?line mult_lib_verify_lib(Stdlib, "stdlib"),
- ?line [Lib1,Lib2,Lib3,Lib4,Lib5|Path] = Path3,
+ TSPath = filename:dirname(code:which(test_server)),
+ Path0 = rpc:call(Node, code, get_path, []),
+ [TSPath,"."|Path1] = Path0,
+ [Kernel|Path2] = Path1,
+ [Stdlib|Path3] = Path2,
+ mult_lib_verify_lib(Kernel, "kernel"),
+ mult_lib_verify_lib(Stdlib, "stdlib"),
+ [Lib1,Lib2,Lib3,Lib4,Lib5|Path] = Path3,
+
-
["first_root/my_dummy_app-a/ebin",
"first_root/my_dummy_app-b/ebin",
"first_root/my_dummy_app-c/ebin",
@@ -1103,7 +1136,7 @@ mult_lib_roots(Config) when is_list(Config) ->
E <- lists:sort([Lib1,Lib2,Lib3,Lib4,Lib5])],
io:format("~p\n", [Path]),
- ?line true = rpc:call(Node, code_SUITE_mult_root_module, works_fine, []),
+ true = rpc:call(Node, code_SUITE_mult_root_module, works_fine, []),
ok.
@@ -1113,7 +1146,7 @@ mult_lib_compile(Root, Last) ->
Dir = filename:dirname(Name),
{ok,Mod} = compile:file(Name, [report,{outdir,Dir}]),
ok.
-
+
mult_lib_sep() ->
case os:type() of
{win32,_} -> ";";
@@ -1123,23 +1156,23 @@ mult_lib_sep() ->
mult_lib_verify_lib(Path, Expected) ->
Dir = filename:basename(filename:dirname(Path)),
true = lists:prefix(Expected, Dir).
-
+
mult_lib_remove_prefix([H|T1], [H|T2]) ->
mult_lib_remove_prefix(T1, T2);
mult_lib_remove_prefix([$/|T], []) -> T.
bad_erl_libs(Config) when is_list(Config) ->
- ?line {ok,Node} =
+ {ok,Node} =
?t:start_node(mult_lib_roots, slave,
[{args,"-env ERL_LIBS "}]),
- ?line ?t:stop_node(Node),
+ ?t:stop_node(Node),
- ?line {ok,Node2} =
+ {ok,Node2} =
?t:start_node(mult_lib_roots, slave,
[{args,"-env ERL_LIBS /no/such/dir"}]),
- ?line ?t:stop_node(Node2),
+ ?t:stop_node(Node2),
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1158,55 +1191,55 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) ->
PrivDir = ?config(priv_dir, Config),
App = code_archive_dict,
VsnBase = atom_to_list(App) ++ "-1.0",
- Base =
+ Base =
case StripVsn of
true -> atom_to_list(App);
false -> VsnBase
end,
Ext = init:archive_extension(),
RootDir = filename:join([PrivDir, Root]),
- ?line ok = file:make_dir(RootDir),
+ ok = file:make_dir(RootDir),
Archive = filename:join([RootDir, VsnBase ++ Ext]),
- ?line {ok, _} = zip:create(Archive, [VsnBase],
+ {ok, _} = zip:create(Archive, [VsnBase],
[{compress, []}, {cwd, DataDir}]),
- ?line {ok, _} = zip:extract(Archive, [{cwd, PrivDir}]),
+ {ok, _} = zip:extract(Archive, [{cwd, PrivDir}]),
case StripVsn of
true ->
- ?line ok = file:rename(filename:join([PrivDir, VsnBase]),
+ ok = file:rename(filename:join([PrivDir, VsnBase]),
filename:join([PrivDir, Base]));
false ->
ok
end,
-
+
io:format("DEBUG: ~p\n", [?LINE]),
%% Compile the code
- ?line ok = compile_app(PrivDir, Base),
-
+ ok = compile_app(PrivDir, Base),
+
%% Create the archive
- ?line ok = file:delete(Archive),
- ?line {ok, _} = zip:create(Archive, [Base],
+ ok = file:delete(Archive),
+ {ok, _} = zip:create(Archive, [Base],
[{compress, []}, {cwd, PrivDir}]),
%% Set up ERL_LIBS and start a slave node.
- ?line {ok, Node} =
+ {ok, Node} =
?t:start_node(code_archive, slave,
[{args,"-env ERL_LIBS " ++ RootDir}]),
- ?line CodePath = rpc:call(Node, code, get_path, []),
+ CodePath = rpc:call(Node, code, get_path, []),
AppEbin = filename:join([Archive, Base, "ebin"]),
io:format("AppEbin: ~p\n", [AppEbin]),
io:format("CodePath: ~p\n", [CodePath]),
io:format("Archive: ~p\n", [erl_prim_loader:read_file_info(Archive)]),
- ?line true = lists:member(AppEbin, CodePath),
+ true = lists:member(AppEbin, CodePath),
%% Start the app
- ?line ok = rpc:call(Node, application, start, [App]),
-
+ ok = rpc:call(Node, application, start, [App]),
+
%% Access the app priv dir
AppPrivDir = rpc:call(Node, code, priv_dir, [App]),
- ?line AppPrivFile = filename:join([AppPrivDir, "code_archive.txt"]),
+ AppPrivFile = filename:join([AppPrivDir, "code_archive.txt"]),
io:format("AppPrivFile: ~p\n", [AppPrivFile]),
- ?line {ok, _Bin, _Path} =
+ {ok, _Bin, _Path} =
rpc:call(Node, erl_prim_loader, get_file, [AppPrivFile]),
%% Use the app
@@ -1221,14 +1254,14 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) ->
error = rpc:call(Node, App, find, [Tab, Key]),
ok = rpc:call(Node, App, erase, [Tab]),
- ?line ?t:stop_node(Node),
+ ?t:stop_node(Node),
ok.
compile_app(TopDir, AppName) ->
AppDir = filename:join([TopDir, AppName]),
SrcDir = filename:join([AppDir, "src"]),
OutDir = filename:join([AppDir, "ebin"]),
- ?line {ok, Files} = file:list_dir(SrcDir),
+ {ok, Files} = file:list_dir(SrcDir),
compile_files(Files, SrcDir, OutDir).
compile_files([File | Files], SrcDir, OutDir) ->
@@ -1253,27 +1286,27 @@ big_boot_embedded(doc) ->
["Test that a boot file with (almost) all of OTP can be used to start an"
" embeddedd system."];
big_boot_embedded(Config) when is_list(Config) ->
- ?line {BootArg,AppsInBoot} = create_big_boot(Config),
- ?line {ok, Node} =
+ {BootArg,AppsInBoot} = create_big_boot(Config),
+ {ok, Node} =
?t:start_node(big_boot_embedded, slave,
[{args,"-boot "++BootArg++" -mode embedded"}]),
- ?line RemoteNodeApps =
- [ {X,Y} || {X,_,Y} <-
+ RemoteNodeApps =
+ [ {X,Y} || {X,_,Y} <-
rpc:call(Node,application,loaded_applications,[]) ],
- ?line true = lists:sort(AppsInBoot) =:= lists:sort(RemoteNodeApps),
+ true = lists:sort(AppsInBoot) =:= lists:sort(RemoteNodeApps),
ok.
on_load(Config) when is_list(Config) ->
Master = on_load_test_case_process,
- ?line Data = filename:join([?config(data_dir, Config),"on_load"]),
- ?line ok = file:set_cwd(Data),
- ?line up_to_date = make:all([{d,'MASTER',Master}]),
+ Data = filename:join([?config(data_dir, Config),"on_load"]),
+ ok = file:set_cwd(Data),
+ up_to_date = make:all([{d,'MASTER',Master}]),
%% Register a name for this process.
- ?line register(Master, self()),
-
- ?line {_,Ref} = spawn_monitor(fun() ->
+ register(Master, self()),
+
+ {_,Ref} = spawn_monitor(fun() ->
exit(on_load_a:data())
end),
receive
@@ -1285,8 +1318,8 @@ on_load(Config) when is_list(Config) ->
receive
{on_load_c,PidC} -> ok
end,
-
- ?line Refs = on_load_massive_spawn(lists:seq(1, 50)),
+
+ Refs = on_load_massive_spawn(lists:seq(1, 50)),
receive after 7 -> ok end,
PidC ! go,
@@ -1304,13 +1337,13 @@ on_load(Config) when is_list(Config) ->
receive
{'DOWN',Ref,process,_,Res} ->
- ?line [a,b,c] = Res
+ [a,b,c] = Res
end,
on_load_wait_for_all(Refs),
receive
Any ->
- ?line ?t:fail({unexpected,Any})
+ ?t:fail({unexpected,Any})
after 10 ->
ok
end.
@@ -1377,13 +1410,13 @@ on_load_embedded(Config) when is_list(Config) ->
end.
on_load_embedded_1(Config) ->
- ?line DataDir = ?config(data_dir, Config),
+ DataDir = ?config(data_dir, Config),
%% Link the on_load_app application into the lib directory.
- ?line LibRoot = code:lib_dir(),
- ?line LinkName = filename:join(LibRoot, "on_load_app-1.0"),
- ?line OnLoadApp = filename:join(DataDir, "on_load_app-1.0"),
- ?line del_link(LinkName),
+ LibRoot = code:lib_dir(),
+ LinkName = filename:join(LibRoot, "on_load_app-1.0"),
+ OnLoadApp = filename:join(DataDir, "on_load_app-1.0"),
+ del_link(LinkName),
io:format("LinkName :~p, OnLoadApp: ~p~n",[LinkName,OnLoadApp]),
case file:make_symlink(OnLoadApp, LinkName) of
{error,enotsup} ->
@@ -1392,28 +1425,28 @@ on_load_embedded_1(Config) ->
end,
%% Compile the code.
- ?line OnLoadAppEbin = filename:join(LinkName, "ebin"),
- ?line {ok,_ } = compile:file(filename:join([OnLoadApp,"src",
+ OnLoadAppEbin = filename:join(LinkName, "ebin"),
+ {ok,_ } = compile:file(filename:join([OnLoadApp,"src",
"on_load_embedded"]),
[{outdir,OnLoadAppEbin}]),
%% Create and compile a boot file.
- ?line true = code:add_pathz(OnLoadAppEbin),
+ true = code:add_pathz(OnLoadAppEbin),
Options = case is_source_dir() of
true -> [local];
false -> []
end,
- ?line BootScript = create_boot(Config, Options),
- ?line true = code:del_path(OnLoadAppEbin),
+ BootScript = create_boot(Config, Options),
+ true = code:del_path(OnLoadAppEbin),
%% Start the node and check that the on_load function was run.
- ?line {ok,Node} = start_node(on_load_embedded,
+ {ok,Node} = start_node(on_load_embedded,
"-mode embedded -boot " ++ BootScript),
ok = rpc:call(Node, on_load_embedded, status, []),
%% Clean up.
- ?line stop_node(Node),
- ?line ok = del_link(LinkName).
+ stop_node(Node),
+ ok = del_link(LinkName).
del_link(LinkName) ->
case file:delete(LinkName) of
@@ -1421,100 +1454,94 @@ del_link(LinkName) ->
file:del_dir(LinkName);
Other ->
Other
- end.
+ end.
create_boot(Config, Options) ->
- ?line {ok, OldDir} = file:get_cwd(),
- ?line {LatestDir,LatestName} = create_script(Config),
- ?line ok = file:set_cwd(LatestDir),
- ?line ok = systools:make_script(LatestName, Options),
- ?line ok = file:set_cwd(OldDir),
+ {ok, OldDir} = file:get_cwd(),
+ {LatestDir,LatestName} = create_script(Config),
+ ok = file:set_cwd(LatestDir),
+ ok = systools:make_script(LatestName, Options),
+ ok = file:set_cwd(OldDir),
filename:join(LatestDir, LatestName).
create_script(Config) ->
- ?line PrivDir = ?config(priv_dir, Config),
- ?line Name = PrivDir ++ "on_load_test",
- ?line Apps = application_controller:which_applications(),
- ?line {value,{_,_,KernelVer}} = lists:keysearch(kernel, 1, Apps),
- ?line {value,{_,_,StdlibVer}} = lists:keysearch(stdlib, 1, Apps),
- ?line {ok,Fd} = file:open(Name ++ ".rel", [write]),
- ?line io:format(Fd,
+ PrivDir = ?config(priv_dir, Config),
+ Name = PrivDir ++ "on_load_test",
+ Apps = application_controller:which_applications(),
+ {value,{_,_,KernelVer}} = lists:keysearch(kernel, 1, Apps),
+ {value,{_,_,StdlibVer}} = lists:keysearch(stdlib, 1, Apps),
+ {ok,Fd} = file:open(Name ++ ".rel", [write]),
+ io:format(Fd,
"{release, {\"Test release 3\", \"P2A\"}, \n"
" {erts, \"9.42\"}, \n"
" [{kernel, \"~s\"}, {stdlib, \"~s\"},"
" {on_load_app, \"1.0\"}]}.\n",
[KernelVer,StdlibVer]),
- ?line file:close(Fd),
+ file:close(Fd),
{filename:dirname(Name),filename:basename(Name)}.
create_big_boot(Config) ->
- ?line {ok, OldDir} = file:get_cwd(),
- ?line {Options,Local} = case is_source_dir() of
- true -> {[no_module_tests,local],true};
- _ -> {[no_module_tests],false}
+ {ok, OldDir} = file:get_cwd(),
+ {Options,Local} = case is_source_dir() of
+ true -> {[no_module_tests,local],true};
+ _ -> {[no_module_tests],false}
end,
- ?line {LatestDir,LatestName,Apps} = create_big_script(Config,Local),
- ?line ok = file:set_cwd(LatestDir),
- ?line ok = systools:make_script(LatestName, Options),
- ?line ok = file:set_cwd(OldDir),
+ {LatestDir,LatestName,Apps} = create_big_script(Config,Local),
+ ok = file:set_cwd(LatestDir),
+ ok = systools:make_script(LatestName, Options),
+ ok = file:set_cwd(OldDir),
{filename:join(LatestDir, LatestName),Apps}.
-% The following apps cannot be loaded
+% The following apps cannot be loaded
% hipe .app references (or can reference) files that have no
% corresponding beam file (if hipe is not enabled)
-filter_app("hipe",_) ->
- false;
+filter_app("hipe",_) -> false;
% Dialyzer and typer depends on hipe
-filter_app("dialyzer",_) ->
- false;
-filter_app("typer",_) ->
- false;
+filter_app("dialyzer",_) -> false;
+filter_app("typer",_) -> false;
% Orber requires explicit configuration
-filter_app("orber",_) ->
- false;
+filter_app("orber",_) -> false;
% cos* depends on orber
-filter_app("cos"++_,_) ->
- false;
+filter_app("cos"++_,_) -> false;
% ic has a mod instruction in the app file but no corresponding start function
-filter_app("ic",_) ->
- false;
+filter_app("ic",_) -> false;
% Netconf has some dependency that I really do not understand (maybe like orber)
-filter_app("netconf",_) ->
- false;
+filter_app("netconf",_) -> false;
% Safe has the same kind of error in the .app file as ic
-filter_app("safe",_) ->
- false;
+filter_app("safe",_) -> false;
% Comte cannot be started in the "usual" way
-filter_app("comte",_) ->
- false;
+filter_app("comte",_) -> false;
% OS_mon does not find it's port program when running cerl
-filter_app("os_mon",true) ->
- false;
+filter_app("os_mon",true) -> false;
+% erts is not a "real" app either =/
+filter_app("erts",_) -> false;
% Other apps should be OK.
-filter_app(_,_) ->
- true.
+filter_app(_,_) -> true.
create_big_script(Config,Local) ->
- ?line PrivDir = ?config(priv_dir, Config),
- ?line Name = filename:join(PrivDir,"full_script_test"),
- ?line InitialApplications=application:loaded_applications(),
+ PrivDir = ?config(priv_dir, Config),
+ Name = filename:join(PrivDir,"full_script_test"),
+ InitialApplications=application:loaded_applications(),
%% Applications left loaded by the application suite, unload them!
- ?line UnloadFix=[app0,app1,app2,group_leader,app_start_error],
- ?line [application:unload(Leftover) ||
+ UnloadFix=[app0,app1,app2,group_leader,app_start_error],
+ [application:unload(Leftover) ||
Leftover <- UnloadFix,
lists:keymember(Leftover,1,InitialApplications) ],
%% Now we should have only "real" applications...
- ?line [application:load(list_to_atom(Y)) || {match,[Y]} <- [ re:run(X,code:lib_dir()++"/"++"([^/-]*).*/ebin",[{capture,[1],list}]) || X <- code:get_path()],filter_app(Y,Local)],
- ?line Apps = [ {N,V} || {N,_,V} <- application:loaded_applications()],
- ?line {ok,Fd} = file:open(Name ++ ".rel", [write]),
- ?line io:format(Fd,
+ [application:load(list_to_atom(Y))
+ || {match,[Y]} <- [re:run(X,code:lib_dir()++"/"++"([^/-]*).*/ebin",
+ [{capture,[1],list},unicode]) ||
+ X <- code:get_path()],filter_app(Y,Local)],
+ Apps = [ {N,V} || {N,_,V} <- application:loaded_applications()],
+ {ok,Fd} = file:open(Name ++ ".rel", [write]),
+ io:format(Fd,
"{release, {\"Test release 3\", \"P2A\"}, \n"
" {erts, \"9.42\"}, \n"
" ~p}.\n",
[Apps]),
- ?line file:close(Fd),
- ?line NewlyLoaded =
+ file:close(Fd),
+ NewlyLoaded =
application:loaded_applications() -- InitialApplications,
- ?line [ application:unload(N) || {N,_,_} <- NewlyLoaded],
+ [ application:unload(N) || {N,_,_} <- NewlyLoaded],
{filename:dirname(Name),filename:basename(Name),Apps}.
is_source_dir() ->
@@ -1523,35 +1550,35 @@ is_source_dir() ->
on_load_errors(Config) when is_list(Config) ->
Master = on_load_error_test_case_process,
- ?line register(Master, self()),
+ register(Master, self()),
- ?line Data = filename:join([?config(data_dir, Config),"on_load_errors"]),
- ?line ok = file:set_cwd(Data),
- ?line up_to_date = make:all([{d,'MASTER',Master}]),
+ Data = filename:join([?config(data_dir, Config),"on_load_errors"]),
+ ok = file:set_cwd(Data),
+ up_to_date = make:all([{d,'MASTER',Master}]),
- ?line do_on_load_error(an_atom),
+ do_on_load_error(an_atom),
- ?line error_logger:add_report_handler(?MODULE, self()),
+ error_logger:add_report_handler(?MODULE, self()),
- ?line do_on_load_error({something,terrible,is,wrong}),
+ do_on_load_error({something,terrible,is,wrong}),
receive
Any1 ->
- ?line {_, "The on_load function"++_,
+ {_, "The on_load function"++_,
[on_load_error,
{something,terrible,is,wrong},_]} = Any1
end,
- ?line do_on_load_error(fail), %Cause exception.
+ do_on_load_error(fail), %Cause exception.
receive
Any2 ->
- ?line {_, "The on_load function"++_,
+ {_, "The on_load function"++_,
[on_load_error,{failed,[_|_]},_]} = Any2
end,
%% There should be no more messages.
receive
Unexpected ->
- ?line ?t:fail({unexpected,Unexpected})
+ ?t:fail({unexpected,Unexpected})
after 10 ->
ok
end,
@@ -1559,14 +1586,14 @@ on_load_errors(Config) when is_list(Config) ->
ok.
do_on_load_error(ReturnValue) ->
- ?line {_,Ref} = spawn_monitor(fun() ->
+ {_,Ref} = spawn_monitor(fun() ->
exit(on_load_error:main())
end),
receive {on_load_error,ErrorPid} -> ok end,
- ?line ErrorPid ! ReturnValue,
+ ErrorPid ! ReturnValue,
receive
{'DOWN',Ref,process,_,Exit} ->
- ?line {undef,[{on_load_error,main,[],_}|_]} = Exit
+ {undef,[{on_load_error,main,[],_}|_]} = Exit
end.
native_early_modules(suite) -> [];
@@ -1580,10 +1607,10 @@ native_early_modules(Config) when is_list(Config) ->
end.
native_early_modules_1(Architecture) ->
- ?line {lists, ListsBinary, _ListsFilename} = code:get_object_code(lists),
- ?line ChunkName = hipe_unified_loader:chunk_name(Architecture),
- ?line NativeChunk = beam_lib:chunks(ListsBinary, [ChunkName]),
- ?line IsHipeCompiled = case NativeChunk of
+ {lists, ListsBinary, _ListsFilename} = code:get_object_code(lists),
+ ChunkName = hipe_unified_loader:chunk_name(Architecture),
+ NativeChunk = beam_lib:chunks(ListsBinary, [ChunkName]),
+ IsHipeCompiled = case NativeChunk of
{ok,{_,[{_,Bin}]}} when is_binary(Bin) -> true;
{error, beam_lib, _} -> false
end,
@@ -1591,10 +1618,10 @@ native_early_modules_1(Architecture) ->
false ->
{skip,"OTP apparently not configured with --enable-native-libs"};
true ->
- ?line true = lists:all(fun code:is_module_native/1,
- [ets,file,filename,gb_sets,gb_trees,
- %%hipe_unified_loader, no_native as workaround
- lists,os]),
+ true = lists:all(fun code:is_module_native/1,
+ [ets,file,filename,gb_sets,gb_trees,
+ %%hipe_unified_loader, no_native as workaround
+ lists,os]),
ok
end.
diff --git a/lib/kernel/test/erl_prim_loader_SUITE.erl b/lib/kernel/test/erl_prim_loader_SUITE.erl
index 35502a1d27..b2ca3bdbc2 100644
--- a/lib/kernel/test/erl_prim_loader_SUITE.erl
+++ b/lib/kernel/test/erl_prim_loader_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -24,7 +24,7 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).
--export([get_path/1, set_path/1, get_file/1,
+-export([get_path/1, set_path/1, get_file/1, normalize_and_backslash/1,
inet_existing/1, inet_coming_up/1, inet_disconnects/1,
multiple_slaves/1, file_requests/1,
local_archive/1, remote_archive/1,
@@ -39,7 +39,8 @@
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [get_path, set_path, get_file, inet_existing,
+ [get_path, set_path, get_file,
+ normalize_and_backslash, inet_existing,
inet_coming_up, inet_disconnects, multiple_slaves,
file_requests, local_archive, remote_archive,
primary_archive, virtual_dir_in_archive].
@@ -107,6 +108,26 @@ get_file(Config) when is_list(Config) ->
?line error = erl_prim_loader:get_file({dummy}),
ok.
+normalize_and_backslash(Config) ->
+ %% Test OTP-11170
+ case os:type() of
+ {win32,_} ->
+ {skip, "not on windows"};
+ _ ->
+ test_normalize_and_backslash(Config)
+ end.
+test_normalize_and_backslash(Config) ->
+ PrivDir = ?config(priv_dir,Config),
+ Dir = filename:join(PrivDir,"\\"),
+ File = filename:join(Dir,"file-OTP-11170"),
+ ok = file:make_dir(Dir),
+ ok = file:write_file(File,"a file to test OTP-11170"),
+ {ok,["file-OTP-11170"]} = file:list_dir(Dir),
+ {ok,["file-OTP-11170"]} = erl_prim_loader:list_dir(Dir),
+ ok = file:delete(File),
+ ok = file:del_dir(Dir),
+ ok.
+
inet_existing(doc) -> ["Start a node using the 'inet' loading method, ",
"from an already started boot server."];
inet_existing(Config) when is_list(Config) ->
diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl
index e4c8f0ffaf..c75639ae7e 100644
--- a/lib/kernel/test/file_SUITE.erl
+++ b/lib/kernel/test/file_SUITE.erl
@@ -805,6 +805,20 @@ new_modes(Config) when is_list(Config) ->
?line {ok, [$\[]} = ?FILE_MODULE:read(Fd6, 1),
?line ok = ?FILE_MODULE:close(Fd6),
+ %% write and sync
+ case ?FILE_MODULE:open(Name1, [write, sync]) of
+ {ok, Fd7} ->
+ ok = io:write(Fd7, Marker),
+ ok = io:put_chars(Fd7, ".\n"),
+ ok = ?FILE_MODULE:close(Fd7),
+ {ok, Fd8} = ?FILE_MODULE:open(Name1, [read]),
+ {ok, Marker} = io:read(Fd8, prompt),
+ ok = ?FILE_MODULE:close(Fd8);
+ {error, enotsup} ->
+ %% for platforms that don't support the sync option
+ ok
+ end,
+
?line [] = flush(),
?line test_server:timetrap_cancel(Dog),
ok.
diff --git a/lib/kernel/test/file_name_SUITE.erl b/lib/kernel/test/file_name_SUITE.erl
index 0c8082026a..9354af2e41 100644
--- a/lib/kernel/test/file_name_SUITE.erl
+++ b/lib/kernel/test/file_name_SUITE.erl
@@ -1,5 +1,4 @@
-module(file_name_SUITE).
-%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl
index e89cb44797..881aaed429 100644
--- a/lib/kernel/test/gen_sctp_SUITE.erl
+++ b/lib/kernel/test/gen_sctp_SUITE.erl
@@ -1,4 +1,4 @@
-%%
+%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2007-2013. All Rights Reserved.
@@ -35,8 +35,11 @@
open_unihoming_ipv6_socket/1,
open_multihoming_ipv6_socket/1,
open_multihoming_ipv4_and_ipv6_socket/1,
- basic_stream/1, xfer_stream_min/1, peeloff_active_once/1,
- peeloff_active_true/1, buffers/1]).
+ basic_stream/1, xfer_stream_min/1, active_n/1,
+ peeloff_active_once/1, peeloff_active_true/1, peeloff_active_n/1,
+ buffers/1,
+ names_unihoming_ipv4/1, names_unihoming_ipv6/1,
+ names_multihoming_ipv4/1, names_multihoming_ipv6/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
@@ -46,9 +49,11 @@ all() ->
open_multihoming_ipv4_socket,
open_unihoming_ipv6_socket,
open_multihoming_ipv6_socket,
- open_multihoming_ipv4_and_ipv6_socket,
+ open_multihoming_ipv4_and_ipv6_socket, active_n,
basic_stream, xfer_stream_min, peeloff_active_once,
- peeloff_active_true, buffers].
+ peeloff_active_true, peeloff_active_n, buffers,
+ names_unihoming_ipv4, names_unihoming_ipv6,
+ names_multihoming_ipv4, names_multihoming_ipv6].
groups() ->
[].
@@ -107,7 +112,7 @@ xfer_min(Config) when is_list(Config) ->
?line {ok,Sb} = gen_sctp:open([{type,seqpacket}]),
?line {ok,Pb} = inet:port(Sb),
?line ok = gen_sctp:listen(Sb, true),
-
+
?line {ok,Sa} = gen_sctp:open(),
?line {ok,Pa} = inet:port(Sa),
?line {ok,#sctp_assoc_change{state=comm_up,
@@ -118,18 +123,18 @@ xfer_min(Config) when is_list(Config) ->
gen_sctp:connect(Sa, Loopback, Pb, []),
?line {SbAssocId,SaOutboundStreams,SaInboundStreams} =
case recv_event(log_ok(gen_sctp:recv(Sb, infinity))) of
- {Loopback,Pa,
- #sctp_assoc_change{state=comm_up,
- error=0,
- outbound_streams=SbOutboundStreams,
- inbound_streams=SbInboundStreams,
- assoc_id=AssocId}} ->
- {AssocId,SbInboundStreams,SbOutboundStreams};
- {Loopback,Pa,
- #sctp_paddr_change{state=addr_confirmed,
- addr={Loopback,Pa},
- error=0,
- assoc_id=AssocId}} ->
+ {Loopback,Pa,
+ #sctp_assoc_change{state=comm_up,
+ error=0,
+ outbound_streams=SbOutboundStreams,
+ inbound_streams=SbInboundStreams,
+ assoc_id=AssocId}} ->
+ {AssocId,SbInboundStreams,SbOutboundStreams};
+ {Loopback,Pa,
+ #sctp_paddr_change{state=addr_confirmed,
+ addr={Loopback,Pa},
+ error=0,
+ assoc_id=AssocId}} ->
{Loopback,Pa,
#sctp_assoc_change{state=comm_up,
error=0,
@@ -148,17 +153,20 @@ xfer_min(Config) when is_list(Config) ->
assoc_id=SbAssocId}],
Data} -> ok;
Event1 ->
- {Loopback,Pa,
- #sctp_paddr_change{addr = {Loopback,_},
- state = addr_available,
- error = 0,
- assoc_id = SbAssocId}} =
- recv_event(Event1),
- {ok,{Loopback,
- Pa,
- [#sctp_sndrcvinfo{stream=Stream,
- assoc_id=SbAssocId}],
- Data}} = gen_sctp:recv(Sb, infinity)
+ case recv_event(Event1) of
+ {Loopback,Pa,
+ #sctp_paddr_change{addr = {Loopback,_},
+ state = State,
+ error = 0,
+ assoc_id = SbAssocId}}
+ when State =:= addr_available;
+ State =:= addr_confirmed ->
+ {Loopback,
+ Pa,
+ [#sctp_sndrcvinfo{stream=Stream,
+ assoc_id=SbAssocId}],
+ Data} = log_ok(gen_sctp:recv(Sb, infinity))
+ end
end,
?line ok = gen_sctp:send(Sb, SbAssocId, 0, Data),
?line case log_ok(gen_sctp:recv(Sa, infinity)) of
@@ -197,7 +205,7 @@ xfer_min(Config) when is_list(Config) ->
recv_event(log_ok(gen_sctp:recv(Sb, infinity))),
?line ok = gen_sctp:close(Sa),
?line ok = gen_sctp:close(Sb),
-
+
?line receive
Msg -> test_server:fail({received,Msg})
after 17 -> ok
@@ -216,7 +224,7 @@ xfer_active(Config) when is_list(Config) ->
?line {ok,Sb} = gen_sctp:open([{active,true}]),
?line {ok,Pb} = inet:port(Sb),
?line ok = gen_sctp:listen(Sb, true),
-
+
?line {ok,Sa} = gen_sctp:open([{active,true}]),
?line {ok,Pa} = inet:port(Sa),
?line ok = gen_sctp:connect_init(Sa, Loopback, Pb, []),
@@ -348,7 +356,7 @@ def_sndrcvinfo(Config) when is_list(Config) ->
%%
?line S1 =
log_ok(gen_sctp:open(
- 0, [{sctp_default_send_param,#sctp_sndrcvinfo{ppid=17}}])),
+ 0, [{sctp_default_send_param,#sctp_sndrcvinfo{ppid=17}}])),
?LOGVAR(S1),
?line P1 =
log_ok(inet:port(S1)),
@@ -455,18 +463,22 @@ def_sndrcvinfo(Config) when is_list(Config) ->
stream=1, ppid=0, context=0, assoc_id=S1AssocId}],
<<"3: ",Data/binary>>} -> ok;
Event2 ->
- {Loopback,P2,
- #sctp_paddr_change{
- addr={Loopback,_}, state=addr_available,
- error=0, assoc_id=S1AssocId}} =
- recv_event(Event2),
- ?line case log_ok(gen_sctp:recv(S1)) of
- {Loopback,P2,
- [#sctp_sndrcvinfo{
- stream=1, ppid=0, context=0,
- assoc_id=S1AssocId}],
- <<"3: ",Data/binary>>} -> ok
- end
+ case recv_event(Event2) of
+ {Loopback,P2,
+ #sctp_paddr_change{
+ addr={Loopback,_},
+ state=State,
+ error=0, assoc_id=S1AssocId}}
+ when State =:= addr_available;
+ State =:= addr_confirmed ->
+ ?line case log_ok(gen_sctp:recv(S1)) of
+ {Loopback,P2,
+ [#sctp_sndrcvinfo{
+ stream=1, ppid=0, context=0,
+ assoc_id=S1AssocId}],
+ <<"3: ",Data/binary>>} -> ok
+ end
+ end
end,
?line ok =
do_from_other_process(
@@ -509,6 +521,13 @@ log_ok(X) -> log(ok(X)).
ok({ok,X}) -> X.
+err([], Result) ->
+ erlang:error(Result);
+err([Reason|_], {error,Reason}) ->
+ ok;
+err([_|Reasons], Result) ->
+ err(Reasons, Result).
+
log(X) ->
io:format("LOG[~w]: ~p~n", [self(),X]),
X.
@@ -529,57 +548,57 @@ api_open_close(Config) when is_list(Config) ->
?line {ok,S1} = gen_sctp:open(0),
?line {ok,P} = inet:port(S1),
?line ok = gen_sctp:close(S1),
-
+
?line {ok,S2} = gen_sctp:open(P),
?line {ok,P} = inet:port(S2),
?line ok = gen_sctp:close(S2),
-
+
?line {ok,S3} = gen_sctp:open([{port,P}]),
?line {ok,P} = inet:port(S3),
?line ok = gen_sctp:close(S3),
-
+
?line {ok,S4} = gen_sctp:open(P, []),
?line {ok,P} = inet:port(S4),
?line ok = gen_sctp:close(S4),
-
+
?line {ok,S5} = gen_sctp:open(P, [{ifaddr,any}]),
?line {ok,P} = inet:port(S5),
?line ok = gen_sctp:close(S5),
?line ok = gen_sctp:close(S5),
-
+
?line try gen_sctp:close(0)
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open({})
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open(-1)
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open(65536)
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open(make_ref(), [])
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open(0, {})
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open(0, [make_ref()])
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open([{invalid_option,0}])
catch error:badarg -> ok
end,
-
+
?line try gen_sctp:open(0, [{mode,invalid_mode}])
catch error:badarg -> ok
end,
@@ -591,11 +610,11 @@ api_listen(suite) ->
[];
api_listen(Config) when is_list(Config) ->
?line Localhost = {127,0,0,1},
-
+
?line try gen_sctp:listen(0, true)
catch error:badarg -> ok
end,
-
+
?line {ok,S} = gen_sctp:open(),
?line {ok,Pb} = inet:port(S),
?line try gen_sctp:listen(S, not_allowed_for_listen)
@@ -603,7 +622,7 @@ api_listen(Config) when is_list(Config) ->
end,
?line ok = gen_sctp:close(S),
?line {error,closed} = gen_sctp:listen(S, true),
-
+
?line {ok,Sb} = gen_sctp:open(Pb),
?line {ok,Sa} = gen_sctp:open(),
?line case gen_sctp:connect(Sa, localhost, Pb, []) of
@@ -615,8 +634,8 @@ api_listen(Config) when is_list(Config) ->
gen_sctp:recv(Sa, infinity);
{error,#sctp_assoc_change{state=cant_assoc}} ->
ok%;
- %% {error,{Localhost,Pb,_,#sctp_assoc_change{state=cant_assoc}}} ->
- %% ok
+ %% {error,{Localhost,Pb,_,#sctp_assoc_change{state=cant_assoc}}} ->
+ %% ok
end,
?line ok = gen_sctp:listen(Sb, true),
?line {ok,#sctp_assoc_change{state=comm_up,
@@ -767,6 +786,106 @@ implicit_inet6(S1, Addr) ->
end,
?line ok = gen_sctp:close(S2).
+active_n(doc) ->
+ "Verify {active,N} socket management";
+active_n(suite) ->
+ [];
+active_n(Config) when is_list(Config) ->
+ N = 3,
+ S1 = ok(gen_sctp:open([{active,N}])),
+ [{active,N}] = ok(inet:getopts(S1, [active])),
+ ok = inet:setopts(S1, [{active,-N}]),
+ receive
+ {sctp_passive, S1} -> ok
+ after
+ 5000 ->
+ exit({error,sctp_passive_failure})
+ end,
+ [{active,false}] = ok(inet:getopts(S1, [active])),
+ ok = inet:setopts(S1, [{active,0}]),
+ receive
+ {sctp_passive, S1} -> ok
+ after
+ 5000 ->
+ exit({error,sctp_passive_failure})
+ end,
+ ok = inet:setopts(S1, [{active,32767}]),
+ {error,einval} = inet:setopts(S1, [{active,1}]),
+ {error,einval} = inet:setopts(S1, [{active,-32769}]),
+ ok = inet:setopts(S1, [{active,-32768}]),
+ receive
+ {sctp_passive, S1} -> ok
+ after
+ 5000 ->
+ exit({error,sctp_passive_failure})
+ end,
+ [{active,false}] = ok(inet:getopts(S1, [active])),
+ ok = inet:setopts(S1, [{active,N}]),
+ ok = inet:setopts(S1, [{active,true}]),
+ [{active,true}] = ok(inet:getopts(S1, [active])),
+ receive
+ _ -> exit({error,active_n})
+ after
+ 0 ->
+ ok
+ end,
+ ok = inet:setopts(S1, [{active,N}]),
+ ok = inet:setopts(S1, [{active,once}]),
+ [{active,once}] = ok(inet:getopts(S1, [active])),
+ receive
+ _ -> exit({error,active_n})
+ after
+ 0 ->
+ ok
+ end,
+ {error,einval} = inet:setopts(S1, [{active,32768}]),
+ ok = inet:setopts(S1, [{active,false}]),
+ [{active,false}] = ok(inet:getopts(S1, [active])),
+ ok = gen_sctp:listen(S1, true),
+ S1Port = ok(inet:port(S1)),
+ S2 = ok(gen_sctp:open(0, [{active,false}])),
+ Assoc = ok(gen_sctp:connect(S2, "localhost", S1Port, [])),
+ ok = inet:setopts(S1, [{active,N}]),
+ [{active,N}] = ok(inet:getopts(S1, [active])),
+ LoopFun = fun(Count, Count, _Fn) ->
+ receive
+ {sctp_passive,S1} ->
+ ok
+ after
+ 5000 ->
+ exit({error,timeout})
+ end;
+ (I, Count, Fn) ->
+ Msg = list_to_binary("message "++integer_to_list(I)),
+ ok = gen_sctp:send(S2, Assoc, 0, Msg),
+ receive
+ {sctp,S1,_,_,{[SR],Msg}} when is_record(SR, sctp_sndrcvinfo) ->
+ Fn(I+1, Count, Fn);
+ {sctp,S1,_,_,_} ->
+ %% ignore non-data messages
+ ok = inet:setopts(S1, [{active,1}]),
+ Fn(I, Count, Fn);
+ Other ->
+ exit({unexpected, Other})
+ after
+ 5000 ->
+ exit({error,timeout})
+ end
+ end,
+ ok = LoopFun(1, N, LoopFun),
+ S3 = ok(gen_sctp:open([{active,0}])),
+ receive
+ {sctp_passive,S3} ->
+ [{active,false}] = ok(inet:getopts(S3, [active]))
+ after
+ 5000 ->
+ exit({error,udp_passive})
+ end,
+ ok = gen_sctp:close(S3),
+ ok = gen_sctp:close(S2),
+ ok = gen_sctp:close(S1),
+ ok.
+
basic_stream(doc) ->
"Hello world stream socket";
basic_stream(suite) ->
@@ -840,23 +959,36 @@ xfer_stream_min(Config) when is_list(Config) ->
?line SbOutboundStreams = SaInboundStreams,
?line ?LOGVAR(SbOutboundStreams),
?line ok = gen_sctp:send(Sa, SaAssocId, 0, Data),
- ?line case gen_sctp:recv(Sb, infinity) of
- {ok,{Loopback,
+ ?line case log_ok(gen_sctp:recv(Sb, infinity)) of
+ {Loopback,
+ Pa,
+ [#sctp_sndrcvinfo{stream=Stream,
+ assoc_id=SbAssocId}],
+ Data} -> ok;
+ {Loopback,
+ Pa,[],
+ #sctp_paddr_change{addr = {Loopback,_},
+ state = addr_available,
+ error = 0,
+ assoc_id = SbAssocId}} ->
+ {Loopback,
Pa,
[#sctp_sndrcvinfo{stream=Stream,
assoc_id=SbAssocId}],
- Data}} -> ok;
- {ok,{Loopback,
- Pa,[],
- #sctp_paddr_change{addr = {Loopback,_},
- state = addr_available,
- error = 0,
- assoc_id = SbAssocId}}} ->
- {ok,{Loopback,
- Pa,
- [#sctp_sndrcvinfo{stream=Stream,
- assoc_id=SbAssocId}],
- Data}} = gen_sctp:recv(Sb, infinity)
+ Data} = log_ok(gen_sctp:recv(Sb, infinity));
+ {Loopback,
+ Pa,
+ [#sctp_sndrcvinfo{stream=Stream,
+ assoc_id=SbAssocId}],
+ #sctp_paddr_change{addr = {Loopback,_},
+ state = addr_confirmed,
+ error = 0,
+ assoc_id = SbAssocId}} ->
+ {Loopback,
+ Pa,
+ [#sctp_sndrcvinfo{stream=Stream,
+ assoc_id=SbAssocId}],
+ Data} = log_ok(gen_sctp:recv(Sb, infinity))
end,
?line ok =
do_from_other_process(
@@ -941,6 +1073,14 @@ peeloff_active_true(suite) ->
peeloff_active_true(Config) ->
peeloff(Config, [{active,true}]).
+peeloff_active_n(doc) ->
+ "Peel off an SCTP stream socket ({active,N})";
+peeloff_active_n(suite) ->
+ [];
+
+peeloff_active_n(Config) ->
+ peeloff(Config, [{active,1}]).
+
peeloff(Config, SockOpts) when is_list(Config) ->
?line Addr = {127,0,0,1},
?line Stream = 0,
@@ -972,10 +1112,10 @@ peeloff(Config, SockOpts) when is_list(Config) ->
?line ?LOGVAR(S2Ai),
?line S1Ai =
receive
- {S1,{Addr,P2,
- #sctp_assoc_change{
- state=comm_up,
- assoc_id=AssocId1}}} -> AssocId1
+ {S1,{Addr,P2,
+ #sctp_assoc_change{
+ state=comm_up,
+ assoc_id=AssocId1}}} -> AssocId1
after Timeout ->
socket_bailout([S1,S2])
end,
@@ -1003,8 +1143,8 @@ peeloff(Config, SockOpts) when is_list(Config) ->
?line P3 = case P3_X of 0 -> P1; _ -> P3_X end,
?line [{_,#sctp_paddrinfo{assoc_id=S3Ai,state=active}}] =
socket_call(S3,
- {getopts,[{sctp_get_peer_addr_info,
- #sctp_paddrinfo{address={Addr,P2}}}]}),
+ {getopts,[{sctp_get_peer_addr_info,
+ #sctp_paddrinfo{address={Addr,P2}}}]}),
%%?line S3Ai = S1Ai,
?line ?LOGVAR(S3Ai),
%%
@@ -1087,9 +1227,9 @@ buffers(Config) when is_list(Config) ->
%%
?line socket_call(S1, {setopts,[{recbuf,Limit}]}),
?line Recbuf =
- case socket_call(S1, {getopts,[recbuf]}) of
- [{recbuf,RB1}] when RB1 >= Limit -> RB1
- end,
+ case socket_call(S1, {getopts,[recbuf]}) of
+ [{recbuf,RB1}] when RB1 >= Limit -> RB1
+ end,
?line Data = mk_data(Recbuf+Limit),
?line socket_call(S2, {setopts,[{sndbuf,Recbuf+Limit}]}),
?line socket_call(S2, {send,S2Ai,Stream,Data}),
@@ -1190,6 +1330,93 @@ open_multihoming_ipv4_and_ipv6_socket(Config) when is_list(Config) ->
{skip, Reason}
end.
+names_unihoming_ipv4(doc) ->
+ "Test inet:socknames/peernames on unihoming IPv4 sockets";
+names_unihoming_ipv4(suite) ->
+ [];
+names_unihoming_ipv4(Config) when is_list(Config) ->
+ ?line do_names(Config, inet, 1).
+
+names_unihoming_ipv6(doc) ->
+ "Test inet:socknames/peernames on unihoming IPv6 sockets";
+names_unihoming_ipv6(suite) ->
+ [];
+names_unihoming_ipv6(Config) when is_list(Config) ->
+ ?line do_names(Config, inet6, 1).
+
+names_multihoming_ipv4(doc) ->
+ "Test inet:socknames/peernames on multihoming IPv4 sockets";
+names_multihoming_ipv4(suite) ->
+ [];
+names_multihoming_ipv4(Config) when is_list(Config) ->
+ ?line do_names(Config, inet, 2).
+
+names_multihoming_ipv6(doc) ->
+ "Test inet:socknames/peernames on multihoming IPv6 sockets";
+names_multihoming_ipv6(suite) ->
+ [];
+names_multihoming_ipv6(Config) when is_list(Config) ->
+ ?line do_names(Config, inet6, 2).
+
+
+
+do_names(_, FamilySpec, AddressCount) ->
+ Fun =
+ fun (ServerSocket, _, ServerAssoc, ClientSocket, _, ClientAssoc) ->
+ ?line ServerSocknamesNoassoc =
+ lists:sort(ok(inet:socknames(ServerSocket))),
+ ?line ?LOGVAR(ServerSocknamesNoassoc),
+ ?line ServerSocknames =
+ lists:sort(ok(inet:socknames(ServerSocket, ServerAssoc))),
+ ?line ?LOGVAR(ServerSocknames),
+ ?line [_|_] =
+ ordsets:intersection
+ (ServerSocknamesNoassoc, ServerSocknames),
+ ?line ClientSocknamesNoassoc =
+ lists:sort(ok(inet:socknames(ClientSocket))),
+ ?line ?LOGVAR(ClientSocknamesNoassoc),
+ ?line ClientSocknames =
+ lists:sort(ok(inet:socknames(ClientSocket, ClientAssoc))),
+ ?line ?LOGVAR(ClientSocknames),
+ ?line [_|_] =
+ ordsets:intersection
+ (ClientSocknamesNoassoc, ClientSocknames),
+ ?line err([einval,enotconn], inet:peernames(ServerSocket)),
+ ?line ServerPeernames =
+ lists:sort(ok(inet:peernames(ServerSocket, ServerAssoc))),
+ ?line ?LOGVAR(ServerPeernames),
+ ?line err([einval,enotconn], inet:peernames(ClientSocket)),
+ ?line ClientPeernames =
+ lists:sort(ok(inet:peernames(ClientSocket, ClientAssoc))),
+ ?line ?LOGVAR(ClientPeernames),
+ ?line ServerSocknames = ClientPeernames,
+ ?line ClientSocknames = ServerPeernames,
+ ?line {ok,Socket} =
+ gen_sctp:peeloff(ServerSocket, ServerAssoc),
+ ?line SocknamesNoassoc =
+ lists:sort(ok(inet:socknames(Socket))),
+ ?line ?LOGVAR(SocknamesNoassoc),
+ ?line Socknames =
+ lists:sort(ok(inet:socknames(Socket, ServerAssoc))),
+ ?line ?LOGVAR(Socknames),
+ ?line true =
+ ordsets:is_subset(SocknamesNoassoc, Socknames),
+ ?line Peernames =
+ lists:sort(ok(inet:peernames(Socket, ServerAssoc))),
+ ?line ?LOGVAR(Peernames),
+ ?line ok = gen_sctp:close(Socket),
+ ?line Socknames = ClientPeernames,
+ ?line ClientSocknames = Peernames,
+ ok
+ end,
+ ?line case get_addrs_by_family(FamilySpec, AddressCount) of
+ {ok, Addresses} when length(Addresses) =:= AddressCount ->
+ ?line do_open_and_connect(Addresses, hd(Addresses), Fun);
+ {error, Reason} ->
+ {skip, Reason}
+ end.
+
+
get_addrs_by_family(Family, NumAddrs) ->
case os:type() of
@@ -1274,6 +1501,10 @@ f(F, A) ->
lists:flatten(io_lib:format(F, A)).
do_open_and_connect(ServerAddresses, AddressToConnectTo) ->
+ ?line Fun = fun (_, _, _, _, _, _) -> ok end,
+ ?line do_open_and_connect(ServerAddresses, AddressToConnectTo, Fun).
+%%
+do_open_and_connect(ServerAddresses, AddressToConnectTo, Fun) ->
?line ServerFamily = get_family_by_addrs(ServerAddresses),
?line io:format("Serving ~p addresses: ~p~n",
[ServerFamily, ServerAddresses]),
@@ -1284,14 +1515,26 @@ do_open_and_connect(ServerAddresses, AddressToConnectTo) ->
?line ClientFamily = get_family_by_addr(AddressToConnectTo),
?line io:format("Connecting to ~p ~p~n",
[ClientFamily, AddressToConnectTo]),
- ?line S2 = ok(gen_sctp:open(0, [ClientFamily])),
+ ?line ClientOpts =
+ [ClientFamily |
+ case ClientFamily of
+ inet6 ->
+ [{ipv6_v6only,true}];
+ _ ->
+ []
+ end],
+ ?line S2 = ok(gen_sctp:open(0, ClientOpts)),
+ log(open),
%% Verify client can connect
- ?line #sctp_assoc_change{state=comm_up} =
+ ?line #sctp_assoc_change{state=comm_up} = S2Assoc =
ok(gen_sctp:connect(S2, AddressToConnectTo, P1, [])),
+ log(comm_up),
%% verify server side also receives comm_up from client
- ?line recv_comm_up_eventually(S1),
+ ?line S1Assoc = recv_comm_up_eventually(S1),
+ ?line Result = Fun(S1, ServerFamily, S1Assoc, S2, ClientFamily, S2Assoc),
?line ok = gen_sctp:close(S2),
- ?line ok = gen_sctp:close(S1).
+ ?line ok = gen_sctp:close(S1),
+ Result.
%% If at least one of the addresses is an ipv6 address, return inet6, else inet.
get_family_by_addrs(Addresses) ->
@@ -1306,9 +1549,11 @@ get_family_by_addr(Addr) when tuple_size(Addr) =:= 8 -> inet6.
recv_comm_up_eventually(S) ->
?line case ok(gen_sctp:recv(S)) of
- {_Addr, _Port, _Info, #sctp_assoc_change{state=comm_up}} ->
- ok;
- {_Addr, _Port, _Info, _OtherSctpMsg} ->
+ {_Addr, _Port, _Info,
+ #sctp_assoc_change{state=comm_up} = Assoc} ->
+ Assoc;
+ {_Addr, _Port, _Info, _OtherSctpMsg} = Msg ->
+ ?line log({unexpected,Msg}),
?line recv_comm_up_eventually(S)
end.
@@ -1367,10 +1612,10 @@ socket_bailout([]) ->
socket_history({State,Flush}) ->
{lists:keysort(
- 2,
- lists:flatten(
- [[{Key,Val} || Val <- Vals]
- || {Key,Vals} <- gb_trees:to_list(State)])),
+ 2,
+ lists:flatten(
+ [[{Key,Val} || Val <- Vals]
+ || {Key,Vals} <- gb_trees:to_list(State)])),
Flush}.
s_handler(Socket) ->
@@ -1453,7 +1698,7 @@ s_loop(Socket, Timeout, Parent, Handler, State) ->
#sctp_assoc_change{
state=comm_up,
inbound_streams=Is}}}|_]
- when 0 =< Stream, Stream < Is-> ok;
+ when 0 =< Stream, Stream < Is-> ok;
[] -> ok
end,
Key = {msg,AssocId,Stream},
@@ -1473,7 +1718,7 @@ s_loop(Socket, Timeout, Parent, Handler, State) ->
case {gb_get(Key, State),St} of
{[],_} -> ok;
{[{_,{Addr,Port,#sctp_assoc_change{state=comm_up}}}|_],_}
- when St =:= comm_lost; St =:= shutdown_comp -> ok
+ when St =:= comm_lost; St =:= shutdown_comp -> ok
end,
NewState = gb_push(Key, Val, State),
Parent ! {self(),{Addr,Port,SAC}},
@@ -1489,8 +1734,9 @@ s_loop(Socket, Timeout, Parent, Handler, State) ->
[] -> ok
end,
case {gb_get({assoc_change,AssocId}, State),St} of
- {[{_,{Addr,Port,#sctp_assoc_change{state=comm_up}}}|_],
- addr_available} -> ok;
+ {[{_,{Addr,Port,#sctp_assoc_change{state=comm_up}}}|_],_}
+ when St =:= addr_available;
+ St =:= addr_confirmed -> ok;
{[],addr_confirmed} -> ok
end,
Key = {paddr_change,AssocId},
@@ -1519,7 +1765,13 @@ s_loop(Socket, Timeout, Parent, Handler, State) ->
end.
again(Socket) ->
- inet:setopts(Socket, [{active,once}]).
+ receive
+ {sctp_passive,Socket} ->
+ [{active, false}] = ok(inet:getopts(Socket, [active])),
+ ok = inet:setopts(Socket,[{active,1}])
+ after 0 ->
+ ok = inet:setopts(Socket, [{active,once}])
+ end.
gb_push(Key, Val, GBT) ->
case gb_trees:lookup(Key, GBT) of
diff --git a/lib/kernel/test/gen_tcp_misc_SUITE.erl b/lib/kernel/test/gen_tcp_misc_SUITE.erl
index ee271fbdfa..ee8bfcceb1 100644
--- a/lib/kernel/test/gen_tcp_misc_SUITE.erl
+++ b/lib/kernel/test/gen_tcp_misc_SUITE.erl
@@ -25,7 +25,7 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2,
controlling_process/1, controlling_process_self/1,
- no_accept/1, close_with_pending_output/1,
+ no_accept/1, close_with_pending_output/1, active_n/1,
data_before_close/1, iter_max_socks/1, get_status/1,
passive_sockets/1, accept_closed_by_other_process/1,
init_per_testcase/2, end_per_testcase/2,
@@ -70,7 +70,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[controlling_process, controlling_process_self, no_accept,
close_with_pending_output, data_before_close,
- iter_max_socks, passive_sockets,
+ iter_max_socks, passive_sockets, active_n,
accept_closed_by_other_process, otp_3924, closed_socket,
shutdown_active, shutdown_passive, shutdown_pending,
default_options, http_bad_packet, busy_send,
@@ -407,6 +407,114 @@ send_loop(Sock, Data, Left) ->
ok = gen_tcp:send(Sock, Data),
send_loop(Sock, Data, Left-1).
+%% Test {active,N} option
+active_n(doc) ->
+ ["Verify operation of the {active,N} option."];
+active_n(suite) -> [];
+active_n(Config) when is_list(Config) ->
+ N = 3,
+ LS = ok(gen_tcp:listen(0, [{active,N}])),
+ [{active,N}] = ok(inet:getopts(LS, [active])),
+ ok = inet:setopts(LS, [{active,-N}]),
+ receive
+ {tcp_passive, LS} -> ok
+ after
+ 5000 ->
+ exit({error,tcp_passive_failure})
+ end,
+ [{active,false}] = ok(inet:getopts(LS, [active])),
+ ok = inet:setopts(LS, [{active,0}]),
+ receive
+ {tcp_passive, LS} -> ok
+ after
+ 5000 ->
+ exit({error,tcp_passive_failure})
+ end,
+ ok = inet:setopts(LS, [{active,32767}]),
+ {error,einval} = inet:setopts(LS, [{active,1}]),
+ {error,einval} = inet:setopts(LS, [{active,-32769}]),
+ ok = inet:setopts(LS, [{active,-32768}]),
+ receive
+ {tcp_passive, LS} -> ok
+ after
+ 5000 ->
+ exit({error,tcp_passive_failure})
+ end,
+ [{active,false}] = ok(inet:getopts(LS, [active])),
+ ok = inet:setopts(LS, [{active,N}]),
+ ok = inet:setopts(LS, [{active,true}]),
+ [{active,true}] = ok(inet:getopts(LS, [active])),
+ receive
+ _ -> exit({error,active_n})
+ after
+ 0 ->
+ ok
+ end,
+ ok = inet:setopts(LS, [{active,N}]),
+ ok = inet:setopts(LS, [{active,once}]),
+ [{active,once}] = ok(inet:getopts(LS, [active])),
+ receive
+ _ -> exit({error,active_n})
+ after
+ 0 ->
+ ok
+ end,
+ {error,einval} = inet:setopts(LS, [{active,32768}]),
+ ok = inet:setopts(LS, [{active,false}]),
+ [{active,false}] = ok(inet:getopts(LS, [active])),
+ Port = ok(inet:port(LS)),
+ C = ok(gen_tcp:connect("localhost", Port, [{active,N}])),
+ [{active,N}] = ok(inet:getopts(C, [active])),
+ S = ok(gen_tcp:accept(LS)),
+ ok = inet:setopts(S, [{active,N}]),
+ [{active,N}] = ok(inet:getopts(S, [active])),
+ repeat(3,
+ fun(I) ->
+ Msg = "message "++integer_to_list(I),
+ ok = gen_tcp:send(C, Msg),
+ receive
+ {tcp,S,Msg} ->
+ ok = gen_tcp:send(S, Msg)
+ after
+ 5000 ->
+ exit({error,timeout})
+ end,
+ receive
+ {tcp,C,Msg} ->
+ ok
+ after
+ 5000 ->
+ exit({error,timeout})
+ end
+ end),
+ receive
+ {tcp_passive,S} ->
+ [{active,false}] = ok(inet:getopts(S, [active]))
+ after
+ 5000 ->
+ exit({error,tcp_passive})
+ end,
+ receive
+ {tcp_passive,C} ->
+ [{active,false}] = ok(inet:getopts(C, [active]))
+ after
+ 5000 ->
+ exit({error,tcp_passive})
+ end,
+ LS2 = ok(gen_tcp:listen(0, [{active,0}])),
+ receive
+ {tcp_passive,LS2} ->
+ [{active,false}] = ok(inet:getopts(LS2, [active]))
+ after
+ 5000 ->
+ exit({error,tcp_passive})
+ end,
+ ok = gen_tcp:close(LS2),
+ ok = gen_tcp:close(C),
+ ok = gen_tcp:close(S),
+ ok = gen_tcp:close(LS),
+ ok.
+
-define(OTP_3924_MAX_DELAY, 100).
%% Taken out of the blue, but on intra host connections
%% I expect propagation of a close to be quite fast
@@ -2659,3 +2767,5 @@ oct_aloop(S,X,Times) ->
gen_tcp:close(S),
closed
end.
+
+ok({ok,V}) -> V.
diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl
index cd768813cf..6bb41999c5 100644
--- a/lib/kernel/test/gen_udp_SUITE.erl
+++ b/lib/kernel/test/gen_udp_SUITE.erl
@@ -1,8 +1,7 @@
-%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -34,7 +33,7 @@
init_per_group/2,end_per_group/2]).
-export([init_per_testcase/2, end_per_testcase/2]).
--export([send_to_closed/1,
+-export([send_to_closed/1, active_n/1,
buffer_size/1, binary_passive_recv/1, bad_address/1,
read_packets/1, open_fd/1, connect/1, implicit_inet6/1]).
@@ -43,7 +42,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[send_to_closed, buffer_size, binary_passive_recv,
bad_address, read_packets, open_fd, connect,
- implicit_inet6].
+ implicit_inet6, active_n].
groups() ->
[].
@@ -466,6 +465,108 @@ open_fd(Config) when is_list(Config) ->
?t:fail(io_lib:format("~w", [flush()]))
end.
+active_n(Config) when is_list(Config) ->
+ N = 3,
+ S1 = ok(gen_udp:open(0, [{active,N}])),
+ [{active,N}] = ok(inet:getopts(S1, [active])),
+ ok = inet:setopts(S1, [{active,-N}]),
+ receive
+ {udp_passive, S1} -> ok
+ after
+ 5000 ->
+ exit({error,udp_passive_failure})
+ end,
+ [{active,false}] = ok(inet:getopts(S1, [active])),
+ ok = inet:setopts(S1, [{active,0}]),
+ receive
+ {udp_passive, S1} -> ok
+ after
+ 5000 ->
+ exit({error,udp_passive_failure})
+ end,
+ ok = inet:setopts(S1, [{active,32767}]),
+ {error,einval} = inet:setopts(S1, [{active,1}]),
+ {error,einval} = inet:setopts(S1, [{active,-32769}]),
+ ok = inet:setopts(S1, [{active,-32768}]),
+ receive
+ {udp_passive, S1} -> ok
+ after
+ 5000 ->
+ exit({error,udp_passive_failure})
+ end,
+ [{active,false}] = ok(inet:getopts(S1, [active])),
+ ok = inet:setopts(S1, [{active,N}]),
+ ok = inet:setopts(S1, [{active,true}]),
+ [{active,true}] = ok(inet:getopts(S1, [active])),
+ receive
+ _ -> exit({error,active_n})
+ after
+ 0 ->
+ ok
+ end,
+ ok = inet:setopts(S1, [{active,N}]),
+ ok = inet:setopts(S1, [{active,once}]),
+ [{active,once}] = ok(inet:getopts(S1, [active])),
+ receive
+ _ -> exit({error,active_n})
+ after
+ 0 ->
+ ok
+ end,
+ {error,einval} = inet:setopts(S1, [{active,32768}]),
+ ok = inet:setopts(S1, [{active,false}]),
+ [{active,false}] = ok(inet:getopts(S1, [active])),
+ S1Port = ok(inet:port(S1)),
+ S2 = ok(gen_udp:open(0, [{active,N}])),
+ S2Port = ok(inet:port(S2)),
+ [{active,N}] = ok(inet:getopts(S2, [active])),
+ ok = inet:setopts(S1, [{active,N}]),
+ [{active,N}] = ok(inet:getopts(S1, [active])),
+ lists:foreach(
+ fun(I) ->
+ Msg = "message "++integer_to_list(I),
+ ok = gen_udp:send(S2, "localhost", S1Port, Msg),
+ receive
+ {udp,S1,_,S2Port,Msg} ->
+ ok = gen_udp:send(S1, "localhost", S2Port, Msg)
+ after
+ 5000 ->
+ exit({error,timeout})
+ end,
+ receive
+ {udp,S2,_,S1Port,Msg} ->
+ ok
+ after
+ 5000 ->
+ exit({error,timeout})
+ end
+ end, lists:seq(1,N)),
+ receive
+ {udp_passive,S1} ->
+ [{active,false}] = ok(inet:getopts(S1, [active]))
+ after
+ 5000 ->
+ exit({error,udp_passive})
+ end,
+ receive
+ {udp_passive,S2} ->
+ [{active,false}] = ok(inet:getopts(S2, [active]))
+ after
+ 5000 ->
+ exit({error,udp_passive})
+ end,
+ S3 = ok(gen_udp:open(0, [{active,0}])),
+ receive
+ {udp_passive,S3} ->
+ [{active,false}] = ok(inet:getopts(S3, [active]))
+ after
+ 5000 ->
+ exit({error,udp_passive})
+ end,
+ ok = gen_udp:close(S3),
+ ok = gen_udp:close(S2),
+ ok = gen_udp:close(S1),
+ ok.
%
% Utils
diff --git a/lib/kernel/test/global_SUITE_data/global_trace.erl b/lib/kernel/test/global_SUITE_data/global_trace.erl
index 00bacf8f54..1396d86c79 100644
--- a/lib/kernel/test/global_SUITE_data/global_trace.erl
+++ b/lib/kernel/test/global_SUITE_data/global_trace.erl
@@ -1,4 +1,3 @@
-%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl
index 62ba95e1a3..ed43749cc0 100644
--- a/lib/kernel/test/inet_SUITE.erl
+++ b/lib/kernel/test/inet_SUITE.erl
@@ -38,10 +38,10 @@
gethostnative_debug_level/0, gethostnative_debug_level/1,
getif/1,
getif_ifr_name_overflow/1,getservbyname_overflow/1, getifaddrs/1,
- parse_strict_address/1]).
+ parse_strict_address/1, simple_netns/1]).
-export([get_hosts/1, get_ipv6_hosts/1, parse_hosts/1, parse_address/1,
- kill_gethost/0, parallell_gethost/0]).
+ kill_gethost/0, parallell_gethost/0, test_netns/0]).
-export([init_per_testcase/2, end_per_testcase/2]).
suite() -> [{ct_hooks,[ts_install_cth]}].
@@ -53,7 +53,7 @@ all() ->
t_gethostnative, gethostnative_parallell, cname_loop,
gethostnative_debug_level, gethostnative_soft_restart,
getif, getif_ifr_name_overflow, getservbyname_overflow,
- getifaddrs, parse_strict_address].
+ getifaddrs, parse_strict_address, simple_netns].
groups() ->
[{parse, [], [parse_hosts, parse_address]}].
@@ -226,7 +226,7 @@ t_gethostbyname_v6(Config) when is_list(Config) ->
h_addr_list = [IP4]} = HEnt4,
{ok,IP46} =
inet_parse:ipv6_address(
- "::ffff:" ++ inet_parse:ntoa(IP4)),
+ "::ffff:" ++ inet:ntoa(IP4)),
check_elems(
[{HEnt#hostent.h_name,[Name,FullName]}])
end,
@@ -246,7 +246,7 @@ t_gethostbyname_v6(Config) when is_list(Config) ->
h_addr_list = [IP4F]} = HEnt4F,
{ok,IP46F} =
inet_parse:ipv6_address(
- "::ffff:" ++ inet_parse:ntoa(IP4F)),
+ "::ffff:" ++ inet:ntoa(IP4F)),
check_elems(
[{HEntF#hostent.h_name,[Name,FullName]}])
end;
@@ -1099,3 +1099,96 @@ toupper([C|Cs]) when is_integer(C) ->
end;
toupper([]) ->
[].
+
+
+simple_netns(Config) when is_list(Config) ->
+ {ok,U} = gen_udp:open(0),
+ case inet:setopts(U, [{netns,""}]) of
+ ok ->
+ jog_netns_opt(U),
+ ok = gen_udp:close(U),
+ %%
+ {ok,L} = gen_tcp:listen(0, []),
+ jog_netns_opt(L),
+ ok = gen_tcp:close(L),
+ %%
+ {ok,S} = gen_sctp:open(),
+ jog_netns_opt(S),
+ ok = gen_sctp:close(S);
+ {error,einval} ->
+ {skip,"setns() not supported"}
+ end.
+
+jog_netns_opt(S) ->
+ %% This is just jogging the option mechanics
+ ok = inet:setopts(S, [{netns,""}]),
+ {ok,[{netns,""}]} = inet:getopts(S, [netns]),
+ ok = inet:setopts(S, [{netns,"/proc/self/ns/net"}]),
+ {ok,[{netns,"/proc/self/ns/net"}]} = inet:getopts(S, [netns]),
+ ok.
+
+
+%% Manual test to be run outside test_server in an emulator
+%% started by root, in a machine with setns() support...
+test_netns() ->
+ DefaultIF = v1,
+ DefaultIP = {192,168,1,17},
+ Namespace = "test",
+ NamespaceIF = v2,
+ NamespaceIP = {192,168,1,18},
+ %%
+ DefaultIPString = inet_parse:ntoa(DefaultIP),
+ NamespaceIPString = inet_parse:ntoa(NamespaceIP),
+ cmd("ip netns add ~s",
+ [Namespace]),
+ cmd("ip link add name ~w type veth peer name ~w netns ~s",
+ [DefaultIF,NamespaceIF,Namespace]),
+ cmd("ip netns exec ~s ip addr add ~s/30 dev ~w",
+ [Namespace,NamespaceIPString,NamespaceIF]),
+ cmd("ip netns exec ~s ip link set ~w up",
+ [Namespace,NamespaceIF]),
+ cmd("ip addr add ~s/30 dev ~w",
+ [DefaultIPString,DefaultIF]),
+ cmd("ip link set ~w up",
+ [DefaultIF]),
+ try test_netns(
+ {DefaultIF,DefaultIP},
+ filename:join("/var/run/netns/", Namespace),
+ {NamespaceIF,NamespaceIP}) of
+ Result ->
+ io:put_chars(["#### Test done",io_lib:nl()]),
+ Result
+ after
+ cmd("ip link delete ~w type veth",
+ [DefaultIF]),
+ cmd("ip netns delete ~s",
+ [Namespace])
+ end.
+
+test_netns({DefaultIF,DefaultIP}, Namespace, {NamespaceIF,NamespaceIP}) ->
+ {ok,ListenSocket} = gen_tcp:listen(0, [{active,false}]),
+ {ok,[{addr,DefaultIP}]} = inet:ifget(ListenSocket, DefaultIF, [addr]),
+ {ok,ListenPort} = inet:port(ListenSocket),
+ {ok,ConnectSocket} =
+ gen_tcp:connect(
+ DefaultIP, ListenPort, [{active,false},{netns,Namespace}], 3000),
+ {ok,[{addr,NamespaceIP}]} = inet:ifget(ConnectSocket, NamespaceIF, [addr]),
+ {ok,ConnectPort} = inet:port(ConnectSocket),
+ {ok,AcceptSocket} = gen_tcp:accept(ListenSocket, 0),
+ {ok,AcceptPort} = inet:port(AcceptSocket),
+ {ok,{NamespaceIP,ConnectPort}} = inet:peername(AcceptSocket),
+ {ok,{DefaultIP,AcceptPort}} = inet:peername(ConnectSocket),
+ ok = gen_tcp:send(ConnectSocket, "data"),
+ ok = gen_tcp:close(ConnectSocket),
+ {ok,"data"} = gen_tcp:recv(AcceptSocket, 4, 1000),
+ {error,closed} = gen_tcp:recv(AcceptSocket, 1, 1000),
+ ok = gen_tcp:close(AcceptSocket),
+ ok = gen_tcp:close(ListenSocket).
+
+cmd(Cmd, Args) ->
+ cmd(io_lib:format(Cmd, Args)).
+%%
+cmd(CmdString) ->
+ io:put_chars(["# ",CmdString,io_lib:nl()]),
+ io:put_chars([os:cmd(CmdString++" ; echo ' =>' $?")]),
+ ok.
diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl
index d7d9434b1f..a375adceea 100644
--- a/lib/kernel/test/interactive_shell_SUITE.erl
+++ b/lib/kernel/test/interactive_shell_SUITE.erl
@@ -22,7 +22,7 @@
init_per_group/2,end_per_group/2,
get_columns_and_rows/1, exit_initial/1, job_control_local/1,
job_control_remote/1,
- job_control_remote_noshell/1]).
+ job_control_remote_noshell/1,ctrl_keys/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
%% For spawn
@@ -41,7 +41,8 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[get_columns_and_rows, exit_initial, job_control_local,
- job_control_remote, job_control_remote_noshell].
+ job_control_remote, job_control_remote_noshell,
+ ctrl_keys].
groups() ->
[].
@@ -289,7 +290,51 @@ job_control_remote_noshell(Config) when is_list(Config) ->
?line stop_noshell_node(NSNode),
?line Res
end.
-
+
+ctrl_keys(suite) -> [];
+ctrl_keys(doc) -> ["Tests various control keys"];
+ctrl_keys(_Conf) when is_list(_Conf) ->
+ Cu=[$\^u],
+ Cw=[$\^w],
+ Home=[27,$O,$H],
+ End=[27,$O,$F],
+ rtnode([{putline,""},
+ {putline,"2."},
+ {getline,"2"},
+ {putline,"\"hello "++Cw++"world\"."}, % test <CTRL>+W
+ {getline,"\"world\""},
+ {putline,"\"hello "++Cu++"\"world\"."}, % test <CTRL>+U
+ {getline,"\"world\""},
+ {putline,"world\"."++Home++"\"hello "}, % test <HOME>
+ {getline,"\"hello world\""},
+ {putline,"world"++Home++"\"hello "++End++"\"."}, % test <END>
+ {getline,"\"hello world\""}]
+ ++wordLeft()++wordRight(),[]).
+
+
+wordLeft() ->
+ L1=[27,27,$[,$D],
+ L2=[27]++"[5D",
+ L3=[27]++"[1;5D",
+ wordLeft(L1)++wordLeft(L2)++wordLeft(L3).
+
+wordLeft(Chars) ->
+ End=[27,$O,$F],
+ [{putline,"\"world\""++Chars++"hello "++End++"."},
+ {getline,"\"hello world\""}].
+
+wordRight() ->
+ R1=[27,27,$[,$C],
+ R2=[27]++"[5C",
+ R3=[27]++"[1;5C",
+ wordRight(R1)++wordRight(R2)++wordRight(R3).
+
+wordRight(Chars) ->
+ Home=[27,$O,$H],
+ [{putline,"world"++Home++"\"hello "++Chars++"\"."},
+ {getline,"\"hello world\""}].
+
+
rtnode(C,N) ->
rtnode(C,N,[]).
rtnode(Commands,Nodename,ErlPrefix) ->
diff --git a/lib/kernel/test/kernel_SUITE.erl b/lib/kernel/test/kernel_SUITE.erl
index 0f29d895e5..78f5e93fc3 100644
--- a/lib/kernel/test/kernel_SUITE.erl
+++ b/lib/kernel/test/kernel_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -23,9 +23,6 @@
-include_lib("test_server/include/test_server.hrl").
-% Default timetrap timeout (set in init_per_testcase).
--define(default_timeout, ?t:minutes(1)).
-
% Test server specific exports
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).
@@ -59,11 +56,8 @@ end_per_group(_GroupName, Config) ->
init_per_testcase(_Case, Config) ->
- ?line Dog=test_server:timetrap(?default_timeout),
- [{watchdog, Dog}|Config].
-end_per_testcase(_Case, Config) ->
- Dog=?config(watchdog, Config),
- test_server:timetrap_cancel(Dog),
+ Config.
+end_per_testcase(_Case, _Config) ->
ok.
%
@@ -78,56 +72,80 @@ app_test(Config) when is_list(Config) ->
ok.
-%% Test that appup allows upgrade from/downgrade to a maximum of two
-%% major releases back.
+%% Test that appup allows upgrade from/downgrade to a maximum of one
+%% major release back.
appup_test(_Config) ->
- application:load(kernel),
- {_,_,Vsn} = lists:keyfind(kernel,1,application:loaded_applications()),
- AppupFile = filename:join([code:lib_dir(kernel),ebin,"kernel.appup"]),
+ appup_tests(kernel,create_test_vsns(kernel)).
+
+appup_tests(_App,{[],[]}) ->
+ {skip,"no previous releases available"};
+appup_tests(App,{OkVsns,NokVsns}) ->
+ application:load(App),
+ {_,_,Vsn} = lists:keyfind(App,1,application:loaded_applications()),
+ AppupFileName = atom_to_list(App) ++ ".appup",
+ AppupFile = filename:join([code:lib_dir(App),ebin,AppupFileName]),
{ok,[{Vsn,UpFrom,DownTo}=AppupScript]} = file:consult(AppupFile),
ct:log("~p~n",[AppupScript]),
- {OkVsns,NokVsns} = create_test_vsns(Vsn),
+ ct:log("Testing ok versions: ~p~n",[OkVsns]),
check_appup(OkVsns,UpFrom,{ok,[restart_new_emulator]}),
check_appup(OkVsns,DownTo,{ok,[restart_new_emulator]}),
+ ct:log("Testing not ok versions: ~p~n",[NokVsns]),
check_appup(NokVsns,UpFrom,error),
check_appup(NokVsns,DownTo,error),
ok.
-create_test_vsns(Current) ->
- [XStr,YStr|Rest] = string:tokens(Current,"."),
- X = list_to_integer(XStr),
- Y = list_to_integer(YStr),
- SecondMajor = vsn(X,Y-2),
- SecondMinor = SecondMajor ++ ".1.3",
- FirstMajor = vsn(X,Y-1),
- FirstMinor = FirstMajor ++ ".57",
- ThisMajor = vsn(X,Y),
- This =
- case Rest of
- [] ->
- [];
- ["1"] ->
- [ThisMajor];
- _ ->
- ThisMinor = ThisMajor ++ ".1",
- [ThisMajor,ThisMinor]
+create_test_vsns(App) ->
+ This = erlang:system_info(otp_release),
+ FirstMajor = previous_major(This),
+ SecondMajor = previous_major(FirstMajor),
+ Ok = app_vsn(App,[FirstMajor]),
+ Nok0 = app_vsn(App,[SecondMajor]),
+ Nok = case Ok of
+ [Ok1|_] ->
+ [Ok1 ++ ",1" | Nok0]; % illegal
+ _ ->
+ Nok0
+ end,
+ {Ok,Nok}.
+
+previous_major("17") ->
+ "r16";
+previous_major("r"++Rel) ->
+ "r"++previous_major(Rel);
+previous_major(Rel) ->
+ integer_to_list(list_to_integer(Rel)-1).
+
+app_vsn(App,[R|Rs]) ->
+ OldRel =
+ case test_server:is_release_available(R) of
+ true ->
+ {release,R};
+ false ->
+ case ct:get_config({otp_releases,list_to_atom(R)}) of
+ undefined ->
+ false;
+ Prog0 ->
+ case os:find_executable(Prog0) of
+ false ->
+ false;
+ Prog ->
+ {prog,Prog}
+ end
+ end
end,
- OkVsns = This ++ [FirstMajor, FirstMinor, SecondMajor, SecondMinor],
-
- ThirdMajor = vsn(X,Y-3),
- ThirdMinor = ThirdMajor ++ ".10.12",
- Illegal = ThisMajor ++ ",1",
- Newer1Major = vsn(X,Y+1),
- Newer1Minor = Newer1Major ++ ".1",
- Newer2Major = ThisMajor ++ "1",
- NokVsns = [ThirdMajor,ThirdMinor,
- Illegal,
- Newer1Major,Newer1Minor,
- Newer2Major],
- {OkVsns,NokVsns}.
-
-vsn(X,Y) ->
- integer_to_list(X) ++ "." ++ integer_to_list(Y).
+ case OldRel of
+ false ->
+ app_vsn(App,Rs);
+ _ ->
+ {ok,N} = test_server:start_node(prevrel,peer,[{erl,[OldRel]}]),
+ _ = rpc:call(N,application,load,[App]),
+ As = rpc:call(N,application,loaded_applications,[]),
+ {_,_,V} = lists:keyfind(App,1,As),
+ test_server:stop_node(N),
+ [V|app_vsn(App,Rs)]
+ end;
+app_vsn(_App,[]) ->
+ [].
check_appup([Vsn|Vsns],Instrs,Expected) ->
case systools_relup:appup_search_for_version(Vsn, Instrs) of
diff --git a/lib/kernel/test/kernel_smoke.spec b/lib/kernel/test/kernel_smoke.spec
new file mode 100644
index 0000000000..e5d8273c56
--- /dev/null
+++ b/lib/kernel/test/kernel_smoke.spec
@@ -0,0 +1,9 @@
+{config, "../test_server/ts.config"}.
+{config, "../test_server/ts.unix.config"}.
+
+{cases,"../kernel_test", inet_SUITE,[t_gethostbyaddr,t_gethostbyname,
+ t_gethostbyaddr_v6,t_gethostbyname_v6,t_gethostnative,getifaddrs]}.
+{cases,"../kernel_test", inet_res_SUITE,[gethostbyaddr,gethostbyname,
+ gethostbyaddr_v6,gethostbyname_v6,basic]}.
+{cases,"../kernel_test", gen_tcp_echo_SUITE,[active_echo]}.
+{cases,"../kernel_test", heart_SUITE,[reboot]}.
diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl
index 73ed704ae3..9b474c4cdf 100644
--- a/lib/kernel/test/os_SUITE.erl
+++ b/lib/kernel/test/os_SUITE.erl
@@ -20,7 +20,7 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2]).
--export([space_in_cwd/1, quoting/1, space_in_name/1, bad_command/1,
+-export([space_in_cwd/1, quoting/1, cmd_unicode/1, space_in_name/1, bad_command/1,
find_executable/1, unix_comment_in_command/1, deep_list_command/1, evil/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -28,9 +28,8 @@
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [space_in_cwd, quoting, space_in_name, bad_command,
- find_executable, unix_comment_in_command, deep_list_command,
- evil].
+ [space_in_cwd, quoting, cmd_unicode, space_in_name, bad_command,
+ find_executable, unix_comment_in_command, deep_list_command, evil].
groups() ->
[].
@@ -95,6 +94,21 @@ quoting(Config) when is_list(Config) ->
?line [] = receive_all(),
ok.
+
+cmd_unicode(doc) -> "Test that unicode arguments work.";
+cmd_unicode(suite) -> [];
+cmd_unicode(Config) when is_list(Config) ->
+ ?line DataDir = ?config(data_dir, Config),
+ ?line Echo = filename:join(DataDir, "my_echo"),
+
+ ?line comp("one", os:cmd(Echo ++ " one")),
+ ?line comp("one::two", os:cmd(Echo ++ " one two")),
+ ?line comp("åäö::ϼΩ", os:cmd(Echo ++ " åäö " ++ [1020, 937])),
+ ?t:sleep(5),
+ ?line [] = receive_all(),
+ ok.
+
+
space_in_name(doc) ->
"Test that program with a space in its name can be executed.";
space_in_name(suite) -> [];
@@ -302,8 +316,8 @@ comp(Expected, Got) ->
Expected ->
ok;
Other ->
- ok = io:format("Expected: ~s\n", [Expected]),
- ok = io:format("Got: ~s\n", [Other]),
+ ok = io:format("Expected: ~ts\n", [Expected]),
+ ok = io:format("Got: ~ts\n", [Other]),
test_server:fail()
end.
diff --git a/lib/kernel/test/os_SUITE_data/my_echo.c b/lib/kernel/test/os_SUITE_data/my_echo.c
index 2127511dd1..712c828bb5 100644
--- a/lib/kernel/test/os_SUITE_data/my_echo.c
+++ b/lib/kernel/test/os_SUITE_data/my_echo.c
@@ -1,3 +1,30 @@
+#ifdef __WIN32__
+#include <windows.h>
+
+int wmain(int argc, wchar_t **argv)
+{
+ char* sep = "";
+ int len;
+
+ /*
+ * Echo all arguments separated with '::', so that we can check that
+ * quotes are interpreted correctly.
+ */
+
+ while (argc-- > 1) {
+ char *utf8;
+ len = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
+ utf8 = malloc(len*sizeof(char));
+ WideCharToMultiByte(CP_UTF8, 0, argv++[1], -1, utf8, len, NULL, NULL);
+ printf("%s%s", sep, utf8);
+ free(utf8);
+ sep = "::";
+ }
+ putchar('\n');
+ return 0;
+}
+#else
+
#include <stdio.h>
int
@@ -17,3 +44,4 @@ main(int argc, char** argv)
putchar('\n');
return 0;
}
+#endif
diff --git a/lib/kernel/test/ram_file_SUITE.erl b/lib/kernel/test/ram_file_SUITE.erl
index 5c4437d4d3..615251a257 100644
--- a/lib/kernel/test/ram_file_SUITE.erl
+++ b/lib/kernel/test/ram_file_SUITE.erl
@@ -1,8 +1,7 @@
-%% -*- coding: utf-8 -*-
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2001-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2001-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/kernel/test/sendfile_SUITE.erl b/lib/kernel/test/sendfile_SUITE.erl
index 4cf4c6489d..2c741232c4 100644
--- a/lib/kernel/test/sendfile_SUITE.erl
+++ b/lib/kernel/test/sendfile_SUITE.erl
@@ -24,7 +24,14 @@
-compile(export_all).
-all() ->
+all() -> [{group,async_threads},
+ {group,no_async_threads}].
+
+groups() ->
+ [{async_threads,[],tcs()},
+ {no_async_threads,[],tcs()}].
+
+tcs() ->
[t_sendfile_small
,t_sendfile_big_all
,t_sendfile_big_size
@@ -33,6 +40,7 @@ all() ->
,t_sendfile_offset
,t_sendfile_sendafter
,t_sendfile_recvafter
+ ,t_sendfile_recvafter_remoteclose
,t_sendfile_sendduring
,t_sendfile_recvduring
,t_sendfile_closeduring
@@ -63,6 +71,14 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
file:delete(proplists:get_value(big_file, Config)).
+init_per_group(async_threads,Config) ->
+ [{sendfile_opts,[{use_threads,true}]}|Config];
+init_per_group(no_async_threads,Config) ->
+ [{sendfile_opts,[{use_threads,false}]}|Config].
+
+end_per_group(_,_Config) ->
+ ok.
+
init_per_testcase(TC,Config) when TC == t_sendfile_recvduring;
TC == t_sendfile_sendduring ->
Filename = proplists:get_value(small_file, Config),
@@ -71,7 +87,7 @@ init_per_testcase(TC,Config) when TC == t_sendfile_recvduring;
{_Size, Data} = sendfile_file_info(Filename),
{ok,D} = file:open(Filename, [raw,binary,read]),
prim_file:sendfile(D, Sock, 0, 0, 0,
- [],[],false,false,false),
+ [],[],[]),
Data
end,
@@ -92,6 +108,7 @@ t_sendfile_small(Config) when is_list(Config) ->
Send = fun(Sock) ->
{Size, Data} = sendfile_file_info(Filename),
+ %% Here we make sure to test the sendfile/2 api
{ok, Size} = file:sendfile(Filename, Sock),
Data
end,
@@ -101,6 +118,7 @@ t_sendfile_small(Config) when is_list(Config) ->
t_sendfile_many_small(Config) when is_list(Config) ->
Filename = proplists:get_value(small_file, Config),
FileOpts = proplists:get_value(file_opts, Config, []),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
error_logger:add_report_handler(?MODULE,[self()]),
@@ -109,7 +127,7 @@ t_sendfile_many_small(Config) when is_list(Config) ->
N = 10000,
{ok,D} = file:open(Filename,[read|FileOpts]),
[begin
- {ok,Size} = file:sendfile(D,Sock,0,0,[])
+ {ok,Size} = file:sendfile(D,Sock,0,0,SendfileOpts)
end || _I <- lists:seq(1,N)],
file:close(D),
Size*N
@@ -127,11 +145,12 @@ t_sendfile_many_small(Config) when is_list(Config) ->
t_sendfile_big_all(Config) when is_list(Config) ->
Filename = proplists:get_value(big_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock) ->
{ok, #file_info{size = Size}} =
file:read_file_info(Filename),
- {ok, Size} = file:sendfile(Filename, Sock),
+ {ok, Size} = sendfile(Filename, Sock, SendfileOpts),
Size
end,
@@ -140,12 +159,13 @@ t_sendfile_big_all(Config) when is_list(Config) ->
t_sendfile_big_size(Config) ->
Filename = proplists:get_value(big_file, Config),
FileOpts = proplists:get_value(file_opts, Config, []),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
SendAll = fun(Sock) ->
{ok, #file_info{size = Size}} =
file:read_file_info(Filename),
{ok,D} = file:open(Filename,[read|FileOpts]),
- {ok, Size} = file:sendfile(D, Sock,0,Size,[]),
+ {ok, Size} = file:sendfile(D, Sock,0,Size,SendfileOpts),
Size
end,
@@ -154,12 +174,13 @@ t_sendfile_big_size(Config) ->
t_sendfile_partial(Config) ->
Filename = proplists:get_value(small_file, Config),
FileOpts = proplists:get_value(file_opts, Config, []),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
SendSingle = fun(Sock) ->
{_Size, <<Data:5/binary,_/binary>>} =
sendfile_file_info(Filename),
{ok,D} = file:open(Filename,[read|FileOpts]),
- {ok,5} = file:sendfile(D,Sock,0,5,[]),
+ {ok,5} = file:sendfile(D,Sock,0,5,SendfileOpts),
file:close(D),
Data
end,
@@ -170,14 +191,14 @@ t_sendfile_partial(Config) ->
{ok,D} = file:open(Filename,[read|FileOpts]),
{ok, <<FData/binary>>} = file:read(D,5),
FSend = fun(Sock) ->
- {ok,5} = file:sendfile(D,Sock,0,5,[]),
+ {ok,5} = file:sendfile(D,Sock,0,5,SendfileOpts),
FData
end,
ok = sendfile_send(FSend),
SSend = fun(Sock) ->
- {ok,3} = file:sendfile(D,Sock,5,3,[]),
+ {ok,3} = file:sendfile(D,Sock,5,3,SendfileOpts),
SData
end,
@@ -190,12 +211,13 @@ t_sendfile_partial(Config) ->
t_sendfile_offset(Config) ->
Filename = proplists:get_value(small_file, Config),
FileOpts = proplists:get_value(file_opts, Config, []),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock) ->
{_Size, <<_:5/binary,Data:3/binary,_/binary>> = AllData} =
sendfile_file_info(Filename),
{ok,D} = file:open(Filename,[read|FileOpts]),
- {ok,3} = file:sendfile(D,Sock,5,3,[]),
+ {ok,3} = file:sendfile(D,Sock,5,3,SendfileOpts),
{ok, AllData} = file:read(D,100),
file:close(D),
Data
@@ -205,10 +227,11 @@ t_sendfile_offset(Config) ->
t_sendfile_sendafter(Config) ->
Filename = proplists:get_value(small_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock) ->
{Size, Data} = sendfile_file_info(Filename),
- {ok, Size} = file:sendfile(Filename, Sock),
+ {ok, Size} = sendfile(Filename, Sock, SendfileOpts),
ok = gen_tcp:send(Sock, <<2>>),
<<Data/binary,2>>
end,
@@ -217,10 +240,11 @@ t_sendfile_sendafter(Config) ->
t_sendfile_recvafter(Config) ->
Filename = proplists:get_value(small_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock) ->
{Size, Data} = sendfile_file_info(Filename),
- {ok, Size} = file:sendfile(Filename, Sock),
+ {ok, Size} = sendfile(Filename, Sock, SendfileOpts),
ok = gen_tcp:send(Sock, <<1>>),
{ok,<<1>>} = gen_tcp:recv(Sock, 1),
<<Data/binary,1>>
@@ -228,8 +252,28 @@ t_sendfile_recvafter(Config) ->
ok = sendfile_send(Send).
+%% This tests specifically for a bug fixed in 17.0
+t_sendfile_recvafter_remoteclose(Config) ->
+ Filename = proplists:get_value(small_file, Config),
+
+ Send = fun(Sock, SFServer) ->
+ {Size, _Data} = sendfile_file_info(Filename),
+ {ok, Size} = file:sendfile(Filename, Sock),
+
+ %% Make sure the remote end has been closed
+ SFServer ! stop,
+ timer:sleep(100),
+
+ %% In the bug this returned {error,ebadf}
+ {error,closed} = gen_tcp:recv(Sock, 1),
+ -1
+ end,
+
+ ok = sendfile_send({127,0,0,1},Send,0).
+
t_sendfile_sendduring(Config) ->
Filename = proplists:get_value(big_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock) ->
{ok, #file_info{size = Size}} =
@@ -238,7 +282,7 @@ t_sendfile_sendduring(Config) ->
timer:sleep(50),
ok = gen_tcp:send(Sock, <<2>>)
end),
- {ok, Size} = file:sendfile(Filename, Sock),
+ {ok, Size} = sendfile(Filename, Sock, SendfileOpts),
Size+1
end,
@@ -246,6 +290,7 @@ t_sendfile_sendduring(Config) ->
t_sendfile_recvduring(Config) ->
Filename = proplists:get_value(big_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock) ->
{ok, #file_info{size = Size}} =
@@ -255,7 +300,7 @@ t_sendfile_recvduring(Config) ->
ok = gen_tcp:send(Sock, <<1>>),
{ok,<<1>>} = gen_tcp:recv(Sock, 1)
end),
- {ok, Size} = file:sendfile(Filename, Sock),
+ {ok, Size} = sendfile(Filename, Sock, SendfileOpts),
timer:sleep(1000),
Size+1
end,
@@ -264,6 +309,7 @@ t_sendfile_recvduring(Config) ->
t_sendfile_closeduring(Config) ->
Filename = proplists:get_value(big_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
Send = fun(Sock,SFServPid) ->
spawn_link(fun() ->
@@ -272,13 +318,14 @@ t_sendfile_closeduring(Config) ->
end),
case erlang:system_info(thread_pool_size) of
0 ->
- {error, closed} = file:sendfile(Filename, Sock);
+ {error, closed} = sendfile(Filename, Sock,
+ SendfileOpts);
_Else ->
%% This can return how much has been sent or
%% {error,closed} depending on OS.
%% How much is sent impossible to know as
%% the socket was closed mid sendfile
- case file:sendfile(Filename, Sock) of
+ case sendfile(Filename, Sock, SendfileOpts) of
{error, closed} ->
ok;
{ok, Size} when is_integer(Size) ->
@@ -292,6 +339,7 @@ t_sendfile_closeduring(Config) ->
t_sendfile_crashduring(Config) ->
Filename = proplists:get_value(big_file, Config),
+ SendfileOpts = proplists:get_value(sendfile_opts, Config),
error_logger:add_report_handler(?MODULE,[self()]),
@@ -300,7 +348,7 @@ t_sendfile_crashduring(Config) ->
timer:sleep(50),
exit(die)
end),
- {error, closed} = file:sendfile(Filename, Sock),
+ {error, closed} = sendfile(Filename, Sock, SendfileOpts),
-1
end,
process_flag(trap_exit,true),
@@ -395,6 +443,16 @@ sendfile_file_info(File) ->
{ok, Data} = file:read_file(File),
{Size, Data}.
+sendfile(Filename,Sock,Opts) ->
+ case file:open(Filename, [read, raw, binary]) of
+ {error, Reason} ->
+ {error, Reason};
+ {ok, Fd} ->
+ Res = file:sendfile(Fd, Sock, 0, 0, Opts),
+ _ = file:close(Fd),
+ Res
+ end.
+
%% Error handler
diff --git a/lib/kernel/test/zlib_SUITE.erl b/lib/kernel/test/zlib_SUITE.erl
index bd237cb513..3be6f39d95 100644
--- a/lib/kernel/test/zlib_SUITE.erl
+++ b/lib/kernel/test/zlib_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -178,7 +178,7 @@ api_deflateInit(Config) when is_list(Config) ->
?m(ok,zlib:close(Z))
end, lists:seq(1,8)),
- Strategies = [filtered,huffman_only,default],
+ Strategies = [filtered,huffman_only,rle,default],
lists:foreach(fun(Strategy) ->
?line Z = zlib:open(),
?m(ok, zlib:deflateInit(Z,best_speed,deflated,-15,8,Strategy)),
@@ -220,7 +220,6 @@ api_deflateParams(Config) when is_list(Config) ->
?m(_, zlib:deflate(Z1, <<1,1,1,1,1,1,1,1,1>>, none)),
?m(ok, zlib:deflateParams(Z1, best_compression, huffman_only)),
?m(_, zlib:deflate(Z1, <<1,1,1,1,1,1,1,1,1>>, sync)),
- ?m({'EXIT',_}, zlib:deflateParams(Z1,best_speed, filtered)),
?m(ok, zlib:close(Z1)).
api_deflate(doc) -> "Test deflate";
@@ -565,8 +564,8 @@ intro(Config) when is_list(Config) ->
large_deflate(doc) -> "Test deflate large file, which had a bug reported on erlang-bugs";
large_deflate(suite) -> [];
large_deflate(Config) when is_list(Config) ->
- large_deflate().
-large_deflate() ->
+ large_deflate_do().
+large_deflate_do() ->
?line Z = zlib:open(),
?line Plain = rand_bytes(zlib:getBufSize(Z)*5),
?line ok = zlib:deflateInit(Z),
@@ -899,7 +898,7 @@ worker(Seed, FnATpl, Parent) ->
Parent ! self().
worker_loop(0, _FnATpl) ->
- large_deflate(), % the time consuming one as finale
+ large_deflate_do(), % the time consuming one as finale
ok;
worker_loop(N, FnATpl) ->
{F,A} = element(random:uniform(size(FnATpl)),FnATpl),
diff --git a/lib/kernel/vsn.mk b/lib/kernel/vsn.mk
index 96c1e3d83d..dd5316b825 100644
--- a/lib/kernel/vsn.mk
+++ b/lib/kernel/vsn.mk
@@ -1 +1 @@
-KERNEL_VSN = 2.16.3
+KERNEL_VSN = 3.0