Return the query server PIDs and their associated debugger ports
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/915c7e7b Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/915c7e7b Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/915c7e7b Branch: refs/heads/nodejs_couchdb Commit: 915c7e7b0b3a7092b42ffd404c2c18b5528b57c9 Parents: 44d4b5f Author: Jason Smith (work) <j...@iriscouch.com> Authored: Thu Feb 7 08:53:38 2013 +0000 Committer: Jason Smith (work) <j...@iriscouch.com> Committed: Thu Feb 7 08:53:38 2013 +0000 ---------------------------------------------------------------------- src/couchdb/couch_query_servers.erl | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/915c7e7b/src/couchdb/couch_query_servers.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_query_servers.erl b/src/couchdb/couch_query_servers.erl index 54bad8d..b3e1c3a 100644 --- a/src/couchdb/couch_query_servers.erl +++ b/src/couchdb/couch_query_servers.erl @@ -22,6 +22,7 @@ -export([filter_view/3]). -export([with_ddoc_proc/2, proc_prompt/2, ddoc_prompt/3, ddoc_proc_prompt/3, json_doc/1]). +-export([debug_ports/1]). % For 210-os-proc-pool.t -export([get_os_process/1, ret_os_process/1]). @@ -240,6 +241,9 @@ validate_doc_update(DDoc, EditDoc, DiskDoc, Ctx, SecObj) -> throw({unauthorized, Message}) end. +debug_ports(Lang) -> + gen_server:call(couch_query_servers, {get_debugging, ?l2b(Lang)}). + json_doc(nil) -> null; json_doc(Doc) -> couch_doc:to_json_obj(Doc, [revs]). @@ -348,6 +352,18 @@ handle_call({get_proc, Lang}, From, Server) -> Error -> {reply, Error, Server} end; +handle_call({get_debugging, Lang}, _From, Server) -> + #qserver{lang_procs=LangProcs} = Server, + case ets:lookup(LangProcs, Lang) of + [{Lang, Procs}] -> + Ports = lists:map(fun(#proc{pid=Pid, debug_port=Port}) -> + PidStr = io_lib:format("~w", [Pid]), + {?l2b(PidStr), Port} + end, Procs), + {reply, Ports, Server}; + _ -> + {reply, [], Server} + end; handle_call({unlink_proc, Pid}, _From, Server) -> unlink(Pid), {reply, ok, Server};