couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1031884 - in /couchdb/trunk: src/couchdb/couch_os_daemons.erl test/etap/171-os-daemons-config.es
Date Fri, 05 Nov 2010 23:59:14 GMT
Author: davisp
Date: Fri Nov  5 23:59:14 2010
New Revision: 1031884

URL: http://svn.apache.org/viewvc?rev=1031884&view=rev
Log:
Don't choke on unknown configuration settings.


Modified:
    couchdb/trunk/src/couchdb/couch_os_daemons.erl
    couchdb/trunk/test/etap/171-os-daemons-config.es

Modified: couchdb/trunk/src/couchdb/couch_os_daemons.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_os_daemons.erl?rev=1031884&r1=1031883&r2=1031884&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_os_daemons.erl (original)
+++ couchdb/trunk/src/couchdb/couch_os_daemons.erl Fri Nov  5 23:59:14 2010
@@ -210,12 +210,16 @@ stop_port(#daemon{port=Port}=D) ->
 handle_port_message(#daemon{port=Port}=Daemon, [<<"get">>, Section]) ->
     KVs = couch_config:get(Section),
     Data = lists:map(fun({K, V}) -> {?l2b(K), ?l2b(V)} end, KVs),
-    JsonData = ?JSON_ENCODE({Data}),
-    port_command(Port, JsonData ++ "\n"),
+    Json = iolist_to_binary(?JSON_ENCODE({Data})),
+    port_command(Port, <<Json/binary, "\n">>),
     {ok, Daemon};
 handle_port_message(#daemon{port=Port}=Daemon, [<<"get">>, Section, Key]) ->
-    Value = couch_config:get(Section, Key, null),
-    port_command(Port, ?JSON_ENCODE(?l2b(Value)) ++ "\n"),
+    Value = case couch_config:get(Section, Key, null) of
+        null -> null;
+        String -> ?l2b(String)
+    end,
+    Json = iolist_to_binary(?JSON_ENCODE(Value)),
+    port_command(Port, <<Json/binary, "\n">>),
     {ok, Daemon};
 handle_port_message(Daemon, [<<"register">>, Sec]) when is_binary(Sec) ->
     Patterns = lists:usort(Daemon#daemon.cfg_patterns ++ [{?b2l(Sec)}]),

Modified: couchdb/trunk/test/etap/171-os-daemons-config.es
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/etap/171-os-daemons-config.es?rev=1031884&r1=1031883&r2=1031884&view=diff
==============================================================================
--- couchdb/trunk/test/etap/171-os-daemons-config.es (original)
+++ couchdb/trunk/test/etap/171-os-daemons-config.es Fri Nov  5 23:59:14 2010
@@ -50,6 +50,10 @@ test_get_cfg2() ->
     FileName = get_cfg(<<"os_daemons">>, <<"foo">>),
     <<"sequential">> = get_cfg(<<"uuids">>, <<"algorithm">>).
 
+test_get_unknown_cfg() ->
+    {[]} = get_cfg(<<"aal;3p4">>),
+    null = get_cfg(<<"aal;3p4">>, <<"313234kjhsdfl">>).
+
 test_log() ->
     log(<<"foobar!">>),
     log(<<"some stuff!">>, <<"debug">>),
@@ -63,6 +67,7 @@ test_log() ->
 do_tests() ->
     test_get_cfg1(),
     test_get_cfg2(),
+    test_get_unknown_cfg(),
     test_log(),
     loop(io:read("")).
 



Mime
View raw message