couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r1075728 - in /couchdb/trunk: src/couchdb/couch_httpd.erl src/couchdb/couch_httpd_vhost.erl test/etap/160-vhosts.t
Date Tue, 01 Mar 2011 09:05:34 GMT
Author: benoitc
Date: Tue Mar  1 09:05:33 2011
New Revision: 1075728

URL: http://svn.apache.org/viewvc?rev=1075728&view=rev
Log:
fix error spotted by @enquora on irc. Don't load rules when it isn't needed. ALso fix tests.wq

Modified:
    couchdb/trunk/src/couchdb/couch_httpd.erl
    couchdb/trunk/src/couchdb/couch_httpd_vhost.erl
    couchdb/trunk/test/etap/160-vhosts.t

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1075728&r1=1075727&r2=1075728&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Tue Mar  1 09:05:33 2011
@@ -86,9 +86,6 @@ start_link(Name, Options) ->
     {ok, SocketOptions} = couch_util:parse_term(
         couch_config:get("httpd", "socket_options", "[]")),
 
-    % install vhosts rules
-    couch_httpd_vhost:install(),
-
     Loop = fun(Req)->
         case SocketOptions of
         [] ->

Modified: couchdb/trunk/src/couchdb/couch_httpd_vhost.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_vhost.erl?rev=1075728&r1=1075727&r2=1075728&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_vhost.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_vhost.erl Tue Mar  1 09:05:33 2011
@@ -13,7 +13,7 @@
 -module(couch_httpd_vhost).
 -behaviour(gen_server).
 
--export([start_link/0, config_change/2, install/0, dispatch_host/1]).
+-export([start_link/0, config_change/2, reload/0, get_state/0, dispatch_host/1]).
 -export([urlsplit_netloc/2, redirect_to_vhost/2]).
 
 
@@ -80,8 +80,9 @@
 start_link() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
 
-install() ->
-    gen_server:call(?MODULE, install).
+%% @doc reload vhosts rules
+reload() ->
+    gen_server:call(?MODULE, reload).
 
 get_state() ->
     gen_server:call(?MODULE, get_state).
@@ -188,7 +189,7 @@ try_bind_vhost([VhostSpec|Rest], HostPar
 %% doc: build new patch from bindings. bindings are query args
 %% (+ dynamic query rewritten if needed) and bindings found in
 %% bind_path step. 
-%% TODO: merge code wit rewrite. But we need to make sure we are
+%% TODO: merge code with rewrite. But we need to make sure we are
 %% in string here.
 make_target([], _Bindings, _Remaining, Acc) ->
     lists:reverse(Acc);
@@ -237,9 +238,9 @@ bind_path(_, _) ->
 
 %% create vhost list from ini
 make_vhosts() ->
-    lists:foldl(fun({Vhost, Path}, Acc) ->
-        [{parse_vhost(Vhost), split_path(Path)}|Acc]
-    end, [], couch_config:get("vhosts")).
+    lists:reverse(lists:foldl(fun({Vhost, Path}, Acc) ->
+                    [{parse_vhost(Vhost), split_path(Path)}|Acc]
+            end, [], couch_config:get("vhosts"))).
 
 
 parse_vhost(Vhost) ->
@@ -320,7 +321,7 @@ init(_) ->
         vhosts_fun=Fun},
     {ok, State}.
 
-handle_call(install, _From, _State) ->
+handle_call(reload, _From, _State) ->
     {VHostGlobals, VHosts, Fun} = load_conf(),
     {reply, ok, #vhosts_state{
             vhost_globals=VHostGlobals,

Modified: couchdb/trunk/test/etap/160-vhosts.t
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/160-vhosts.t?rev=1075728&r1=1075727&r2=1075728&view=diff
==============================================================================
--- couchdb/trunk/test/etap/160-vhosts.t (original)
+++ couchdb/trunk/test/etap/160-vhosts.t Tue Mar  1 09:05:33 2011
@@ -111,13 +111,13 @@ test() ->
     ok = couch_config:set("vhosts", ":dbname.example1.com", "/:dbname", false),
     
     ok = couch_config:set("vhosts", "*.example2.com", "/*", false),
-    ok = couch_config:set("vhosts", "*/test", "/etap-test-db", false), 
     ok = couch_config:set("vhosts", "*.example2.com/test", "/*", false),
+    ok = couch_config:set("vhosts", "*/test", "/etap-test-db", false), 
     ok = couch_config:set("vhosts", "*/test1", 
             "/etap-test-db/_design/doc1/_show/test", false), 
 
-    % let couch_httpd restart
-    timer:sleep(100),
+    %% reload rules
+    couch_httpd_vhost:reload(),
 
     test_regular_request(),
     test_vhost_request(),



Mime
View raw message