You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/08/12 22:43:17 UTC

couch commit: updated refs/heads/windsor-merge to a651e1d

Repository: couchdb-couch
Updated Branches:
  refs/heads/windsor-merge b480af32f -> a651e1dd4


Update the task if any props change

This ignores the frequency setting and just updates forcefully on any
change to the task properties.


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

Branch: refs/heads/windsor-merge
Commit: a651e1dd49a2eb8321715f976ec91654cd741ffb
Parents: b480af3
Author: Paul J. Davis <pa...@gmail.com>
Authored: Tue Aug 12 15:42:35 2014 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Tue Aug 12 15:42:35 2014 -0500

----------------------------------------------------------------------
 src/couch_task_status.erl | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/a651e1dd/src/couch_task_status.erl
----------------------------------------------------------------------
diff --git a/src/couch_task_status.erl b/src/couch_task_status.erl
index 8a8dbf2..8adba6b 100644
--- a/src/couch_task_status.erl
+++ b/src/couch_task_status.erl
@@ -68,9 +68,14 @@ set_update_frequency(Msecs) ->
 
 update(Props) ->
     MergeProps = lists:ukeysort(1, Props),
-    TaskProps = lists:ukeymerge(1, MergeProps, erlang:get(task_status_props)),
-    put(task_status_props, TaskProps),
-    maybe_persist(TaskProps).
+    CurrProps = erlang:get(task_status_props),
+    TaskProps = lists:ukeymerge(1, MergeProps, CurrProps),
+    case TaskProps == CurrProps of
+        true ->
+            maybe_persist(TaskProps);
+        false ->
+            persist(TaskProps)
+    end.
 
 
 get(Props) when is_list(Props) ->
@@ -81,18 +86,22 @@ get(Prop) ->
     couch_util:get_value(Prop, TaskProps).
 
 
-maybe_persist(TaskProps0) ->
+maybe_persist(TaskProps) ->
     {LastUpdateTime, Frequency} = erlang:get(task_status_update),
     case timer:now_diff(Now = os:timestamp(), LastUpdateTime) >= Frequency of
     true ->
         put(task_status_update, {Now, Frequency}),
-        TaskProps = ?set(TaskProps0, updated_on, timestamp(Now)),
-        gen_server:cast(?MODULE, {update_status, self(), TaskProps});
+        persist(TaskProps);
     false ->
         ok
     end.
 
 
+persist(TaskProps0) ->
+    TaskProps = ?set(TaskProps0, updated_on, timestamp(os:timestamp())),
+    gen_server:cast(?MODULE, {update_status, self(), TaskProps}).
+
+
 init([]) ->
     % read configuration settings and register for configuration changes
     ets:new(?MODULE, [ordered_set, protected, named_table]),