aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/ebin
AgeCommit message (Collapse)Author
2018-11-13Avoid closing files in gc/monitor callbacksJohn Högberg
Closing files in these callbacks could block scheduler progress and cause major system instability. We now defer these operations to a dedicated process instead. This process may in turn block forever and prevent further orphaned files from being closed, but it will keep the emulator itself from misbehaving.
2018-11-06[socket-nif|test] Add UDP ping-pong test casesMicael Karlberg
Added ping-pong test cases for UDP, small and medium, using the sendto/recvfrom and sendmsg/recvmsg functions. OTP-14831
2018-11-06Merge branch 'maint'Björn Gustavsson
* maint: Implement a tab for persistent terms in crashdump viewer Add tests of persistent terms for crashdump_viewer Add a persistent term storage Refactor releasing of literals Extend the sharing-preserving routines to optionally copy literals Conflicts: erts/emulator/Makefile.in erts/emulator/beam/erl_process_dump.c erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/init.beam lib/sasl/src/systools_make.erl
2018-11-06Add a persistent term storageBjörn Gustavsson
Persistent terms are useful for storing Erlang terms that are never or infrequently updated. They have the following advantages: * Constant time access. A persistent term is not copied when it is looked up. The constant factor is lower than for ETS, and no locks are taken when looking up a term. * Persistent terms are not copied in garbage collections. * There is only ever one copy of a persistent term (until it is deleted). That makes them useful for storing configuration data that needs to be easily accessible by all processes. Persistent terms have the following drawbacks: * Updates are expensive. The hash table holding the keys for the persistent terms are updated whenever a persistent term is added, updated or deleted. * Updating or deleting a persistent term triggers a "global GC", which will schedule a heap scan of all processes to search the heap of all processes for the deleted term. If a process still holds a reference to the deleted term, the process will be garbage collected and the term copied to the heap of the process. This global GC can make the system less responsive for some time. Three BIFs (implemented in C in the emulator) is the entire interface to the persistent term functionality: * put(Key, Value) to store a persistent term. * get(Key) to look up a persistent term. * erase(Key) to delete a persistent term. There are also two additional BIFs to obtain information about persistent terms: * info() to return a map with information about persistent terms. * get() to return a list of a {Key,Value} tuples for all persistent terms. (The values are not copied.)
2018-11-05[socket-nif] Add "partial success" to sendmsgMicael Karlberg
The sendmsg function attempts to send *one message*. But its possible for the underlying software to fail to send the *entire* message. So, instead of retrying itself, as send does, the sendmsg function will now instead return with {ok, Remaining}, leaving it to the caller to decide what to do. OTP-14831
2018-10-30[socket-nif] Add a send and receive chunks test caseMicael Karlberg
The send and recv test case triggered a two bugs. One was that there was no re-selecting when only a portion of the data was received (which meant that we stopped reading). Also, the wrong 'current' (writer) was reset when demonitor current reader after a successful read (which meant that future readers would never have been monitored). OTP-14831
2018-10-22Merge branch 'maint'Raimo Niskanen
Conflicts: erts/preloaded/ebin/prim_inet.beam
2018-10-22Merge branch 'raimo/tcp-close-while-send/maint/ERL-561/OTP-12242' into maintRaimo Niskanen
* raimo/tcp-close-while-send/maint/ERL-561/OTP-12242: Write test case Fix hanging gen_tcp send vs close race Conflicts: erts/preloaded/ebin/prim_inet.beam
2018-10-19Fix hanging gen_tcp send vs close raceRaimo Niskanen
While a gen_tcp send was in progress with filled buffers and slow receiver a close (from another process) would place the port in a half dead state so the port could not signal back to send, that waited for confirmation. The solution is to after some time (5 s) of waiting for send confirmation set a monitor on the port, which detects if the port becomes half dead due to close from another process. The close pending loop has also been improved to use the linger timeout for waiting, and to set a system timeout (arbitrarily selected 3 min) to not wait forever when the other end reads data s l o w l y (tarpitting, kind of).
2018-10-17Merge branch 'maint'John Högberg
* maint: "cork" tcp socket around file:sendfile Add nopush TCP socket option
2018-10-17Merge branch 'igor/tcp-nopush-ERL-698/OTP-15357' into maintJohn Högberg
* igor/tcp-nopush-ERL-698/OTP-15357: "cork" tcp socket around file:sendfile Add nopush TCP socket option
2018-10-12Merge branch 'maint'Raimo Niskanen
Conflicts: erts/preloaded/ebin/prim_inet.beam
2018-10-09[socket-nif|doc] Add preliminary doc for the function supportsMicael Karlberg
Added preliminary documentation for the function socket:supports/0,1,2,3. It still does not generate proper doc for supports/3 (the last arg, Opt, don't get a type). OTP-14831
2018-10-09[socket-nif] The supports function now also handles sctp and ipv6Micael Karlberg
The supports function now also handles testing for SCTP and IPv6 support. Basic test at the moment, but better then nothing. OTP-14831
2018-10-05[socket-nif] Add first three socket (socket) options to supportsMicael Karlberg
Added the first three socket (level socket) options to the supports function(s). OTP-14831
2018-10-04[socket-nif] Socket option 'SO_DOMAIN' not avalable on all platformsMicael Karlberg
Internally in the socket module we accessed domain, type and protocol for an open socket. But as it turns out, domain (family) is not actually available as a socket option on all platforms. FreeBSD in this case. So, since we store these values in the socket descriptor anyway, we switch to use these values for our internal use instead. OTP-14831
2018-10-02Implement {netns,NS} option for inet:getifaddrs/1Raimo Niskanen
Also implement the same option for the legacy undocumented functions inet:getif/1,getiflist/1,ifget/2,ifset/2. The arity 1 functions had before this change got signatures that took a socket port that was used to do the needed syscall, so now the signature was extended to also take an option list with the only supported option {netns,Namespace}. The Socket argument variant remains unsupported. For inet:getifaddrs/1 the documentation file was changed to old style function name definition so be able to hide the Socket argument variant that is visible in the type spec. The arity 2 functions had got an option list as second argument. This list had to be partitioned into one list for the namespace option(s) and the other for the rest. The namespace option list was then fed to the already existing namespace support for socket opening, which places the socket in a namespace and hence made all these functions that in inet_drv.c used getsockopt() work without change. The functions that used getifaddrs() in inet_drv.c had to be changed in inet_drv.c to swap namespaces around the getifaddrs() syscall. This functionality was separated into a new function call_getifaddrs().
2018-10-01Merge branch 'richcarl/erts/erl_init-cleanup/OTP-15336'Lukas Larsson
* richcarl/erts/erl_init-cleanup/OTP-15336: sasl: Order systools_make:preloaded modules alphabetically Update preloaded modules Move calling on_load for preloaded modules to erl_init Make erl_init.c pass the boot module to erl_init.beam Remove obsolete comment text Remove undocumented and unused -# display_items emulator option Remove broken and undocumented boot function emulator option Replace remaining references to otp_ring0 with erl_init Drop otp_ring0, using erl_init instead Update preloaded modules Add erl_init module Conflicts: erts/emulator/beam/erl_init.c erts/preloaded/ebin/erl_prim_loader.beam erts/preloaded/ebin/erl_tracer.beam erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_code_purger.beam erts/preloaded/ebin/erts_dirty_process_signal_handler.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/erts_literal_area_collector.beam erts/preloaded/ebin/init.beam erts/preloaded/ebin/otp_ring0.beam erts/preloaded/ebin/prim_buffer.beam erts/preloaded/ebin/prim_eval.beam erts/preloaded/ebin/prim_file.beam erts/preloaded/ebin/prim_inet.beam erts/preloaded/ebin/prim_zip.beam erts/preloaded/ebin/zlib.beam
2018-09-28[socket-nif] Add support for socket (level otp) buffer optionsMicael Karlberg
Add support for otp level socket options rcvbuf, rcvctrlbuf and sndctrlbuf. These options define default sizes for these buffers. The 'rcvbuf' is used when receiving messages when calling the recv, recvfrom and recvmsg functions. The 'rcvctrlbuf' is used for the control message header info when calling the recvmsg function. The 'sndctrlbuf' is used for the control message header info when calling the sendmsg function. OTP-14831
2018-09-20[socket-nif] Add proper send timeout handlingMicael Karlberg
Added proper send timeout handling. Made use of the enif_select(mode = cancel) feature. Each time a timeout expires, the "active" send (the surrent write select) has to be cancelled. OTP-14831
2018-09-19[socket-nif] Add proper connect and accept timeout handlingMicael Karlberg
Added proper connect and accept timeout handling. Made use of the enif_select(mode = cancel) feature. Each time a timeout expires, the previous operation (connect or accept) has to be cancelled (actually its the select operation that has to be cancelled). Only partial implementation of cancel for now (connect and accept). More to follow... OTP-14831
2018-09-18[socket-nif] Post rebase updateMicael Karlberg
2018-09-18[socket-nif] Cleanup and guardsMicael Karlberg
Some cleanup and also added a guard to sendmsg to ensure that only ctrl (cmsg hdr) with actual content will be "sent down". OTP-14831
2018-09-18[socket-nif] CMsgHdr and various doc related changesMicael Karlberg
Updated the (send) cmsghdr type and the handling of it (in the nif code). Still not tested! Removed the is_loaded nif function. Tried to get fix the doc build problem (socket.erl *i think*), which causes socket.html generation to fail with: "cannot find module exporting type" To solve this I tried to run dialyzer on preloaded, and ran into problems with enc_setopt_value. Update various specs and types to "solve" this (which did not work). Updated the nif-stub functions to make dialyzer happy.
2018-09-18[socket-nif] Add support for (recvmsg) control message ipv6_pktinfoMicael Karlberg
Added support for (recvmsg) control message ipv6_pktinfo, for level = ipv6 and type = pktinfo. This is enabled by setting the socket option: recvpktinfo for level ipv6. Not yet tested! OTP-14831
2018-09-18[socket-nif] Add more data types (with doc) and (C) debugMicael Karlberg
Add more debug printouts for the new sendmsg. Also added new (erlang) types with doc. OTP-14831
2018-09-18[socket-nif] Add preliminary support for sendmsgMicael Karlberg
Added function sendmsg/2,3,4. Actually worked on the first try. Something must be wrong... Still no supported cmsghdr's (only support headers where the data part is already a binary, which therefor does not require any processing). So if the cmsghdrs actually work is unclear. OTP-14831
2018-09-18[socket-nif] Processing of more cmsg headersMicael Karlberg
Added processing or more cmsg headers (for more options). Now (also) supports: socket:timestamp. Also various fixes and cleanups. For some reason calling getopt(Sock, 0, {13, int}) (or similar) fails with badarg even though the nif-function (nif_getopt) actually returns a valid value (for instance: {ok, 0}). OTP-14831
2018-09-18[socket-nif] Add support for recvmsgMicael Karlberg
Added preliminary support for function recvmsg. At the moment this only works on *nix (Windows has another function, WSARecvMsg, which has a slightly different API). Also we have "no" cmsg decode at the moment (just level and type). OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option sendsrcaddrMicael Karlberg
Added support for ip level socket option SENDSRCADDR. This option requires sendmsg to actually use, so we cannot test this fully at the moment. OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option recvorigdstaddrMicael Karlberg
Added support for ip level socket option RECVORIGDSTADDR. This option requires recvmsg to actually use, so we cannot test this fully at the moment (although both set and get works). OTP-14831
2018-09-18[socket-nif] Updated socket typeMicael Karlberg
Updated the socket type. No longer store "stuff" that can be retrieved by other means (domain, type and protocol). OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option retoptsMicael Karlberg
Added support for ip level socket option RETOPTS. OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option transparentMicael Karlberg
Added support for ip level socket option TRANSPARENT. OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option pktinfoMicael Karlberg
Added support for ip level socket option PKTINFO. This option requires sendmsg and/or recvmsg to actually use, so we cannot test this fully at the moment (although both set and get works). OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option hdrinclMicael Karlberg
Added support for ip level socket option HDRINCL. As this option is raw only, it has not yet been tested! OTP-14831
2018-09-18[socket-nif] Add support for socket (level ip) option msfilterMicael Karlberg
Added support for ip level socket option MSFILTER. This option has not been tested *in any way*... OTP-14831
2018-09-18[socket-nif] Add support for socket (level ipv6) option recverrMicael Karlberg
Added support for the IPv6 socket option RECVERR. To actually make use of this option, we need the recvmsg function, which we don't have yet. Baby steps. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ip) option recverrMicael Karlberg
Added support for the IP socket option RECVERR. To actually make use of this option, we need the recvmsg function, which we don't have yet. Baby steps. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option addrformMicael Karlberg
Added support for the IPv6 socket option ADDRFORM. Only allowed for IPv6 sockets that are connected and bound to a v4-mapped-on-v6 address. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option router_alertMicael Karlberg
Added support for the IPv6 socket option ROUTER_ALERT. Only supported for raw sockets. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option unicast_hopsMicael Karlberg
Added support for the IPv6 socket option UNICAST_HOPS. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option flowinfoMicael Karlberg
Added support for the IPv6 socket option(s) FLOWINFO. The option returns with einval when calling setsockopt, so either you need to be a privileged user to update, or its not actually possible to update this option (even though it says nothing about that in the man page. It only talks about set). This is the same behaviour as with DSTOPTS. Needs furher checking. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option dstoptsMicael Karlberg
Added support for the IPv6 socket option(s) DSTOPTS. The option returns with einval when calling setsockopt, so either you need to be a privileged user to update, or its not actually possible to update this option (even though it says nothing about that in the man page. It only talks about set). This is the same behaviour as with RTHDR and HOPLIMIT. On FreeBSD, it says that HOPOPTS requires superuser privileges. Needs furher checking. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option authhdr & hopoptsMicael Karlberg
Added support for the IPv6 socket option(s) AUTHHDR and HOPOPTS. Its possible that the option is AUTHHDR is obsolete. It says so in the include files and when trying to get it (getsockopt) it returns with enoprotoopt. The option HOPOPTS returns with einval when calling setsockopt, so either you need to be a privileged user to update, or its not actually possible to update this option (even though it says nothing about that in the man page. It only talks about set). This is the same behaviour as with RTHDR and HOPLIMIT. On FreeBSD, it says that HOPOPTS requires superuser privileges. Needs furher checking. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option rthdrMicael Karlberg
Added support for the IPv6 socket option RTHDR. On FreeBSD this option requires superuser privileges to update. There is no mention of this on linux, but its still not possible to update (einval), so I assume that its the same there. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option recvpktinfoMicael Karlberg
Added support for the IPv6 socket option RECVPKTINFO. This option is called PKTINFO on FreeBSD, so that value will also be accepted. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option multicast_loopMicael Karlberg
Added support for the IPv6 socket option MULTICAST_LOOP. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option multicast_ifMicael Karlberg
Added support for the IPv6 socket option MULTICAST_IF. OTP-14831.
2018-09-18[socket-nif] Add support for socket (level ipv6) option multicast_hopsMicael Karlberg
Added support for the IPv6 socket option MULTICAST_HOPS. OTP-14831.