aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-09-20 15:37:37 +0200
committerMicael Karlberg <[email protected]>2018-09-20 16:29:05 +0200
commit13d10bc60a41f98647d802524ea8ef8fa9af6b39 (patch)
tree2a56b2fa3b0d63c05c49aea93427a343e149835f /erts/preloaded/src
parente01a856c993b55c3fbc76fd429783d4aad5bfc80 (diff)
downloadotp-13d10bc60a41f98647d802524ea8ef8fa9af6b39.tar.gz
otp-13d10bc60a41f98647d802524ea8ef8fa9af6b39.tar.bz2
otp-13d10bc60a41f98647d802524ea8ef8fa9af6b39.zip
[socket-nif] Add proper send timeout handling
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
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r--erts/preloaded/src/socket.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 1c16c94711..652054457f 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -1345,10 +1345,19 @@ sendto(Socket, Data, Dest) ->
Data :: binary(),
Dest :: null | sockaddr(),
Flags :: send_flags(),
- Reason :: term().
+ Reason :: term()
+ ; (Socket, Data, Dest, Timeout) -> ok | {error, Reason} when
+ Socket :: socket(),
+ Data :: iodata(),
+ Dest :: null | sockaddr(),
+ Timeout :: timeout(),
+ Reason :: term().
+
+sendto(Socket, Data, Dest, Flags) when is_list(Flags) ->
+ sendto(Socket, Data, Dest, Flags, ?SOCKET_SENDTO_TIMEOUT_DEFAULT);
+sendto(Socket, Data, Dest, Timeout) ->
+ sendto(Socket, Data, Dest, ?SOCKET_SENDTO_FLAGS_DEFAULT, Timeout).
-sendto(Socket, Data, Dest, Flags) ->
- sendto(Socket, Data, Dest, Flags, ?SOCKET_SENDTO_TIMEOUT_DEFAULT).
-spec sendto(Socket, Data, Dest, Flags, Timeout) -> ok | {error, Reason} when
Socket :: socket(),