aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs
AgeCommit message (Collapse)Author
2019-02-01[socket-nif] nosup expection of win32 and type(s) replacementsMicael Karlberg
The nif callback functions (nif_open) now instead cause an 'nosup' exception if called (instead of badarg). The basic type uint16_t, uint32_t and int32_t (C99) replaced "own" (that is, defined by "us") types Uint16, Uint32 and Sint32. The point of this is that our Windows build system seems to be a bit lacking when it comes to types... Removed "some stuff" that was if-defed. Different solution when win32 support for sockets has been improved. Make sure the socket_*.c util modules are not included in the building for windows. OTP-15526
2019-01-30[socket-nif] Preliminary windows adaptionsMicael Karlberg
Added preliminary, and temporary, windows adaptions. Basically they amount to letting all nif-callback functions returning badarg for all calls if on windows (this has been accomplished by if-defing the nif-code; if win32 then badarg else do-something). OTP-15526
2019-01-29[socket-nif] The otp rcvbuf option updatedMicael Karlberg
Its now possible to set a rcvbuf (otp) option value of {N :: pos_integer(), BufSz :: pos_integer()}. This value is used for type stream and protocol tcp, when calling the function recv with length = 0 (zero). The second value, BufSz, is the actual size of the receive buffer used when calling the socket recv function, and the first value, N, is the max number of possible reads that will be performed (at most), even if there is more data to read. This is limit the effect of DoS attacks. OTP-15497
2019-01-25[socket-nif] Correct state checks when calling read and write functionsMicael Karlberg
The read and write functions now *only* use the isReadable and isWritable fields, respectively, to decide if the "socket" can be read from and written to (previously the state field was used outside of the mutex lock). Also made it possible to enable / disable test suite groups individually, via environment variables (ESOCK_TEST_...). Specifically, the ttest group has been excluded by default (takes to long a time). OTP-15549
2019-01-21[socket-nif] Add support for otp option fdMicael Karlberg
Add a way to *get* the file descriptor (fd) of a socket. Useful mostly for debugging. OTP-15528
2018-12-21[socket-nif] Fixed OpenBSD configMicael Karlberg
The macro (define) IPTOS_MINCOST does not exist on OpenBSD 6.3. 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_[recvfrom<recvmsg]Micael Karlberg
"Dry fixed" the "same" problems as was found for nif_recv (missing binary free(s)). 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-12-05Merge branch 'bmk/20181205/nififying_inet_ttest/OTP-14831' into ↵Micael Karlberg
bmk/20180918/nififying_inet/OTP-14831
2018-12-05[socket-nif] Fixed two minor problems with socket close and downMicael Karlberg
* Socket close callback Only demonitor the closer if its local (close) and its not a direct call. There was a spurious warning message. * Down callback Only process this event if the socket is not closed or closing. OTP-14831
2018-12-05[socket-nif] Increased the default read buffer sizeMicael Karlberg
The default read buffer size was 2K and has now been increased to 8K. OTP-14831
2018-11-27[socket-nif] Conditional use of sctp struct fieldMicael Karlberg
Added config checks for the sctp struct field: sctp_event_subscribe.sctp_authentication_event Also, if-def'ed the code accordingly. If-def'ed code to handle the (non-) existence of IP_PMTUDISC_PROBE and IPV6_PMTUDISC_PROBE for the IP and IPv6 MTU_DISCOVER options. OTP-14831
2018-11-26[socket-nif] Conditional use of sctp struct fieldMicael Karlberg
Added config checks for the sctp struct field: sctp_event_subscribe.sctp_sender_dry_event Also, if-def'ed the code accordingly. OTP-14831
2018-11-06[socket-nif] Badly handled socket close for recvfrom and recvmsgMicael Karlberg
When type = dgram, the functions recvfrom and recvmsg did not properly handle socket close, cuaing the caller to hang indefinitely. OTP-14831
2018-11-05[socket-nif] Sending when buffer is full failedMicael Karlberg
When the send buffer was full (eagain), the send failed (with the rather useless return of {ok, -1}) instead of returning {error, eagain}. OTP-14831
2018-11-05[socket-nif] Make it possible to send (nif) debug to fileMicael Karlberg
Make it possible to open a file and send debug printouts to (instead of stdout) for debug printouts from the nif-code. OTP-14831
2018-11-02[socket-nif] Inherit buffer sizes when acceptingMicael Karlberg
An "accepted" socket will inherit the parent (listen) socket's buffer sizes (rBufSz, rCtrlSz and wCtrlSz). OTP-14831
2018-11-01[sock-nif|test] Add a ping-pong test caseMicael Karlberg
We got some kind of send hang...
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-22[socket-nif] Initiation of "current reader" missing for recvfromMicael Karlberg
When calling the recvfrom function when there is no data, we should be made wait (for the specified amount of time). But this did not work because the "current reader" structure was not initiated. OTP-14831
2018-10-18[socket-nif] setopt and getopt with level ipv6Micael Karlberg
The level argument for IPv6 can be either SOL_IPV6 or IPPROTO_IPV6, whichever is defined. But it was hard- coded to SOL_IPV6, which is not defined on FreeBSD. 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] Initiation of "current reader" missing for recvmsgMicael Karlberg
When calling the recvmsg function when there is no data, we should be wait (for the specified amount of time). But this not not wotk because the "current reader" structure was not initiated. 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-16[socket-nif] Recv handling of closing socketsMicael Karlberg
Fixed more issues regarding closing sockets. Specifically with respect to recv calls. Also, added demonitor for all *current* processes. Also fixed a buffer overflow problem when writing an warning message (the timestamp buffer was not large enough). OTP-14831
2018-10-15[socket-nif] Fix socket close when owner process exitsMicael Karlberg
The handling of terminating controlling-process was incomplete. Also added state check (CLOSED and CLOSING) in all nif-functions to prevent access for a closed (or closing) socket. 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-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-05[socket-nif] Add *preliminary* new function supports/0,1Micael Karlberg
2018-10-04Merge branch 'bmk/20181004/nififying_inet_freebsd_fixes/OTP-14831' into ↵Micael Karlberg
bmk/20180918/nififying_inet/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-10-04[socket-nif] Fixed decode of send and recv flagsMicael Karlberg
Add explicitly handling the default case, when not flags are provided (value of zero). 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-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-27[socket-nif] Improve socket stopMicael Karlberg
Make sure the current whatever (writer, reader or writer) is not the closer pid before *attempting* to sending the abort message. And if that fails, issue a warning message (not aborting). 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-21Merge branch 'bmk/20180918/nififying_inet_freebsd/OTP-14831' into ↵Micael Karlberg
bmk/20180918/nififying_inet/OTP-14831 Also needed to "revert" two of the chnages, related to assoc id. This is in FreeBSD defined as an uint32 but on linux as a int32.
2018-09-21[socket-nif] Moved include file (FreeBSD)Micael Karlberg
2018-09-21[socket-nif] More constant if-def and header include movingMicael Karlberg
2018-09-20[socket-nif] Various fixes related to FreeBSD environmentMicael Karlberg
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] Encoding of cmsg headers for sendmsgMicael Karlberg
Fixed various issues with regard to encode of CMsgHdrs during sendmsg. 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