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 2019/09/09 17:56:09 UTC
[couchdb] branch prototype/fdb-layer updated: Fix _changes
heartbeat option
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/prototype/fdb-layer by this push:
new 5c3517a Fix _changes heartbeat option
5c3517a is described below
commit 5c3517ab67d3412abd6187c571385c2e148a79ce
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Sep 9 13:40:57 2019 -0400
Fix _changes heartbeat option
`TimeoutFun` was already returning `{ok|stop, UserAcc}` so there was no need to
wrap it another `{ok, ...} tuple.
Also TimeoutFun was calling user with`{timeout, _ResponseType}` not just
timeout, so added a clause to handle that as well.
---
src/chttpd/src/chttpd_changes.erl | 8 ++++----
src/chttpd/src/chttpd_db.erl | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/chttpd/src/chttpd_changes.erl b/src/chttpd/src/chttpd_changes.erl
index ba81de3..81fa90f 100644
--- a/src/chttpd/src/chttpd_changes.erl
+++ b/src/chttpd/src/chttpd_changes.erl
@@ -483,10 +483,10 @@ get_changes_timeout(Args, Callback) ->
end;
true ->
{DefaultTimeout,
- fun(UserAcc) -> {ok, Callback({timeout, ResponseType}, UserAcc)} end};
+ fun(UserAcc) -> Callback({timeout, ResponseType}, UserAcc) end};
_ ->
{lists:min([DefaultTimeout, Heartbeat]),
- fun(UserAcc) -> {ok, Callback({timeout, ResponseType}, UserAcc)} end}
+ fun(UserAcc) -> Callback({timeout, ResponseType}, UserAcc) end}
end.
start_sending_changes(Callback, UserAcc) ->
@@ -961,9 +961,9 @@ maybe_heartbeat(Timeout, TimeoutFun, Acc) ->
Now = os:timestamp(),
case timer:now_diff(Now, Before) div 1000 >= Timeout of
true ->
- Acc2 = TimeoutFun(Acc),
+ {StopOrGo, Acc2} = TimeoutFun(Acc),
put(last_changes_heartbeat, Now),
- Acc2;
+ {StopOrGo, Acc2};
false ->
{ok, Acc}
end
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 16774a2..a1f1212 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -210,7 +210,7 @@ changes_callback(waiting_for_updates, Acc) ->
#cacc{buffer = Buf, mochi = Resp} = Acc,
{ok, Resp1} = chttpd:send_delayed_chunk(Resp, Buf),
{ok, Acc#cacc{buffer = [], bufsize = 0, mochi = Resp1}};
-changes_callback(timeout, Acc) ->
+changes_callback({timeout, _ResponseType}, Acc) ->
{ok, Resp1} = chttpd:send_delayed_chunk(Acc#cacc.mochi, "\n"),
{ok, Acc#cacc{mochi = Resp1}};
changes_callback({error, Reason}, #cacc{mochi = #httpd{}} = Acc) ->