couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <fdman...@apache.org>
Subject Re: svn commit: r1061828 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Date Fri, 21 Jan 2011 15:18:42 GMT
-        ("httpd", "server_options") ->
-            ?MODULE:stop();

Benoît, I think you forgot to add a matching clause for the new
couch_httpd:config_change/3 function.

On Fri, Jan 21, 2011 at 2:46 PM,  <benoitc@apache.org> wrote:
> Author: benoitc
> Date: Fri Jan 21 14:46:15 2011
> New Revision: 1061828
>
> URL: http://svn.apache.org/viewvc?rev=1061828&view=rev
> Log:
> don't use anonymous function to handle config_changes in couch_httpd.
>
> Modified:
>    couchdb/trunk/src/couchdb/couch_httpd.erl
>
> Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
> URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1061828&r1=1061827&r2=1061828&view=diff
> ==============================================================================
> --- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
> +++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Jan 21 14:46:15 2011
> @@ -13,7 +13,8 @@
>  -module(couch_httpd).
>  -include("couch_db.hrl").
>
> --export([start_link/0, start_link/1, stop/0, handle_request/5]).
> +-export([start_link/0, start_link/1, stop/0, config_change/2,
> +        handle_request/5]).
>
>  -export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,qs_json_value/3]).
>  -export([path/1,absolute_uri/2,body_length/1]).
> @@ -96,42 +97,45 @@ start_link(Name, Options) ->
>         ])
>     end,
>
> -    % and off we go
> -
> -    {ok, Pid} = case mochiweb_http:start(Options ++ ServerOptions ++ [
> -        {loop, Loop},
> -        {name, Name},
> -        {ip, BindAddress}
> -    ]) of
> -    {ok, MochiPid} -> {ok, MochiPid};
> -    {error, Reason} ->
> -        io:format("Failure to start Mochiweb: ~s~n",[Reason]),
> -        throw({error, Reason})
> -    end,
> -
> -    ok = couch_config:register(
> -        fun("httpd", "bind_address") ->
> -            ?MODULE:stop();
> -        ("httpd", "port") ->
> -            ?MODULE:stop();
> -        ("httpd", "default_handler") ->
> -            ?MODULE:stop();
> -        ("httpd", "server_options") ->
> -            ?MODULE:stop();
> -        ("httpd", "socket_options") ->
> -            ?MODULE:stop();
> -        ("httpd_global_handlers", _) ->
> -            ?MODULE:stop();
> -        ("httpd_db_handlers", _) ->
> -            ?MODULE:stop();
> -        ("vhosts", _) ->
> -            ?MODULE:stop();
> -        ("ssl", _) ->
> -            ?MODULE:stop()
> -        end, Pid),
> +    % set mochiweb options
> +    FinalOptions = lists:append([Options, ServerOptions, [
> +            {loop, Loop},
> +            {name, Name},
> +            {ip, BindAddress}]]),
> +
> +    % launch mochiweb
> +    {ok, Pid} = case mochiweb_http:start(FinalOptions) of
> +        {ok, MochiPid} ->
> +            {ok, MochiPid};
> +        {error, Reason} ->
> +            io:format("Failure to start Mochiweb: ~s~n",[Reason]),
> +            throw({error, Reason})
> +    end,
>
> +    ok = couch_config:register(fun ?MODULE:config_change/2, Pid),
>     {ok, Pid}.
>
> +
> +stop() ->
> +    mochiweb_http:stop(?MODULE).
> +
> +config_change("httpd", "bind_addres") ->
> +    ?MODULE:stop();
> +config_change("httpd", "port") ->
> +    ?MODULE:stop();
> +config_change("httpd", "default_handler") ->
> +    ?MODULE:stop();
> +config_change("httpd", "socket_options") ->
> +    ?MODULE:stop();
> +config_change("httpd_global_handlers", _) ->
> +    ?MODULE:stop();
> +config_change("httpd_db_handlers", _) ->
> +    ?MODULE:stop();
> +config_change("vhosts", _) ->
> +    ?MODULE:stop();
> +config_change("ssl", _) ->
> +    ?MODULE:stop().
> +
>  % SpecStr is a string like "{my_module, my_fun}"
>  %  or "{my_module, my_fun, <<"my_arg">>}"
>  make_arity_1_fun(SpecStr) ->
> @@ -162,10 +166,6 @@ make_arity_3_fun(SpecStr) ->
>  make_fun_spec_strs(SpecStr) ->
>     re:split(SpecStr, "(?<=})\\s*,\\s*(?={)", [{return, list}]).
>
> -stop() ->
> -    mochiweb_http:stop(?MODULE).
> -
> -
>  handle_request(MochiReq, DefaultFun, UrlHandlers, DbUrlHandlers,
>     DesignUrlHandlers) ->
>
>
>
>



-- 
Filipe David Manana,
fdmanana@gmail.com, fdmanana@apache.org

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Mime
View raw message