From 43939e525330a779301eee28cf5d36710ed0cb07 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 27 Jun 2019 12:39:09 +0200 Subject: [esock|doc] Add documentation for the (socket) info function Add documentation for the (socket) info function, which (among other things) return the socket counters. Also typed the return value (socket_info()). OTP-15818 --- erts/doc/src/socket.xml | 23 +++++++++++++++++++++++ erts/preloaded/ebin/socket.beam | Bin 75844 -> 76064 bytes erts/preloaded/src/socket.erl | 15 ++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index b4e22e86a8..da049b1a7f 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -111,6 +111,15 @@ + + + + + + + + + @@ -455,6 +464,20 @@ + + + Get miscellaneous socket info. + +

Get miscellaneous info about the socket.

+

The function returns a map with each info item as a key-value + binding. It reflects the "current" state of the socket.

+ +

In order to ensure data integrity, mutex'es are taken when + needed. So, do not call this function often.

+
+
+
+ diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam index 42959cac4b..25eb0b2f4a 100644 Binary files a/erts/preloaded/ebin/socket.beam and b/erts/preloaded/ebin/socket.beam differ diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index b0f84700a1..be94e3a867 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -67,6 +67,10 @@ select_ref/0, select_info/0, + socket_counters/0, + socket_counter/0, + socket_info/0, + %% command/0, domain/0, @@ -153,6 +157,15 @@ }. %% -type command() :: debug_command(). +-type socket_counters() :: [{socket_counter(), non_neg_integer()}]. +-type socket_counter() :: read_byte | read_fails | read_pkg | read_tries | + read_waits | write_byte | write_fails | write_pkg | + write_tries | write_waits. +-type socket_info() :: #{counters := socket_counters(), + num_readers := non_neg_integer(), + num_writers := non_neg_integer(), + num_acceptors := non_neg_integer()}. + -type uint8() :: 0..16#FF. -type uint16() :: 0..16#FFFF. -type uint20() :: 0..16#FFFFF. @@ -912,7 +925,7 @@ command(#{command := debug, %% %% =========================================================================== --spec info(Socket) -> map() when +-spec info(Socket) -> socket_info() when Socket :: socket(). info(#socket{ref = SockRef}) -> -- cgit v1.2.3