You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Filipe David Manana <fd...@apache.org> on 2011/01/21 16:18:42 UTC
Re: svn commit: r1061828 - /couchdb/trunk/src/couchdb/couch_httpd.erl
- ("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, <be...@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."
Re: svn commit: r1061828 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Posted by Filipe David Manana <fd...@apache.org>.
On Fri, Jan 21, 2011 at 3:37 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>>
>>
> oh. Sorry was thinking you were speaking about function arity ... your
> "/3" . Adding missing pattern.
:)
np
>
> - benoît
>
--
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."
Re: svn commit: r1061828 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jan 21, 2011 at 4:34 PM, Filipe David Manana
<fd...@apache.org> wrote:
> On Fri, Jan 21, 2011 at 3:29 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Fri, Jan 21, 2011 at 4:18 PM, Filipe David Manana
>> <fd...@apache.org> wrote:
>>> - ("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.
>>>
>>
>> Sound like couch_config:register handle that: (couch_config.erl line 160) .
>
> I don't understand the reply.
> What I was talking about is that you're now ignoring new values for
> the "server_options" parameter. Your config_change/2 function is
> missing a clause like:
>
> config_change("httpd", "server_options") ->
> ?MODULE:stop;
>
>
oh. Sorry was thinking you were speaking about function arity ... your
"/3" . Adding missing pattern.
- benoît
Re: svn commit: r1061828 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Posted by Filipe David Manana <fd...@apache.org>.
On Fri, Jan 21, 2011 at 3:29 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Fri, Jan 21, 2011 at 4:18 PM, Filipe David Manana
> <fd...@apache.org> wrote:
>> - ("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.
>>
>
> Sound like couch_config:register handle that: (couch_config.erl line 160) .
I don't understand the reply.
What I was talking about is that you're now ignoring new values for
the "server_options" parameter. Your config_change/2 function is
missing a clause like:
config_change("httpd", "server_options") ->
?MODULE:stop;
>
> - benoît
>
--
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."
Re: svn commit: r1061828 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Jan 21, 2011 at 4:18 PM, Filipe David Manana
<fd...@apache.org> wrote:
> - ("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.
>
Sound like couch_config:register handle that: (couch_config.erl line 160) .
- benoît