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) ->
|
until(infinity) ->
|
||||||
infinity;
|
infinity;
|
||||||
until(Timeout) ->
|
until(Timeout) ->
|
||||||
{Me, S, Mi} = os:timestamp(),
|
erlang:monotonic_time(milli_seconds) + Timeout.
|
||||||
Me * 1000000000 + S * 1000 + Mi div 1000 + Timeout.
|
|
||||||
|
|
||||||
%% Request parsing.
|
%% Request parsing.
|
||||||
%%
|
%%
|
||||||
|
@ -125,9 +124,7 @@ until(Timeout) ->
|
||||||
recv(Socket, Transport, infinity) ->
|
recv(Socket, Transport, infinity) ->
|
||||||
Transport:recv(Socket, 0, infinity);
|
Transport:recv(Socket, 0, infinity);
|
||||||
recv(Socket, Transport, Until) ->
|
recv(Socket, Transport, Until) ->
|
||||||
{Me, S, Mi} = os:timestamp(),
|
Timeout = Until - erlang:monotonic_time(milli_seconds),
|
||||||
Now = Me * 1000000000 + S * 1000 + Mi div 1000,
|
|
||||||
Timeout = Until - Now,
|
|
||||||
if Timeout < 0 ->
|
if Timeout < 0 ->
|
||||||
{error, timeout};
|
{error, timeout};
|
||||||
true ->
|
true ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue