Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 41EB6200BA7 for ; Fri, 21 Oct 2016 21:09:28 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 40895160AF2; Fri, 21 Oct 2016 19:09:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8F63A160ADE for ; Fri, 21 Oct 2016 21:09:27 +0200 (CEST) Received: (qmail 94562 invoked by uid 500); 21 Oct 2016 19:09:26 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 94538 invoked by uid 99); 21 Oct 2016 19:09:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Oct 2016 19:09:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 70959F0DC2; Fri, 21 Oct 2016 19:09:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: iilyak@apache.org To: commits@couchdb.apache.org Date: Fri, 21 Oct 2016 19:09:27 -0000 Message-Id: In-Reply-To: <14674af74d174e2d839f497b2839a9e5@git.apache.org> References: <14674af74d174e2d839f497b2839a9e5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] couch commit: updated refs/heads/master to 189af37 archived-at: Fri, 21 Oct 2016 19:09:28 -0000 Add couch_debug:opened_files_contains/1 couch_debug:opened_files_contains is an efficient way to find out list of file descriptors or couch_file processes which path contains given substring. Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/3888faf8 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/3888faf8 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/3888faf8 Branch: refs/heads/master Commit: 3888faf8182a4f33de37f8fe3852c08e7cefc107 Parents: 8553050 Author: ILYA Khlopotov Authored: Fri Oct 21 11:51:05 2016 -0700 Committer: ILYA Khlopotov Committed: Fri Oct 21 11:51:05 2016 -0700 ---------------------------------------------------------------------- src/couch_debug.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/3888faf8/src/couch_debug.erl ---------------------------------------------------------------------- diff --git a/src/couch_debug.erl b/src/couch_debug.erl index e2d5ea1..633b2c6 100644 --- a/src/couch_debug.erl +++ b/src/couch_debug.erl @@ -14,7 +14,8 @@ -export([ opened_files/0, - opened_files_by_regexp/1 + opened_files_by_regexp/1, + opened_files_contains/1 ]). -spec opened_files() -> @@ -42,3 +43,10 @@ opened_files_by_regexp(FileRegExp) -> lists:filter(fun({_Port, _Pid, _Fd, Path}) -> re:run(Path, RegExp) =/= nomatch end, couch_debug:opened_files()). + +-spec opened_files_contains(FileNameFragment :: iodata()) -> + [{port(), CouchFilePid :: pid(), Fd :: pid() | tuple(), FilePath :: string()}]. +opened_files_contains(FileNameFragment) -> + lists:filter(fun({_Port, _Pid, _Fd, Path}) -> + string:str(Path, FileNameFragment) > 0 + end, couch_debug:opened_files()).