anchor.diff:  handle_cast(_Msg, State) ->
       {noreply, State}.
   
  +handle_info({'EXIT', _, {ok, Proc0, {Client,_} = From}}, State) ->
  +    link(Proc0#proc.pid),
  +    Proc = Proc0#proc{client = erlang:monitor(process, Client)},
  +    gen_server:reply(From, {ok, Proc, get_query_server_config()}),
  +    ets:insert(State#state.tab, Proc),
  +    {noreply, State};
  +
   handle_info({'EXIT', Pid, Reason}, State) ->
       ?LOG_INFO("~p ~p died ~p", [?MODULE, Pid, Reason]),
       ets:delete(State#state.tab, Pid),
  
positive.code: get_procs(Tab, Lang) when is_binary(Lang) ->
      get_procs(Tab, binary_to_list(Lang));
  get_procs(Tab, Lang) when is_list(Lang) ->
      case ets:match_object(Tab, #proc{lang=Lang, client=nil, _='_'}) of
      [] ->
          {ok, NewProc} = new_proc(Lang), % check OS process limit
          [NewProc];
      Procs ->
          Procs
      end.
  
  new_proc(Lang) when is_list(Lang) ->
      case couch_config:get("query_servers", Lang) of
      undefined ->
          case couch_config:get("native_query_servers", Lang) of
          undefined ->
              throw({unknown_query_language, Lang});
          SpecStr ->
              {ok, {M,F,A}} = couch_util:parse_term(SpecStr),
              {ok, Pid} = apply(M, F, A),
  
negative.code: handle_call(get_proc_count, _From, State) ->
      {reply, ets:info(State#state.tab, size), State};
  
  handle_call({get_proc, #doc{body={Props}}=DDoc, DDocKey}, From, State) ->
      Lang = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
      try get_procs(State#state.tab, Lang) of
      [] ->
          spawn_link(?MODULE, new_proc, [From, Lang, DDoc, DDocKey]),
          {noreply, State};
      Procs ->
          case proc_with_ddoc(DDoc, DDocKey, Procs) of
          {ok, Proc0} ->
              Client = element(1, From),
              Proc = Proc0#proc{client = erlang:monitor(process, Client)},
              ets:insert(State#state.tab, Proc),
              {reply, {ok, Proc, get_query_server_config()}, State};
          {error, Reason} ->
              {reply, {error, Reason}, State}
          end
      catch error:Reason ->
          ?LOG_ERROR("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]),
          {reply, {error, Reason}, State}
      end;
  
  handle_call({get_proc, Lang}, {Client, _} = From, State) ->
      try get_procs(State#state.tab, Lang) of
      [] ->
          spawn_link(?MODULE, new_proc, [From, Lang]),
          {noreply, State};
      [Proc0|_] ->
          Proc = Proc0#proc{client = erlang:monitor(process, Client)},
          ets:insert(State#state.tab, Proc),
          {reply, {ok, Proc, get_query_server_config()}, State}
      catch error:Reason ->
          ?LOG_ERROR("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]),
          {reply, {error, Reason}, State}
      end;
  