aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-03-08 15:37:15 +0100
committerMicael Karlberg <[email protected]>2019-04-17 16:56:33 +0200
commit9dcdb6714391c4f496e91f95cb293bf7bdf97f2c (patch)
tree99b39f5823da28f33b604c2dfbf404f5bf1a1a53 /erts/preloaded
parentde49a641d635b2b0c494e64f78069049ab56cd5e (diff)
downloadotp-9dcdb6714391c4f496e91f95cb293bf7bdf97f2c.tar.gz
otp-9dcdb6714391c4f496e91f95cb293bf7bdf97f2c.tar.bz2
otp-9dcdb6714391c4f496e91f95cb293bf7bdf97f2c.zip
[socket] Messages from the nif code now has a proper socket
The messages sent from the nif code to an erlang process has been changed to: {'$socket', Socket :: socket(), Tag :: atom(), Info :: term()} This is in preparation for (using) the new enif select API. OTP-15496
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/socket.beambin70312 -> 70284 bytes
-rw-r--r--erts/preloaded/src/socket.erl30
2 files changed, 18 insertions, 12 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index e44dff8475..23b3269990 100644
--- a/erts/preloaded/ebin/socket.beam
+++ b/erts/preloaded/ebin/socket.beam
Binary files differ
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 5c1647290d..5687b067f3 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -586,6 +586,12 @@
#{level := integer(), type := integer(), data := binary()}.
+%% This is used in messages sent from the nif-code to erlang processes:
+%%
+%% {?SOCKET_TAG, Socket, Tag, Info}
+%%
+-define(SOCKET_TAG, '$socket').
+
-define(SOCKET_DOMAIN_LOCAL, 1).
-define(SOCKET_DOMAIN_UNIX, ?SOCKET_DOMAIN_LOCAL).
-define(SOCKET_DOMAIN_INET, 2).
@@ -1347,7 +1353,7 @@ do_accept(LSockRef, Timeout) ->
{select, LSockRef, AccRef, ready_input} ->
do_accept(LSockRef, next_timeout(TS, Timeout));
- {'$socket', _, abort, {AccRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {AccRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -1424,7 +1430,7 @@ do_send(SockRef, Data, EFlags, Timeout) ->
do_send(SockRef, Data, EFlags,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {SendRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {SendRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -1437,7 +1443,7 @@ do_send(SockRef, Data, EFlags, Timeout) ->
do_send(SockRef, Data, EFlags,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {SendRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {SendRef, Reason}} ->
{error, Reason}
after Timeout ->
@@ -1529,7 +1535,7 @@ do_sendto(SockRef, Data, Dest, EFlags, Timeout) ->
do_sendto(SockRef, Data, Dest, EFlags,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {SendRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {SendRef, Reason}} ->
{error, Reason}
after Timeout ->
@@ -1543,7 +1549,7 @@ do_sendto(SockRef, Data, Dest, EFlags, Timeout) ->
do_sendto(SockRef, Data, Dest, EFlags,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {SendRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {SendRef, Reason}} ->
{error, Reason}
after Timeout ->
@@ -1793,7 +1799,7 @@ do_recv(SockRef, _OldRef, Length, EFlags, Acc, Timeout)
Bin,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {RecvRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {RecvRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -1813,7 +1819,7 @@ do_recv(SockRef, _OldRef, Length, EFlags, Acc, Timeout)
<<Acc/binary, Bin/binary>>,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {RecvRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {RecvRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -1838,7 +1844,7 @@ do_recv(SockRef, _OldRef, Length, EFlags, Acc, Timeout)
Acc,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {RecvRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {RecvRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -1977,7 +1983,7 @@ do_recvfrom(SockRef, BufSz, EFlags, Timeout) ->
do_recvfrom(SockRef, BufSz, EFlags,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {RecvRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {RecvRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -2081,7 +2087,7 @@ do_recvmsg(SockRef, BufSz, CtrlSz, EFlags, Timeout) ->
do_recvmsg(SockRef, BufSz, CtrlSz, EFlags,
next_timeout(TS, Timeout));
- {'$socket', _, abort, {RecvRef, Reason}} ->
+ {?SOCKET_TAG, _, abort, {RecvRef, Reason}} ->
{error, Reason}
after NewTimeout ->
@@ -2118,7 +2124,7 @@ do_recvmsg(SockRef, BufSz, CtrlSz, EFlags, Timeout) ->
%% 1) nif_close + the socket_stop (nif) callback function
%% This is for everything that can be done safely NON-BLOCKING.
%% 2) nif_finalize_close which is executed by a *dirty* scheduler
-%% Before we call the socket close function, we se the socket
+%% Before we call the socket close function, we set the socket
%% BLOCKING. Thereby linger is handled properly.
@@ -2137,7 +2143,7 @@ do_close(SockRef) ->
%% We must wait for the socket_stop callback function to
%% complete its work
receive
- {'$socket', SockRef, close, CloseRef} ->
+ {?SOCKET_TAG, #socket{ref = SockRef}, close, CloseRef} ->
nif_finalize_close(SockRef)
end;
{error, _} = ERROR ->