You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2021/06/07 17:25:57 UTC
[couchdb-ibrowse] 01/05: Add strictly monotonic timestamp (#173)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch upstream-rebase
in repository https://gitbox.apache.org/repos/asf/couchdb-ibrowse.git
commit 6c811515914266fde875c4f868cb8ff0a341c23f
Author: Noah Shaw <no...@yahoo.com>
AuthorDate: Sun Jun 6 19:49:06 2021 -0400
Add strictly monotonic timestamp (#173)
---
src/ibrowse_http_client.erl | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl
index 5443fe7..98a475f 100644
--- a/src/ibrowse_http_client.erl
+++ b/src/ibrowse_http_client.erl
@@ -484,6 +484,15 @@ accumulate_response(Data, #state{reply_buffer = RepBuf,
State#state{reply_buffer = RepBuf_1}
end.
+generate_timestamp() ->
+ case catch erlang:unique_integer([positive]) of
+ {'EXIT', _} ->
+ erlang:apply(erlang, now, []);
+ Unique ->
+ {A,B,C} = os:timestamp(),
+ {A * 1000000 + B, C, Unique}
+ end.
+
make_tmp_filename(true) ->
DownloadDir = ibrowse:get_config_value(download_dir, filename:absname("./")),
{A,B,C} = os:timestamp(),
@@ -2050,12 +2059,7 @@ cancel_timer(Ref, {eat_message, Msg}) ->
end.
make_req_id() ->
- case catch erlang:unique_integer() of
- {'EXIT', _} ->
- erlang:apply(erlang, now, []);
- V ->
- V
- end.
+ generate_timestamp().
to_lower(Str) when is_binary(Str) ->
to_lower(binary_to_list(Str));