aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs/common/socket_int.h
AgeCommit message (Collapse)Author
2019-06-26[esock] Counters for individual socketsMicael Karlberg
We already had the counters. But we did not entirely handle counter wrap, especially in related to 'iow' (Inform On Wrap). There was also no way to get to the counter values, so a socket specific info function was implemented (piggy back on the existing "global" info function). And since, we have it, we also add other info in the returned map (number of readers, writers and acceptors). OTP-15818
2019-06-24[esock] Add command (nif) functionMicael Karlberg
Add a command function to the socket API. Currently only used for changing global debug. OTP-15817
2019-05-29[esock] Finalize handling of Unix Domain SocketMicael Karlberg
Corrected various issues and added missing stuff. Default protocol is now indicated with the atom 'default' instead of the atom 'null'. Also let the underlying OS decide what protocol is actually the default protocol. OTP-15822
2019-04-17[socket] Make use of the new select (read|write) functionsMicael Karlberg
Make use of the new select functions; enif_select_[read|write], for read and write select. These functions allows us to construct the select message ourseves: {'$socket', Socket, select, Ref} This is in preparations for when we introduce the 'nowait' (or something similar) value for the timeout argument (in accept, read and write funcions). It also solves (we hope) the term leakage problems (it was difficult to free the environment when there was only one/socket). OTP-15496
2019-04-17[socket|net] Make set|get options safe and type prefixMicael Karlberg
Firstly, make sure socket (and own) options manipulations are safe by adding a mutex that we take in the setopt and getopt functions. Secondly, change type prefix of various types from 'Socket' to 'ESock' (for instance; SocketDescriptor -> ESockDescriptor). OTP-15496
2019-03-06[socket] Use (new) enif_compare_pids functionMicael Karlberg
Replace the won function for pid compare with the (new) enif_compare_pids function. OTP-15565
2019-03-05[socket] Make use of official monitor to term functionMicael Karlberg
Remove own function to make monitor printable (was a hack) and make use of the new enif_make_monitor_term instead.
2019-03-04[socket|net] Macro abuseMicael Karlberg
Make use of macro concat magic to simplify declarations. OTP-15565
2019-02-22[socket] More fixes to socket closeMicael Karlberg
Better handling of socket close. The 'closeRef' needed its own environment to make if work in both cases (both called and scheduled). Also Introduced the enif select wrapper functions (read, write, stop and cancel). Also add error handling at every time one of these functions are called. OTP-14831
2018-12-14[socket-nif] Message interface between socket.erl and nif updatedMicael Karlberg
Previously the "message interface" between the functions in socket.erl and the nif-code (socket_nif.c) was "ad hoc". This has now been changed so that we have a unified message {'$socket', SockRef | undefined, Tag, Info} This also has the added advantage of preparing the code for when we start using the new select-fucntions (with which its possible to specify your own message). This will be used in order to get around our eterm "leak" (we will use a simple counter, maintained in the nif, instead of the [Recv|Send|Acc]Ref we generate in the erlang code today. OTP-14831
2018-12-06[socket-nif] Valgrind: plugged memory leaks in nif_recvMicael Karlberg
Running valgrind, found a couple of cases when allocated binaries where not released. Mostly when the recv failed for some reason. Also clear and free the environment associated with the socket (resource) (in the _dtor callback function). OTP-14831
2018-10-18Merge branch 'bmk/20181004/nififying_inet_rework_test_suite/OTP-14831' into ↵Micael Karlberg
bmk/20180918/nififying_inet/OTP-14831
2018-10-18[socket-nif] Socket closeMicael Karlberg
Fixed a number of issues regarding monitor handling. Monitors are now wrapped in its own type (ESockMonitor). This is hopefully temporary! The reason for this is that there is no way to "initialize" a monitor after a demonitor. This could mean that after a successful demonitor, you could still get a down-callback, and thenh compare with, for instance, ctrlMOn field and get a match, even though it was just (successfully) demonitor'ed. To make debugging easier, the monitor and demonitor calls are now wrapped in their own functions, with debug printouts before and in case of failure, also after the actual calls Also, fixed a number of problems with cancel, where monitors where left still active after cleaning up current and active reader, writer and acceptor. OTP-14831
2018-10-09[socket-nif] Completed (ahum) the socket option(s) part of supportsMicael Karlberg
"Completed" the socket options part of the supports function. OTP-14831
2018-10-08[socket-nif] Add the options for socket, ip and ipv6 for supportsMicael Karlberg
Add the options for level socket (full), ip and ipv6 to the supports function. 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] Add owner validation when setopt controlling_processMicael Karlberg
Before allowing setopt(Sock, opt, controlling_process, NewPid), verify that the caller is actually the current controlling_process. OTP-14831
2018-09-27[socket-nif] Add proper recv timeout handlingMicael Karlberg
Added proper recv timeout handling. Made use of the enif_select(mode = cancel) feature. Each time a timeout expires, the "active" recv (the surrent reader select) has to be cancelled. Not yet tested...something for the new test suite... Also, added support for getopt(controlling_pprocess) that, for some reason, was not yet implemented. 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 more control message decodingMicael Karlberg
Added decoding of the "known" control message options: pktinfo, recvtos, recvttl and recvorigdstaddr). 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 socket) option(s) [rcv|snd]timeoMicael Karlberg
Added support for socket level socket option RCVTIMEO and SNDTIMEO. These are both a little strange, at least on linux. See the man pages for more info. OTP-14831
2018-09-18[socket-nif] Add (partial) support for socket (level sctp) option associnfoMicael Karlberg
Added support for the SCTP option ASSOCINFO. This option is a bit tricky. As the underlying structure (sctp_assocparams) contains the assoc_id, it begs the question what happens if this option is fetched for: * The own assoc (which means that we might have the assoc id in the descriptor and can initiate that part of the struct accordningly). * Another assoc: From assoc A asks for info with assoc_id set to that of assoc B. * The "owning" endpoint. * Another endpoint (an endpoint to which the assoc does not belong). So, if the user calls socket:[getopt|setopt] for an association socket, shall we require that the assoc_id field is set to -1? Or not set at all and therefor filled in automatically by the nif-code? And, if the user calls socket:[getopt|setopt] for an endpoint socket, shall we require that the assoc_id field is set to a valid id? Or shall it not be allowed? Questions, questions... OTP-14831
2018-09-18[socket-nif] Add support for multiple acceptor processesMicael Karlberg
Its now possible to have multiple (simultaneous) acceptor processes for the same listening socket. OTP-14831
2018-09-18[net-nif] Changed return type of getaddrinfoMicael Karlberg
The returned address info was supposed to be a map, by was instead (still) a record. OTP-14831
2018-09-18[socket-nif] Add doc for net module and some cleanupMicael Karlberg
Added doc for the net module. Also some socket-nif cleanup. OTP-14831
2018-09-18[socket-nif] Fixed (stream) recvMicael Karlberg
Fixed handling of closed in the recv function. We still need to properly handle when we get 0 bytes of data for other types ock sockets then stream (its valid for dgram for instance). OTP-14831
2018-09-18[socket+net-nif] BackupMicael Karlberg
2018-09-18[socket+net-nif] Introduced a couple of common filesMicael Karlberg
Started to move the common stuff, such as common utility functions, debug and encode / decode of basic types. OTP-14831