diff options
author | Loïc Hoguin <[email protected]> | 2015-07-27 17:31:24 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-07-27 17:31:24 +0200 |
commit | ccd786baee23fd3432c78ed2569b644ecb96f1d2 (patch) | |
tree | f93f441fc3e110b4532d5999d394db96095d6dd0 | |
parent | e92385038957dcda1429ee4fd93e921f3eb30f81 (diff) | |
download | cowboy-ccd786baee23fd3432c78ed2569b644ecb96f1d2.tar.gz cowboy-ccd786baee23fd3432c78ed2569b644ecb96f1d2.tar.bz2 cowboy-ccd786baee23fd3432c78ed2569b644ecb96f1d2.zip |
Use erlang:monotonic_time instead of os:timestamp
Avoids unnecessary calculations.
-rw-r--r-- | src/cowboy_protocol.erl | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl index 5a20f6b..90128c3 100644 --- a/src/cowboy_protocol.erl +++ b/src/cowboy_protocol.erl @@ -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 -> |