aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-04-16 13:43:45 +0200
committerMicael Karlberg <[email protected]>2019-05-29 14:22:47 +0200
commit1039d05f393d470a1edba93a0026f4fba7d2ce5b (patch)
treedc6182cf7911aa20a667309a75ea968a3a8f77be /erts/preloaded/src
parente95430644d7f9144a632b89370222c3b7119dc33 (diff)
downloadotp-1039d05f393d470a1edba93a0026f4fba7d2ce5b.tar.gz
otp-1039d05f393d470a1edba93a0026f4fba7d2ce5b.tar.bz2
otp-1039d05f393d470a1edba93a0026f4fba7d2ce5b.zip
[socket] Add cancel and the first recvfrom(nowait) cancel test case
Add the (public) cancel function and the first of the cancel test cases (recvfrom(nowait)).
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r--erts/preloaded/src/socket.erl23
1 files changed, 22 insertions, 1 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index c805c5586d..f4d8f175f8 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -53,7 +53,9 @@
getopt/3,
sockname/1,
- peername/1
+ peername/1,
+
+ cancel/2
]).
-export_type([
@@ -2586,6 +2588,25 @@ peername(#socket{ref = SockRef}) ->
nif_peername(SockRef).
+%% ===========================================================================
+%%
+%% cancel - cancel an operation resulting in a select
+%%
+%% A call to accept, recv/recvfrom/recvmsg and send/sendto/sendmsg
+%% can result in a select if they are called with the Timeout argument
+%% set to nowait. This is indicated by the return of the select-info.
+%% Such a operation can be cancelled by calling this function.
+%%
+
+-spec cancel(Socket, SelectInfo) -> ok | {error, Reason} when
+ Socket :: socket(),
+ SelectInfo :: select_info(),
+ Reason :: term().
+
+cancel(#socket{ref = SockRef}, {select, Tag, Ref}) ->
+ cancel(SockRef, Tag, Ref).
+
+
%% ===========================================================================
%%