mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Use erlang:monotonic_time instead of os:timestamp
Avoids unnecessary calculations.
This commit is contained in:
parent
e923850389
commit
ccd786baee
1 changed files with 2 additions and 5 deletions
|
@ -110,8 +110,7 @@ init(Ref, Socket, Transport, Opts) ->
|
|||
until(infinity) ->
|
||||
infinity;
|
||||
until(Timeout) ->
|
||||
{Me, S, Mi} = os:timestamp(),
|
||||
Me * 1000000000 + S * 1000 + Mi div 1000 + Timeout.
|
||||
erlang:monotonic_time(milli_seconds) + Timeout.
|
||||
|
||||
%% Request parsing.
|
||||
%%
|
||||
|
@ -125,9 +124,7 @@ until(Timeout) ->
|
|||
recv(Socket, Transport, infinity) ->
|
||||
Transport:recv(Socket, 0, infinity);
|
||||
recv(Socket, Transport, Until) ->
|
||||
{Me, S, Mi} = os:timestamp(),
|
||||
Now = Me * 1000000000 + S * 1000 + Mi div 1000,
|
||||
Timeout = Until - Now,
|
||||
Timeout = Until - erlang:monotonic_time(milli_seconds),
|
||||
if Timeout < 0 ->
|
||||
{error, timeout};
|
||||
true ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue