You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2017/03/01 16:38:55 UTC
[08/50] couch commit: updated refs/heads/2971-count-distinct to
ee32cd5
Add couch_debug:opened_files_by_regexp/1
couch_debug:opened_files_by_regexp is an efficient way to find out list
of file descriptors or couch_file processes which path matches given
regexp
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/8553050a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/8553050a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/8553050a
Branch: refs/heads/2971-count-distinct
Commit: 8553050abdde53bb189567aa0b7173cd669a40e7
Parents: fb12795
Author: ILYA Khlopotov <ii...@apache.org>
Authored: Fri Oct 21 11:26:18 2016 -0700
Committer: ILYA Khlopotov <ii...@apache.org>
Committed: Fri Oct 21 11:32:57 2016 -0700
----------------------------------------------------------------------
src/couch_debug.erl | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8553050a/src/couch_debug.erl
----------------------------------------------------------------------
diff --git a/src/couch_debug.erl b/src/couch_debug.erl
index 31b4c5c..e2d5ea1 100644
--- a/src/couch_debug.erl
+++ b/src/couch_debug.erl
@@ -12,7 +12,10 @@
-module(couch_debug).
--export([opened_files/0]).
+-export([
+ opened_files/0,
+ opened_files_by_regexp/1
+]).
-spec opened_files() ->
[{port(), CouchFilePid :: pid(), Fd :: pid() | tuple(), FilePath :: string()}].
@@ -31,3 +34,11 @@ couch_file_port_info(Port) ->
undefined ->
undefined
end.
+
+-spec opened_files_by_regexp(FileRegExp :: iodata()) ->
+ [{port(), CouchFilePid :: pid(), Fd :: pid() | tuple(), FilePath :: string()}].
+opened_files_by_regexp(FileRegExp) ->
+ {ok, RegExp} = re:compile(FileRegExp),
+ lists:filter(fun({_Port, _Pid, _Fd, Path}) ->
+ re:run(Path, RegExp) =/= nomatch
+ end, couch_debug:opened_files()).