couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [1/3] couch commit: updated refs/heads/master to 189af37
Date Fri, 21 Oct 2016 19:09:26 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master fb12795de -> 189af37a8


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/master
Commit: 8553050abdde53bb189567aa0b7173cd669a40e7
Parents: fb12795
Author: ILYA Khlopotov <iilyak@apache.org>
Authored: Fri Oct 21 11:26:18 2016 -0700
Committer: ILYA Khlopotov <iilyak@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()).


Mime
View raw message