iilyak commented on a change in pull request #539: Close idle dbs
URL: https://github.com/apache/couchdb/pull/539#discussion_r119726561
##########
File path: src/couch/src/couch_file.erl
##########
@@ -338,12 +339,33 @@ init_status_error(ReturnPid, Ref, Error) ->
ReturnPid ! {Ref, self(), Error},
ignore.
+last_read(Fd) when is_pid(Fd) ->
+ ReadTsSec = case process_info(Fd, dictionary) of
+ {dictionary, Dict} ->
+ case lists:keyfind(read_timestamp, 1, Dict) of
+ false ->
+ 0;
+ {read_timestamp, Ts} ->
+ Ts
+ end;
+ undefined ->
+ 0
+ end,
+ case now_sec() - ReadTsSec of
Review comment:
This is not quite right. Consider the case when `ReadTsSec = 0`. In this
case `now_sec() - ReadTsSec` would be equal to `now_sec()` which is greater
than 0. So we return the value of a `now_sec()`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services