diff options
author | Micael Karlberg <[email protected]> | 2019-04-15 14:00:31 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-05-29 14:12:32 +0200 |
commit | 0fbe9b5bddf3d6f0869068666256274660a98d53 (patch) | |
tree | c0bf582fa3330a87e81e99d09d5ea40ea2915482 /erts | |
parent | 7246c98eac93687343e96913acd07e6261c0933c (diff) | |
download | otp-0fbe9b5bddf3d6f0869068666256274660a98d53.tar.gz otp-0fbe9b5bddf3d6f0869068666256274660a98d53.tar.bz2 otp-0fbe9b5bddf3d6f0869068666256274660a98d53.zip |
[socket] Update accept to handle Timeout = nowait
Update function accept and its spec(s) to handle
the Timeout value of nowait.
Diffstat (limited to 'erts')
-rw-r--r-- | erts/preloaded/ebin/socket.beam | bin | 74296 -> 74516 bytes | |||
-rw-r--r-- | erts/preloaded/src/socket.erl | 26 |
2 files changed, 20 insertions, 6 deletions
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam Binary files differindex c353f62b18..76ea46ea73 100644 --- a/erts/preloaded/ebin/socket.beam +++ b/erts/preloaded/ebin/socket.beam diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index b2085b4b59..073a699b1a 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -1279,18 +1279,27 @@ listen(#socket{ref = SockRef}, Backlog) accept(Socket) -> accept(Socket, ?SOCKET_ACCEPT_TIMEOUT_DEFAULT). --spec accept(LSocket, Timeout) -> {ok, Socket} | {error, Reason} when - LSocket :: socket(), - Timeout :: timeout(), - Socket :: socket(), - Reason :: term(). +-spec accept(LSocket, nowait) -> + {ok, Socket} | + {ok, SelectInfo} | + {error, Reason} when + LSocket :: socket(), + Socket :: socket(), + SelectInfo :: select_info(), + Reason :: term() + ; (LSocket, Timeout) -> {ok, Socket} | {error, Reason} when + LSocket :: socket(), + Timeout :: timeout(), + Socket :: socket(), + Reason :: term(). %% Do we really need this optimization? accept(_, Timeout) when is_integer(Timeout) andalso (Timeout =< 0) -> {error, timeout}; accept(#socket{ref = LSockRef}, Timeout) when is_integer(Timeout) orelse - (Timeout =:= infinity) -> + (Timeout =:= infinity) orelse + (Timeout =:= nowait) -> do_accept(LSockRef, Timeout). do_accept(LSockRef, Timeout) -> @@ -1301,6 +1310,11 @@ do_accept(LSockRef, Timeout) -> Socket = #socket{ref = SockRef}, {ok, Socket}; + + {error, eagain} when (Timeout =:= nowait) -> + {ok, ?SELECT_INFO(accept, AccRef)}; + + {error, eagain} -> %% Each call is non-blocking, but even then it takes %% *some* time, so just to be sure, recalculate before |