aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-05-10 14:26:41 +0200
committerMicael Karlberg <[email protected]>2019-06-24 15:10:42 +0200
commitcd0f46d1f286b28d1289c2be4218c83b980f241d (patch)
tree614175b78e8106424a552558f551756dc355f3ff /erts/preloaded
parentba72ec760adfc8c35628d7e02477d4b0f42d0e07 (diff)
downloadotp-cd0f46d1f286b28d1289c2be4218c83b980f241d.tar.gz
otp-cd0f46d1f286b28d1289c2be4218c83b980f241d.tar.bz2
otp-cd0f46d1f286b28d1289c2be4218c83b980f241d.zip
[esock] Add command (nif) function
Add a command function to the socket API. Currently only used for changing global debug. OTP-15817
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/socket.beambin75044 -> 75444 bytes
-rw-r--r--erts/preloaded/src/socket.erl32
2 files changed, 30 insertions, 2 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index 134b4eac13..d19e0c40b4 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 ae1ffdb4ac..3a43504f8f 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -26,9 +26,12 @@
%% Administrative and "global" utility functions
-export([
on_load/0, on_load/1,
+
+ ensure_sockaddr/1,
+
+ command/1,
info/0,
- supports/0, supports/1, supports/2, supports/3,
- ensure_sockaddr/1
+ supports/0, supports/1, supports/2, supports/3
]).
-export([
@@ -63,6 +66,8 @@
select_ref/0,
select_info/0,
+ command/0,
+
domain/0,
type/0,
protocol/0,
@@ -135,6 +140,18 @@
]).
+%% The command type has the general form:
+%% #{
+%% command := atom(),
+%% data := term()
+%% }
+%% But only certain values are actually valid, so the type gets the form:
+-type debug_command() :: #{
+ command := debug,
+ data := boolean()
+ }.
+-type command() :: debug_command().
+
-type uint8() :: 0..16#FF.
-type uint16() :: 0..16#FFFF.
-type uint20() :: 0..16#FFFFF.
@@ -867,6 +884,14 @@ info() ->
nif_info().
+-spec command(Command) -> term() when
+ Command :: command().
+
+command(#{command := debug,
+ data := Dbg} = Command) when is_boolean(Dbg) ->
+ nif_command(Command).
+
+
%% ===========================================================================
%%
@@ -3845,6 +3870,9 @@ error(Reason) ->
nif_info() ->
erlang:nif_error(undef).
+nif_command(_Command) ->
+ erlang:nif_error(undef).
+
nif_supports(_Key) ->
erlang:nif_error(undef).