aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
AgeCommit message (Collapse)Author
2016-05-20Make inet:gethostbyname respect resolver option `inet6`Daniel Sommermann
This makes the implementation text of inet:gethostbyname/1 identical to that of inet_res:gethostbyname/1. I also copied over the doc note about this resolver option.
2016-05-04Merge branch 'bjorn/fix-on_load/OTP-12593'Björn Gustavsson
* bjorn/fix-on_load/OTP-12593: Update documentation regarding improvements Correctly handle multiple load attempts when on_load is pending Avoid deadlock when an on_load function makes an external call to the module itself code_server: Eliminate unnecessary Tag in handle_call/3 Reimplement -on_load() Refactor erts_finish_loading() and insert_new_code() code_SUITE: Make on_load_binary/1 clearer by using merl
2016-05-04Correctly handle multiple load attempts when on_load is pendingBjörn Gustavsson
If an on_load function had not yet returned, the code server would only correctly handle calls to code:ensure_loaded/1. That is, each process that called code:ensured_loaded/1 for the module in question would be suspended until the on_load function had returned. The code server handled calls to code:load_binary/1, code:load_file/1, and code:load_abs/1 in the same way as for code:ensure_loaded/1. That means that if call to one those functions attempted to load *different* code for the module, that code would not get loaded. Note that code:finish_loading/1 (code:atomic_load/1) will still return {error,pending_on_load} if there is a pending on_load function for one of the modules that are about to be loaded. The reason is that code:finish_loading/1 is meant to either succeed directly, or fail quickly if there is any problem.
2016-05-04Avoid deadlock when an on_load function makes an external call to the module ↵Björn Gustavsson
itself
2016-05-04code_server: Eliminate unnecessary Tag in handle_call/3Björn Gustavsson
For historical reasons, the second argument in handle_call/3 is {Pid,Tag}. The tag is always 'call' and is never used.
2016-05-04Reimplement -on_load()Björn Gustavsson
Load the module as old code; swap old and new code if the -on_load function succeeds. That way, a failed update attempt for a module that has an -on_load function will preserve the previous version of the code.
2016-05-04Merge branch 'legoscia/dist-shutdown-reasons/PR-1028/OTP-13458'Zandra
* legoscia/dist-shutdown-reasons/PR-1028/OTP-13458: Error reasons for more distribution errors
2016-05-04Merge branch 'zandra/optimize-rpc/OTP-13518'Zandra
* zandra/optimize-rpc/OTP-13518: use maps instead of gb_trees to optimize the rpc server let the spawned processes handle rpc replies Conflicts: lib/runtime_tools/test/dbg_SUITE.erl
2016-05-02use maps instead of gb_trees to optimize the rpc serverZandra
2016-05-02let the spawned processes handle rpc repliesZandra
This decreases the load on the rex server.
2016-04-30Introduce is_dir/1 to test for a directoryBjörn Gustavsson
2016-04-30Introduce split_base/1 to split into name and version stringBjörn Gustavsson
2016-04-29Eliminate one call to filename:split/1Björn Gustavsson
2016-04-29Refactor get_name/1Björn Gustavsson
Refactor get_name/1 to facilitate an optimization in the next commit.
2016-04-29Clean up make_path()Björn Gustavsson
make_path() returns a tuple whose second element is not used by any of its caller. Eliminate the tuple. Also avoid calling filename:dirname/1 when we already have the result stored in a variable, and avoid calling filename:basename/2 on a complete path when we already have the last part of the pathname stored in a variable.
2016-04-29Avoid calling absname/1 on an absolute pathBjörn Gustavsson
absname/1 is quite expensive, so we should not call if we already have a normalized absolute path.
2016-04-29Clean up processing of archive filesBjörn Gustavsson
The same filtering of sub directories is done in archive_subdirs/1 and try_archive_subdirs/1. Actually, archive_subdirs/1 does nothing useful. It can be removed and all_archive_subdirs/1 can be renamed to archive_subdirs/1. In try_archive_subdirs/1, we can also replace filename:join/1 with the cheaper filename:append/1, since we know that pathnames have already been normalized.
2016-04-29Simplify and speed up del_ebin/1Björn Gustavsson
It is faster and easier to use filename:split/1 and filename:join/1 than use four different 'filename' operations. Each call in the original call first flattens the input list, and then traverse the entire string to the end. So there are roughly 8 complete traversals. In comparison, filename:split/1 will traverse the input string twice (once to flatten, once to split) and filename:join/1 once. For background on why this optimization is worthwhile, here is the result of profiling the start-up of the run-time system on my computer (done before this optimization): $ $ERL_TOP/bin/erl -profile_boot . . . filename:join1/4 - 13573 : 13805 us erlang:finish_loading/1 - 27 : 19963 us filename:do_flatten/2 - 29337 : 49518 us erlang:prepare_loading/2 - 49 : 52270 us Note that filename:do_flatten/2 ends up in second place, almost as expensive as erlang:prepare_loading/2. Your mileage may vary, depending on the length of $ERL_TOP and the number of extra directories added to the path using $ERL_LIBS.
2016-04-26Fix global_group.erlxuming
2016-04-25Error reasons for more distribution errorsMagnus Henoch
Add descriptive shutdown reasons when an incoming distribution connection is rejected because it is not on the "allowed" list or because it has an incorrect cookie. These error reasons can be seen after calling net_kernel:verbose(1). Distinguishing these failures is valuable, because the log message printed is otherwise identical.
2016-04-15erts: Implement tracer modulesLukas Larsson
Add the possibility to use modules as trace data receivers. The functions in the module have to be nifs as otherwise complex trace probes will be very hard to handle (complex means trace probes for ports for example). This commit changes the way that the ptab->tracer field works from always being an immediate, to now be NIL if no tracer is present or else be the tuple {TracerModule, TracerState} where TracerModule is an atom that is later used to lookup the appropriate tracer callbacks to call and TracerState is just passed to the tracer callback. The default process and port tracers have been rewritten to use the new API. This commit also changes the order which trace messages are delivered to the potential tracer process. Any enif_send done in a tracer module may be delayed indefinitely because of lock order issues. If a message is delayed any other trace message send from that process is also delayed so that order is preserved for each traced entity. This means that for some trace events (i.e. send/receive) the events may come in an unintuitive order (receive before send) to the trace receiver. Timestamps are taken when the trace message is generated so trace messages from differented processes may arrive with the timestamp out of order. Both the erlang:trace and seq_trace:set_system_tracer accept the new tracer module tracers and also the backwards compatible arguments. OTP-10267
2016-04-15Merge branch 'paulgray/inet_db_fix/PR-949/OTP-13470'Raimo Niskanen
* paulgray/inet_db_fix/PR-949/OTP-13470: Fix start timestamp instead of time check Allow to refresh resolver settings on startup
2016-04-13Merge branch 'henrik/update-copyrightyear'Henrik Nord
* henrik/update-copyrightyear: update copyright-year
2016-04-07erts: Add DFLAG_BIG_CREATIONSverker Eriksson
to let future nodes know that we can handle NEW_PID_EXT, NEW_PORT_EXT and NEWER_REFERENCE_EXT.
2016-04-07Update spec for rpc:pinfo/2Björn Gustavsson
rpc:pinfo/2 is documented as a location-transparent version of process_info/2. Therefore, it should be expected that the spec would allow calls with an item list, for example: rpc:pinfo(Pid, [initial_call,last_calls]) Report-URL: http://bugs.erlang.org/browse/ERL-124 Reported-by: bjfish
2016-04-06Fix start timestamp instead of time checkRaimo Niskanen
Verify with: erl -noshell -eval 'io:write(inet_res:lookup("localhost",in,a)),io:nl(),init:stop().' Prints: [{127,0,0,1}] Without this correction you will get [] on a hostname that works later after system start.
2016-04-04Merge branch 'bjorn/kernel/remove-deprecated/OTP-13449'Björn Gustavsson
* bjorn/kernel/remove-deprecated/OTP-13449: rpc: Remove functions deprecated in R12B
2016-04-04Merge branch 'dcorbacho/dist_util_logs'Zandra
OTP-13458 * dcorbacho/dist_util_logs: Keep error reasons for some common distribution errors
2016-04-01rpc: Remove functions deprecated in R12BBjörn Gustavsson
2016-03-31code: Remove 'bad_path' error code from set_path/1Björn Gustavsson
code:set_path/1 no longer returns {error,bad_path} (an exception will be thrown instead).
2016-03-18kernel: Reduce sendfile fallback chunk sizeLukas Larsson
This is necessary for windows to perform correctly when writing large files.
2016-03-16code_server: Normalize the pathnames for all loaded modulesBjörn Gustavsson
On Windows, the pathnames for modules that are loaded early are returned with mixed backslashes and slashes: 1> code:which(lists). "C:\\Program Files\\erl8.0/lib/stdlib-2.7/ebin/lists.beam" 2> Modules loaded later are fully normalized. When starting the code_server, normalize the pathnames for all modules that have been loaded so far.
2016-03-15update copyright-yearHenrik Nord
2016-03-15Keep error reasons for some common distribution errorsDiana Corbacho
These error reasons can be seen in the logs after calling net_kernel:verbose(1).
2016-03-14Merge branch 'bjorn/kernel/rpc/OTP-13409'Björn Gustavsson
* bjorn/kernel/rpc/OTP-13409: Don't throw exceptions from rpc:call() and rpc:block_call() Reduce code duplication in called_node_dies/1 and friends
2016-03-14Merge branch 'bjorn/clearer-startup-crashes/OTP-13294'Björn Gustavsson
* bjorn/clearer-startup-crashes/OTP-13294: Make distribution failures during start-up easier to read net_kernel: Separate exports into documented and non-documented groups erl_distribution: Simplify start_link/0 and friends Reorder and comment API functions Clean up splitting of node names
2016-03-14Make distribution failures during start-up easier to readBjörn Gustavsson
When an attempt is made to start a distributed Erlang node with the same name as an existing node, the crash reports for several supervisors would be displayed. Only the first line contains useful information. The verbiage is annoying for old hands and could easily scare newcomers away for good. For all the common distribution failures during start-up, write a simple message and terminate the emulator using halt/1. Here is an example of what will be printed: Protocol 'inet_tcp': the name somename@somehost seems to be in use by another Erlang node
2016-03-11Don't throw exceptions from rpc:call() and rpc:block_call()Björn Gustavsson
The documentation for rpc:call() says: Evaluates apply(Module, Function, Args) on the node Node and returns the corresponding value Res, or {badrpc, Reason} if the call fails. What is not said that rpc:call() can generate an exception if the 'rex' process on the other node is killed: (kalle@host)1> Rex = rpc:call(arne@host, erlang, whereis, [rex]). <6937.14.0> (kalle@host)2> rpc:call(arne@host, erlang, exit, [Rex,kill]). ** exception exit: {killed, {gen_server,call, [{rex,arne@host}, {call,erlang,exit,[<6937.14.0>,kill],<0.33.0>}, infinity]}} in function rpc:rpc_check/1 (rpc.erl, line 361) On the other hand, if the other node shuts down for some other reason, we'll get a {badrpc,nodedown} result: (kalle@host)5> rpc:call(arne@host, erlang, halt, []). {badrpc,nodedown} There does not seem to be any reason to handle the two cases differently. If the 'rex' process is terminated on the other node, it will shut down shortly thereafter. Therefore, change rpc:call() and rpc:block_call() to always return {badrpc,Reason} is the call fails: (kalle@host)1> Rex = rpc:call(arne@host, erlang, whereis, [rex]). <6937.14.0> (kalle@host)2> rpc:call(arne@host, erlang, exit, [Rex,kill]). {badrpc,{'EXIT',{killed,{gen_server,call, [{rex,arne@host}, {call,erlang,exit,[<7126.14.0>,kill],<0.33.0>}, infinity]}}}}
2016-03-11net_kernel: Separate exports into documented and non-documented groupsBjörn Gustavsson
2016-03-11erl_distribution: Simplify start_link/0 and friendsBjörn Gustavsson
start_link/0 and friends are too convoluted for me.
2016-03-11Reorder and comment API functionsBjörn Gustavsson
Move all functions meant to be called from other modules before the internal functions. Comment them to make it clearer what their purpose are.
2016-03-11Clean up splitting of node namesBjörn Gustavsson
2016-03-10Improved scheduler suspend functionalityRickard Green
- The calling process is now suspended while synchronizing scheduler suspends via erlang:system_flag(schedulers_online, _) and erlang:system_flag(multi_scheduling, _), instead of blocking the scheduler thread in the BIF call waiting for the operation to synchronize. Besides releasing the scheduler for other work (or immediate suspend) it also makes it possible to abort the operation by killing the process. - erlang:system_flag(schedulers_online, _) now only wait for normal schedulers to complete before it returns. This since it may take a very long time before all dirty schedulers suspends. - erlang:system_flag(multi_scheduling, block_normal|unblock_normal) which only operate on normal schedulers has been introduced. This since there are use cases where suspend of dirty schedulers are not of interest (hipe loader). - erlang:system_flag(multi_scheduling, block) still blocks all dirty schedulers as well as all normal schedulers except one since it is hard to redefine what multi scheduling block means. - The three operations: - changing amount of schedulers online - blocking/unblocking normal multi scheduling - blocking/unblocking full multi scheduling can now be done in parallel. This is important since otherwise a full multi scheduling block would potentially delay the other operations for a very long time.
2016-03-02Merge branch 'siri/appups-19.0'Siri Hansen
* siri/appups-19.0: Update appups in kernel, stdlib and sasl for OTP-19
2016-03-01Merge branch 'maint'Ingela Anderton Andin
2016-03-01Merge branch 'msantos/epmd-IPv6-node-reg2/PR-864/OTP-13364' into maintIngela Anderton Andin
* msantos/epmd-IPv6-node-reg2/PR-864/OTP-13364: epmd: support IPv6 node registration
2016-03-01Update appups in kernel, stdlib and sasl for OTP-19Siri Hansen
2016-02-29Merge branch 'maint'Siri Hansen
2016-02-29Merge branch 'siri/appups-18.3' into maintSiri Hansen
* siri/appups-18.3: Update appups in kernel, stdlib and sasl for OTP-18.3
2016-02-26Merge branch 'bjorn/multiple-load/OTP-13111'Björn Gustavsson
* bjorn/multiple-load/OTP-13111: code: Add functions that can load multiple modules Refactor post_beam_load handling Simplify and robustify code_server:all_loaded/1 Update preloaded modules Add erl_prim_loader:get_modules/3 Add has_prepared_code_on_load/1 BIF Allow erlang:finish_loading/1 to load more than one module beam_load.c: Add a function to check for an on_load function