couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r649988 - in /incubator/couchdb/trunk: bin/couchdb.tpl.in src/couchdb/couch.app.tpl.in src/couchdb/couch_erl_driver.c src/couchdb/couch_httpd.erl src/couchdb/couch_rep.erl src/couchdb/couch_server_sup.erl src/couchdb/couch_util.erl
Date Sun, 20 Apr 2008 22:27:17 GMT
Author: damien
Date: Sun Apr 20 15:27:11 2008
New Revision: 649988

URL: http://svn.apache.org/viewvc?rev=649988&view=rev
Log:
Change uuid generaion to rely on crypto. Started crypto and inets application in startscript,
and also couch_server_up. Fix for regression caused by accidental check-in of disabled etags.

Modified:
    incubator/couchdb/trunk/bin/couchdb.tpl.in
    incubator/couchdb/trunk/src/couchdb/couch.app.tpl.in
    incubator/couchdb/trunk/src/couchdb/couch_erl_driver.c
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
    incubator/couchdb/trunk/src/couchdb/couch_rep.erl
    incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl
    incubator/couchdb/trunk/src/couchdb/couch_util.erl

Modified: incubator/couchdb/trunk/bin/couchdb.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/bin/couchdb.tpl.in?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/bin/couchdb.tpl.in (original)
+++ incubator/couchdb/trunk/bin/couchdb.tpl.in Sun Apr 20 15:27:11 2008
@@ -224,7 +224,11 @@
         %ERL% $interactive_option -sasl errlog_type error \
         -pa %erlanglibdir%/couch-%version%/ebin \
             %erlanglibdir%/mochiweb-r64/ebin \
+        -eval \"application:load(inets)\" \
+        -eval \"application:load(crypto)\" \
         -eval \"application:load(couch)\" \
+        -eval \"crypto:start()\" \
+        -eval \"inets:start()\" \
         -eval \"couch_server:start(), receive done -> done end.\" \
         -couchini $INI_FILE"
     if test "$BACKGROUND_BOOLEAN" = "true" \

Modified: incubator/couchdb/trunk/src/couchdb/couch.app.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch.app.tpl.in?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch.app.tpl.in (original)
+++ incubator/couchdb/trunk/src/couchdb/couch.app.tpl.in Sun Apr 20 15:27:11 2008
@@ -25,4 +25,4 @@
                            couch_view,
                            couch_query_servers,
                            couch_ft_query]},
-              {applications,[kernel,stdlib,xmerl,inets,mochiweb]}]}.
+              {applications,[kernel,stdlib,crypto,inets,mochiweb]}]}.

Modified: incubator/couchdb/trunk/src/couchdb/couch_erl_driver.c
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_erl_driver.c?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_erl_driver.c (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_erl_driver.c Sun Apr 20 15:27:11 2008
@@ -23,7 +23,6 @@
 #ifndef WIN32
 #include <string.h> // for memcpy
 #endif
-#include <uuid/uuid.h>
 
 typedef struct {
     ErlDrvPort port;
@@ -91,21 +90,11 @@
 static int couch_drv_control(ErlDrvData drv_data, unsigned int command, const char *pBuf,
              int bufLen, char **rbuf, int rlen)
 {
-    #define COLLATE 0
-    #define COLLATE_NO_CASE 1
-    #define UUID 2
 
     couch_drv_data* pData = (couch_drv_data*)drv_data;
     switch(command) {
-    case UUID:
-        {
-        uuid_t uuid;
-        uuid_generate(uuid);
-        return return_control_result(&uuid, sizeof(uuid), rbuf, rlen);
-        }
-    
-    case COLLATE:
-    case COLLATE_NO_CASE:
+    case 0: // COLLATE
+    case 1: // COLLATE_NO_CASE:
         {
         UErrorCode status = U_ZERO_ERROR;
         int collResult;
@@ -134,9 +123,9 @@
         // point the iterator at it.
         uiter_setUTF8(&iterB, pBuf, length);
 
-        if (command == COLLATE)
+        if (command == 0) // COLLATE
           collResult = ucol_strcollIter(pData->coll, &iterA, &iterB, &status);
-        else if (command == COLLATE_NO_CASE)
+        else              // COLLATE_NO_CASE
           collResult = ucol_strcollIter(pData->collNoCase, &iterA, &iterB, &status);
 
         if (collResult < 0)

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Sun Apr 20 15:27:11 2008
@@ -437,7 +437,7 @@
                 JsonDoc = couch_doc:to_json_obj(Doc, Options),
                 AdditionalHeaders =
                     case Doc#doc.meta of
-                    [] -> [{"XEtag", Etag}]; % output etag when we have no meta
+                    [] -> [{"Etag", Etag}]; % output etag when we have no meta
                     _ -> []
                     end,
                 send_json(Req, 200, AdditionalHeaders, JsonDoc);
@@ -504,7 +504,7 @@
     Doc = couch_doc:from_json_obj(Json),
 
     {ok, NewRev} = couch_db:update_doc(Db, Doc#doc{id=DocId, revs=Revs}, []),
-    send_json(Req, 201, [{"XEtag", "\"" ++ NewRev ++ "\""}], {obj, [
+    send_json(Req, 201, [{"Etag", "\"" ++ NewRev ++ "\""}], {obj, [
         {ok, true},
         {id, DocId},
         {rev, NewRev}
@@ -797,9 +797,9 @@
 send_error(Req, {method_not_allowed, Methods}) ->
     {ok, Req:respond({405, [{"Allow", Methods}], <<>>})};
 send_error(Req, {modified, Etag}) ->
-    {ok, Req:respond({412, [{"XEtag", Etag}], <<>>})};
+    {ok, Req:respond({412, [{"Etag", Etag}], <<>>})};
 send_error(Req, {not_modified, Etag}) ->
-    {ok, Req:respond({304, [{"XEtag", Etag}], <<>>})};
+    {ok, Req:respond({304, [{"Etag", Etag}], <<>>})};
 send_error(Req, Error) ->
     {Code, Json} = error_to_json(Error),
     ?LOG_INFO("HTTP Error (code ~w): ~p", [Code, Error]),

Modified: incubator/couchdb/trunk/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_rep.erl?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_rep.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_rep.erl Sun Apr 20 15:27:11 2008
@@ -155,14 +155,6 @@
     ?LOG_DEBUG("\tAction: ~p", [Action]),
     ?LOG_DEBUG("\tUrl: ~p", [Url]),
 
-    % ensure that the inets application is running
-    case application:start(inets) of
-        ok ->
-            ok;
-        {error, {already_started, inets}} ->
-            ok
-    end,
-
     Request =
     case JsonBody of
     [] ->

Modified: incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl Sun Apr 20 15:27:11 2008
@@ -145,6 +145,11 @@
 
     io:format("couch ~s (LogLevel=~s)~n", [couch_server:get_version(), LogLevel]),
     io:format("~s~n", [ConsoleStartupMsg]),
+    
+    
+    % ensure these applications are running
+    application:start(inets),
+    application:start(crypto),
 
     process_flag(trap_exit, true),
     StartResult = (catch supervisor:start_link(

Modified: incubator/couchdb/trunk/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_util.erl?rev=649988&r1=649987&r2=649988&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_util.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_util.erl Sun Apr 20 15:27:11 2008
@@ -40,7 +40,7 @@
 
 
 new_uuid() ->
-    to_hex(erlang:port_control(drv_port(), 2, <<>>)).
+    to_hex(binary_to_list(crypto:rand_bytes(16))).
 
 to_hex([]) ->
     [];
@@ -57,8 +57,7 @@
 
 % returns a random integer
 rand32() ->
-    [A,B,C,D|_] = erlang:port_control(drv_port(), 2, <<>>),
-    (A bsl 24) + (B bsl 16) + (C bsl 8) + D.
+    crypto:rand_uniform(0, 16#100000000).
 
 % given a pathname "../foo/bar/" it gives back the fully qualified
 % absolute pathname.



Mime
View raw message