couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [11/11] couch commit: updated refs/heads/master to 7ab7995
Date Wed, 21 May 2014 16:53:26 GMT
Use os:timestamp instead of now() wherever possible


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/1a06391a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/1a06391a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/1a06391a

Branch: refs/heads/master
Commit: 1a06391a522f5d1151c0d9d603a6a659aa8de853
Parents: 9044eac
Author: Robert Newson <rnewson@apache.org>
Authored: Wed May 21 15:10:48 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed May 21 15:17:18 2014 +0100

----------------------------------------------------------------------
 src/couch_auth_cache.erl       | 4 ++--
 src/couch_changes.erl          | 6 +++---
 src/couch_db.erl               | 4 ++--
 src/couch_db_updater.erl       | 2 +-
 src/couch_httpd.erl            | 4 ++--
 src/couch_lru.erl              | 4 ++--
 src/couch_os_daemons.erl       | 4 ++--
 src/couch_proc_manager.erl     | 2 +-
 src/couch_server.erl           | 4 ++--
 src/couch_stats_aggregator.erl | 2 +-
 src/couch_task_status.erl      | 4 ++--
 src/couch_uuids.erl            | 2 +-
 12 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_auth_cache.erl
----------------------------------------------------------------------
diff --git a/src/couch_auth_cache.erl b/src/couch_auth_cache.erl
index 1650495..afc3b1f 100644
--- a/src/couch_auth_cache.erl
+++ b/src/couch_auth_cache.erl
@@ -177,7 +177,7 @@ handle_call({fetch, UserName}, _From, State) ->
     [] ->
         couch_stats_collector:increment({couchdb, auth_cache_misses}),
         Creds = get_user_props_from_db(UserName),
-        State1 = add_cache_entry(UserName, Creds, erlang:now(), State),
+        State1 = add_cache_entry(UserName, Creds, os:timestamp(), State),
         {Creds, State1}
     end,
     {reply, Credentials, NewState};
@@ -271,7 +271,7 @@ free_mru_cache_entry() ->
 
 
 cache_hit(UserName, Credentials, ATime) ->
-    NewATime = erlang:now(),
+    NewATime = os:timestamp(),
     true = ets:delete(?BY_ATIME, ATime),
     true = ets:insert(?BY_ATIME, {NewATime, UserName}),
     true = ets:insert(?BY_USER, {UserName, {Credentials, NewATime}}).

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couch_changes.erl b/src/couch_changes.erl
index f81ee60..d8b5320 100644
--- a/src/couch_changes.erl
+++ b/src/couch_changes.erl
@@ -70,7 +70,7 @@ handle_changes(Args1, Req, Db0) ->
     undefined ->
         erlang:erase(last_changes_heartbeat);
     Val when is_integer(Val); Val =:= true ->
-        put(last_changes_heartbeat, now())
+        put(last_changes_heartbeat, os:timestamp())
     end,
 
     case lists:member(Feed, ["continuous", "longpoll", "eventsource"]) of
@@ -572,7 +572,7 @@ reset_heartbeat() ->
     undefined ->
         ok;
     _ ->
-        put(last_changes_heartbeat, now())
+        put(last_changes_heartbeat, os:timestamp())
     end.
 
 maybe_heartbeat(Timeout, TimeoutFun, Acc) ->
@@ -581,7 +581,7 @@ maybe_heartbeat(Timeout, TimeoutFun, Acc) ->
     undefined ->
         {ok, Acc};
     _ ->
-        Now = now(),
+        Now = os:timestamp(),
         case timer:now_diff(Now, Before) div 1000 >= Timeout of
         true ->
             Acc2 = TimeoutFun(Acc),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_db.erl b/src/couch_db.erl
index 018878f..9d480a9 100644
--- a/src/couch_db.erl
+++ b/src/couch_db.erl
@@ -141,7 +141,7 @@ wait_for_compaction(Db) ->
     wait_for_compaction(Db, infinity).
 
 wait_for_compaction(#db{main_pid=Pid}=Db, Timeout) ->
-    Start = erlang:now(),
+    Start = os:timestamp(),
     case gen_server:call(Pid, compactor_pid) of
         CPid when is_pid(CPid) ->
             Ref = erlang:monitor(process, CPid),
@@ -149,7 +149,7 @@ wait_for_compaction(#db{main_pid=Pid}=Db, Timeout) ->
                 {'DOWN', Ref, _, _, normal} when Timeout == infinity ->
                     wait_for_compaction(Db, Timeout);
                 {'DOWN', Ref, _, _, normal} ->
-                    Elapsed = timer:now_diff(now(), Start) div 1000,
+                    Elapsed = timer:now_diff(os:timestamp(), Start) div 1000,
                     wait_for_compaction(Db, Timeout - Elapsed);
                 {'DOWN', Ref, _, _, Reason} ->
                     {error, Reason}

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_db_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl
index 901e8c3..330f8cb 100644
--- a/src/couch_db_updater.erl
+++ b/src/couch_db_updater.erl
@@ -494,7 +494,7 @@ init_db(DbName, Filepath, Fd, Header0, Options) ->
         {ok, Security} = couch_file:pread_term(Fd, SecurityPtr)
     end,
     % convert start time tuple to microsecs and store as a binary string
-    {MegaSecs, Secs, MicroSecs} = now(),
+    {MegaSecs, Secs, MicroSecs} = os:timestamp(),
     StartTime = ?l2b(io_lib:format("~p",
             [(MegaSecs*1000000*1000000) + (Secs*1000000) + MicroSecs])),
     ok = couch_file:set_db_pid(Fd, self()),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index f03f2d6..83fb630 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -200,7 +200,7 @@ handle_request(MochiReq, DefaultFun, UrlHandlers, DbUrlHandlers,
 
 handle_request_int(MochiReq, DefaultFun,
             UrlHandlers, DbUrlHandlers, DesignUrlHandlers) ->
-    Begin = now(),
+    Begin = os:timestamp(),
     % for the path, use the raw path with the query string and fragment
     % removed, but URL quoting left intact
     RawUri = MochiReq:get(raw_path),
@@ -346,7 +346,7 @@ handle_request_int(MochiReq, DefaultFun,
             ?LOG_INFO("Stacktrace: ~p",[Stack]),
             send_error(HttpReq, Error)
     end,
-    RequestTime = round(timer:now_diff(now(), Begin)/1000),
+    RequestTime = round(timer:now_diff(os:timestamp(), Begin)/1000),
     couch_stats_collector:record({couchdb, request_time}, RequestTime),
     couch_stats_collector:increment({httpd, requests}),
     {ok, Resp}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_lru.erl
----------------------------------------------------------------------
diff --git a/src/couch_lru.erl b/src/couch_lru.erl
index a236cdd..7742055 100644
--- a/src/couch_lru.erl
+++ b/src/couch_lru.erl
@@ -19,13 +19,13 @@ new() ->
     {gb_trees:empty(), dict:new()}.
 
 insert(DbName, {Tree0, Dict0}) ->
-    Lru = now(),
+    Lru = os:timestamp(),
     {gb_trees:insert(Lru, DbName, Tree0), dict:store(DbName, Lru, Dict0)}.
 
 update(DbName, {Tree0, Dict0}) ->
     case dict:find(DbName, Dict0) of
     {ok, Old} ->
-        New = now(),
+        New = os:timestamp(),
         Tree = gb_trees:insert(New, DbName, gb_trees:delete(Old, Tree0)),
         Dict = dict:store(DbName, New, Dict0),
         {Tree, Dict};

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_os_daemons.erl
----------------------------------------------------------------------
diff --git a/src/couch_os_daemons.erl b/src/couch_os_daemons.erl
index 1c0d1dc..7856678 100644
--- a/src/couch_os_daemons.erl
+++ b/src/couch_os_daemons.erl
@@ -130,7 +130,7 @@ handle_info({Port, {exit_status, Status}}, Table) ->
         [D] ->
             % Port died for unknown reason. Check to see if it's
             % died too many times or if we should boot it back up.
-            case should_halt([now() | D#daemon.errors]) of
+            case should_halt([os:timestamp() | D#daemon.errors]) of
                 {true, _} ->
                     % Halting the process. We won't try and reboot
                     % until the configuration changes.
@@ -376,7 +376,7 @@ should_halt(Errors) ->
     RetryTimeCfg = config:get("os_daemon_settings", "retry_time", "5"),
     RetryTime = list_to_integer(RetryTimeCfg),
 
-    Now = now(),
+    Now = os:timestamp(),
     RecentErrors = lists:filter(fun(Time) ->
         timer:now_diff(Now, Time) =< RetryTime * 1000000
     end, Errors),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_proc_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_proc_manager.erl b/src/couch_proc_manager.erl
index a0fc5c2..9aca645 100644
--- a/src/couch_proc_manager.erl
+++ b/src/couch_proc_manager.erl
@@ -372,7 +372,7 @@ maybe_spawn_proc(State, Client) ->
     end.
 
 add_waiting_client(Tab, Client) ->
-    ets:insert(Tab, Client#client{timestamp=now()}).
+    ets:insert(Tab, Client#client{timestamp=os:timestamp()}).
 
 get_waiting_client(Tab, Lang) when is_list(Lang) ->
     get_waiting_client(Tab, couch_util:to_binary(Lang));

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_server.erl b/src/couch_server.erl
index e03c1e4..b3a3999 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -285,7 +285,7 @@ maybe_close_lru_db(#server{lru=Lru}=Server) ->
 
 open_async(Server, From, DbName, Filepath, Options) ->
     Parent = self(),
-    put({async_open, DbName}, now()),
+    put({async_open, DbName}, os:timestamp()),
     Opener = spawn_link(fun() ->
         Res = couch_db:start_link(DbName, Filepath, Options),
         case {Res, lists:member(create, Options)} of
@@ -328,7 +328,7 @@ handle_call(get_server, _From, Server) ->
 handle_call({open_result, DbName, {ok, Db}}, _From, Server) ->
     link(Db#db.main_pid),
     case erase({async_open, DbName}) of undefined -> ok; T0 ->
-        ?LOG_INFO("needed ~p ms to open new ~s", [timer:now_diff(now(),T0)/1000,
+        ?LOG_INFO("needed ~p ms to open new ~s", [timer:now_diff(os:timestamp(),T0)/1000,
             DbName])
     end,
     % icky hack of field values - compactor_pid used to store clients

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_stats_aggregator.erl
----------------------------------------------------------------------
diff --git a/src/couch_stats_aggregator.erl b/src/couch_stats_aggregator.erl
index 416c9a0..45987d6 100644
--- a/src/couch_stats_aggregator.erl
+++ b/src/couch_stats_aggregator.erl
@@ -141,7 +141,7 @@ handle_call(collect_sample, _, {OldTRef, SampleInterval}) ->
     end, couch_stats_collector:all(absolute)),
     
     Values = Incs ++ Abs,
-    Now = erlang:now(),
+    Now = os:timestamp(),
     lists:foreach(fun({{Key, Rate}, Agg}) ->
         NewAgg = case proplists:lookup(Key, Values) of
             none ->

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_task_status.erl
----------------------------------------------------------------------
diff --git a/src/couch_task_status.erl b/src/couch_task_status.erl
index ea9821f..8dc91b4 100644
--- a/src/couch_task_status.erl
+++ b/src/couch_task_status.erl
@@ -82,7 +82,7 @@ get(Prop) ->
 
 maybe_persist(TaskProps0) ->
     {LastUpdateTime, Frequency} = erlang:get(task_status_update),
-    case timer:now_diff(Now = now(), LastUpdateTime) >= Frequency of
+    case timer:now_diff(Now = os:timestamp(), LastUpdateTime) >= Frequency of
     true ->
         put(task_status_update, {Now, Frequency}),
         TaskProps = ?set(TaskProps0, updated_on, timestamp(Now)),
@@ -145,7 +145,7 @@ code_change(_OldVsn, State, _Extra) ->
 
 
 timestamp() ->
-    timestamp(now()).
+    timestamp(os:timestamp()).
 
 timestamp({Mega, Secs, _}) ->
     Mega * 1000000 + Secs.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/1a06391a/src/couch_uuids.erl
----------------------------------------------------------------------
diff --git a/src/couch_uuids.erl b/src/couch_uuids.erl
index 3065938..e891abb 100644
--- a/src/couch_uuids.erl
+++ b/src/couch_uuids.erl
@@ -40,7 +40,7 @@ utc_random() ->
     utc_suffix(couch_util:to_hex(crypto:rand_bytes(9))).
 
 utc_suffix(Suffix) ->
-    Now = {_, _, Micro} = now(),
+    Now = {_, _, Micro} = erlang:now(), % uniqueness is used.
     Nowish = calendar:now_to_universal_time(Now),
     Nowsecs = calendar:datetime_to_gregorian_seconds(Nowish),
     Then = calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}),


Mime
View raw message