You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2008/07/31 14:56:50 UTC

svn commit: r681360 - in /incubator/couchdb/branches/runtimeconfig: ./ bin/ share/www/script/ src/couchdb/ src/mochiweb/

Author: jan
Date: Thu Jul 31 05:56:49 2008
New Revision: 681360

URL: http://svn.apache.org/viewvc?rev=681360&view=rev
Log:
Merged revisions 677373,677426,677682,677892,678743,678923,679636,679821,679823,679840,679843,679846,679850,680156,680420,680763,680765,680796 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/couchdb/trunk


Modified:
    incubator/couchdb/branches/runtimeconfig/   (props changed)
    incubator/couchdb/branches/runtimeconfig/CHANGES
    incubator/couchdb/branches/runtimeconfig/NEWS
    incubator/couchdb/branches/runtimeconfig/README
    incubator/couchdb/branches/runtimeconfig/THANKS
    incubator/couchdb/branches/runtimeconfig/bin/Makefile.am
    incubator/couchdb/branches/runtimeconfig/share/www/script/browse.js
    incubator/couchdb/branches/runtimeconfig/share/www/script/couch_tests.js
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_btree.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_db.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_doc.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_file.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_httpd.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_key_tree.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_rep.erl
    incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_view.erl
    incubator/couchdb/branches/runtimeconfig/src/mochiweb/mochiweb_response.erl

Propchange: incubator/couchdb/branches/runtimeconfig/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jul 31 05:56:49 2008
@@ -1 +1 @@
-/incubator/couchdb/trunk:1-677342
+/incubator/couchdb/trunk:1-681359

Modified: incubator/couchdb/branches/runtimeconfig/CHANGES
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/CHANGES?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/CHANGES (original)
+++ incubator/couchdb/branches/runtimeconfig/CHANGES Thu Jul 31 05:56:49 2008
@@ -1,6 +1,47 @@
 Apache CouchDB CHANGES
 ======================
 
+Version 0.8.1-incubating
+------------------------
+
+Database Core:
+
+ * Fix for replication problems where the write queues can get backed up if the
+   writes aren't happening fast enough to keep up with the reads. For a large
+   replication, this can exhaust memory and crash, or slow down the machine
+   dramatically. The fix keeps only one document in the write queue at a time.
+ * Fix for databases sometimes incorrectly reporting that they contain 0
+   documents after compaction.
+
+HTTP Interface:
+
+ * Fix for chunked responses where chunks were always being split into multiple
+   TCP packets, which caused problems with the test suite under Safari, and in
+   some other cases.
+ * Fix for an invalid JSON response body being returned for some kinds of
+   views. (COUCHDB-84)
+ * Fix for connections not getting closed after rejecting a chunked request.
+   (COUCHDB-55)
+ * CouchDB can now be bound to IPv6 addresses.
+ * The HTTP Server header now contains the versions of CouchDB and Erlang.
+
+Javascript View Server:
+
+ * Fix for sealing of nested data structure in documents in the Javascript view
+   server.
+ * Improve error handling for undefined values emitted by map functions.
+   (COUCHDB-83)
+
+Packaging and System Integration:
+
+ * The `couchdb` script no longer uses `awk` for configuration checks as this
+   was causing portability problems.
+
+Futon Utility Client:
+
+ * The view selector dropdown should now work in Opera and Internet Explorer
+   even when it includes optgroups for design documents. (COUCHDB-81)
+
 Version 0.8.0-incubating
 ------------------------
 

Modified: incubator/couchdb/branches/runtimeconfig/NEWS
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/NEWS?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/NEWS (original)
+++ incubator/couchdb/branches/runtimeconfig/NEWS Thu Jul 31 05:56:49 2008
@@ -10,6 +10,12 @@
 
 This release is still under development.
 
+Version 0.8.1-incubating
+------------------------
+
+ * Various bug fixes for replication, compaction, the HTTP interface and the
+   Javascript View Server.
+
 Version 0.8.0-incubating
 ------------------------
 

Modified: incubator/couchdb/branches/runtimeconfig/README
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/README?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/README (original)
+++ incubator/couchdb/branches/runtimeconfig/README Thu Jul 31 05:56:49 2008
@@ -53,9 +53,10 @@
 
  * [Erlang OTP][07] (>=R11B) (required)
  * [ICU][08] (required)
- * [Mozilla SpiderMonkey][09] (required)
- * [GNU Make][10] (required)
- * [GNU Compiler Collection][11] (required)
+ * [OpenSSL][09] (required)
+ * [Mozilla SpiderMonkey][10] (required)
+ * [GNU Make][11] (required)
+ * [GNU Compiler Collection][12] (required)
 
 ### UNIX-like Operating Systems (inc. OS X) ###
 
@@ -140,7 +141,7 @@
 
 OS X provides the standard Accounts option from the System Preferences
 application or you can optionally use the Workgroup Manager application which
-can be downloaded as part of the [Server Admin Tools][12].
+can be downloaded as part of the [Server Admin Tools][13].
 
 You should make sure that the `couchdb` user has a working POSIX shell and set
 the home directory to `/usr/local/var/lib/couchdb` which is the Apache CouchDB
@@ -167,7 +168,7 @@
 Relax.
 
 To check that everything has worked point your web browser to
-[http://localhost:5984/_utils/index.html][13] and run the test suite.
+[http://localhost:5984/_utils/index.html][14] and run the test suite.
 
 ##### OS X #####
 
@@ -250,8 +251,9 @@
 [06]: http://incubator.apache.org/couchdb/community/code.html
 [07]: http://erlang.org/
 [08]: http://icu.sourceforge.net/
-[09]: http://www.mozilla.org/js/spidermonkey/
-[10]: http://www.gnu.org/software/make/
-[11]: http://gcc.gnu.org/
-[12]: http://www.apple.com/support/downloads/serveradmintools1047.html
-[13]: http://localhost:5984/_utils/index.html
+[09]: http://www.openssl.org/
+[10]: http://www.mozilla.org/js/spidermonkey/
+[11]: http://www.gnu.org/software/make/
+[12]: http://gcc.gnu.org/
+[13]: http://www.apple.com/support/downloads/serveradmintools1047.html
+[14]: http://localhost:5984/_utils/index.html

Modified: incubator/couchdb/branches/runtimeconfig/THANKS
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/THANKS?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/THANKS (original)
+++ incubator/couchdb/branches/runtimeconfig/THANKS Thu Jul 31 05:56:49 2008
@@ -8,6 +8,7 @@
 
  * Chris Anderson <jc...@grabb.it>
  * William Beh <wi...@gmail.com>
+ * Yoan Blanc <yo...@gmail.com>
  * Benoit Chesneau <bc...@gmail.com>
  * Paul Joseph Davis <pa...@gmail.com>
  * Till Klampaeckel <ti...@klampaeckel.de>

Modified: incubator/couchdb/branches/runtimeconfig/bin/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/bin/Makefile.am?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/bin/Makefile.am (original)
+++ incubator/couchdb/branches/runtimeconfig/bin/Makefile.am Thu Jul 31 05:56:49 2008
@@ -25,7 +25,6 @@
 couchdb: couchdb.tpl
 	sed -e "s|%ERL%|$(ERL)|g" \
 	    -e "s|%ICU_CONFIG%|$(ICU_CONFIG)|g" \
-	    -e "s|%AWK%|$(AWK)|g" \
 	    -e "s|%bindir%|@bindir@|g" \
 	    -e "s|%localerlangbindir%|@localerlangbindir@|g" \
 	    -e "s|%localerlanglibdir%|@localerlanglibdir@|g" \

Modified: incubator/couchdb/branches/runtimeconfig/share/www/script/browse.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/share/www/script/browse.js?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/share/www/script/browse.js [utf-8] (original)
+++ incubator/couchdb/branches/runtimeconfig/share/www/script/browse.js [utf-8] Thu Jul 31 05:56:49 2008
@@ -178,9 +178,12 @@
           db.openDoc(resp.rows[i].id, {
             success: function(doc) {
               var optGroup = $("<optgroup></optgroup>").attr("label", doc._id.substr(8));
+              var optGroup = $(document.createElement("optgroup"))
+                .attr("label", doc._id.substr(8));
               for (var name in doc.views) {
                 if (!doc.views.hasOwnProperty(name)) continue;
-                var option = $("<option></option>").attr("value", doc._id + "/" + name).text(name)
+                var option = $(document.createElement("option"))
+                  .attr("value", doc._id + "/" + name).text(name)
                   .appendTo(optGroup);
                 if (doc._id + "/" + name == viewName) {
                   option[0].selected = true;

Modified: incubator/couchdb/branches/runtimeconfig/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/share/www/script/couch_tests.js?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/branches/runtimeconfig/share/www/script/couch_tests.js [utf-8] Thu Jul 31 05:56:49 2008
@@ -290,6 +290,12 @@
     result = db.query(map, reduce, {startkey: 4, endkey: 6});
     T(result.rows[0].value == 15);
 
+    result = db.query(map, reduce, {group:true, count:3});
+    T(result.rows.length == 3);
+    T(result.rows[0].value == 1);
+    T(result.rows[1].value == 2);
+    T(result.rows[2].value == 3);
+
     for(var i=1; i<numDocs/2; i+=30) {
       result = db.query(map, reduce, {startkey: i, endkey: numDocs - i});
       T(result.rows[0].value == summate(numDocs-i) - summate(i-1));
@@ -356,13 +362,13 @@
     db.createDb();
 
 
-    var map = function (doc) {emit(null, doc.val)};
+    var map = function (doc) {emit(doc.val, doc.val)};
     var reduceCombine = function (keys, values, rereduce) {
         // This computes the standard deviation of the mapped results
-        var stdDeviation=0;
+        var stdDeviation=0.0;
         var count=0;
-        var total=0;
-        var sqrTotal=0;
+        var total=0.0;
+        var sqrTotal=0.0;
 
         if (!rereduce) {
           // This is the reduce phase, we are reducing over emitted values from
@@ -379,7 +385,7 @@
           for(var i in values) {
             count = count + values[i].count;
             total = total + values[i].total;
-            sqrTotal = sqrTotal + (values[i].sqrTotal * values[i].sqrTotal);
+            sqrTotal = sqrTotal + values[i].sqrTotal;
           }
         }
 
@@ -393,27 +399,28 @@
       };
 
       // Save a bunch a docs.
-      for(var j=0; j < 10; j++) {
-        var docs = [];
-        docs.push({val:10});
-        docs.push({val:20});
-        docs.push({val:30});
-        docs.push({val:40});
-        docs.push({val:50});
-        docs.push({val:60});
-        docs.push({val:70});
-        docs.push({val:80});
-        docs.push({val:90});
-        docs.push({val:100});
-        T(db.bulkSave(docs).ok);
-      }
-
-      var results = db.query(map, reduceCombine);
-
-      var difference = results.rows[0].value.stdDeviation - 28.722813232690143;
-      // account for floating point rounding error
-      T(Math.abs(difference) < 0.0000000001);
 
+    for(var i=0; i < 10; i++) {
+      var docs = [];
+      docs.push({val:10});
+      docs.push({val:20});
+      docs.push({val:30});
+      docs.push({val:40});
+      docs.push({val:50});
+      docs.push({val:60});
+      docs.push({val:70});
+      docs.push({val:80});
+      docs.push({val:90});
+      docs.push({val:100});
+      T(db.bulkSave(docs).ok);
+    }
+    
+    var results = db.query(map, reduceCombine);
+    
+    var difference = results.rows[0].value.stdDeviation - 28.722813232690143;
+    // account for floating point rounding error
+    T(Math.abs(difference) < 0.0000000001);
+    
   },
 
   multiple_rows: function(debug) {
@@ -558,7 +565,25 @@
     var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
     T(xhr.responseText == "This is a base64 encoded text");
     T(xhr.getResponseHeader("Content-Type") == "text/plain");
-    
+
+
+    // empty attachment
+    var binAttDoc2 = {
+      _id: "bin_doc5",
+      _attachments:{
+        "foo.txt": {
+          content_type:"text/plain",
+          data: ""
+        }
+      }
+    }
+
+    T(db.save(binAttDoc2).ok);
+
+    var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc5/foo.txt");
+    T(xhr.responseText.length == 0);
+    T(xhr.getResponseHeader("Content-Type") == "text/plain");
+       
     // test RESTful doc API
     
     var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc2/foo2.txt", {
@@ -620,6 +645,30 @@
     
     var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev);
     T(xhr.status == 404);
+
+    // empty attachments
+    var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt", {
+      headers:{"Content-Type":"text/plain;charset=utf-8"},
+      body:""
+    });
+    T(xhr.status == 201);
+    var rev = JSON.parse(xhr.responseText).rev;
+
+    var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt");
+    T(xhr.status == 200);
+    T(xhr.responseText.length == 0);
+    
+    // overwrite previsously empty attachment
+    var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt?rev=" + rev, {
+      headers:{"Content-Type":"text/plain;charset=utf-8"},
+      body:"This is a string"
+    });
+    T(xhr.status == 201);
+
+    var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt");
+    T(xhr.status == 200);
+    T(xhr.responseText == "This is a string");
+    
   },
 
   content_negotiation: function(debug) {
@@ -1289,14 +1338,13 @@
     T(xhr.status == 202);
     // compaction isn't instantaneous, loop until done
     while (db.info().compact_running) {};
-
+    
+    restartServer();
     var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt");
     T(xhr.responseText == "This is a base64 encoded text")
     T(xhr.getResponseHeader("Content-Type") == "text/plain")
-
-    var compactedsize = db.info().disk_size;
-
-    T(compactedsize < deletesize);
+    T(db.info().doc_count == 1);
+    T(db.info().disk_size < deletesize);
   },
 
   runtime_config: function(debug) {

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_btree.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_btree.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_btree.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_btree.erl Thu Jul 31 05:56:49 2008
@@ -16,7 +16,7 @@
 -export([foldr/3, foldr/4, fold/4, fold/5, full_reduce/1, final_reduce/2]).
 -export([fold_reduce/7, lookup/2, get_state/1, set_options/2, test/1, test/0]).
 
--define(CHUNK_THRESHOLD, 16#fff).
+-define(CHUNK_THRESHOLD, 16#4ff).
 
 -record(btree,
     {fd,
@@ -78,17 +78,20 @@
         rev -> {EndKey, StartKey};
         fwd -> {StartKey, EndKey}
     end,
-    {ok, Acc2, GroupedRedsAcc2, GroupedKVsAcc2, GroupedKey2} =
-        reduce_stream_node(Bt, Dir, Root, StartKey2, EndKey2, nil, [], [],
-        KeyGroupFun, Fun, Acc),
-    if GroupedKey2 == nil ->
-        {ok, Acc2};
-    true ->
-        case (catch Fun(GroupedKey2, {GroupedKVsAcc2, GroupedRedsAcc2}, Acc2)) of
+    try
+        {ok, Acc2, GroupedRedsAcc2, GroupedKVsAcc2, GroupedKey2} =
+            reduce_stream_node(Bt, Dir, Root, StartKey2, EndKey2, nil, [], [],
+            KeyGroupFun, Fun, Acc),
+        if GroupedKey2 == nil ->
+            {ok, Acc2};
+        true ->
+            case Fun(GroupedKey2, {GroupedKVsAcc2, GroupedRedsAcc2}, Acc2) of
             {ok, Acc3} -> {ok, Acc3};
-            {stop, Acc3} -> {ok, Acc3};
-            Else -> throw(Else)
+            {stop, Acc3} -> {ok, Acc3}
+            end
         end
+    catch
+        throw:{stop, AccDone} -> {ok, AccDone}
     end.
 
 full_reduce(#btree{root=nil,reduce=Reduce}) ->

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_db.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_db.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_db.erl Thu Jul 31 05:56:49 2008
@@ -367,7 +367,7 @@
                     end,
                     {{0,0}, 0}),
                 {Fd, NewStreamPointer, Len};
-            Bin when is_binary(Bin), size(Bin) > 0 ->
+            Bin when is_binary(Bin) ->
                 {ok, StreamPointer} = couch_stream:write(OutputStream, Bin),
                 {Fd, StreamPointer, size(Bin)}
             end,
@@ -568,16 +568,17 @@
                 init_db(Name, CompactFilepath, NewFd, NewHeader),
         case Db#db.update_seq == NewSeq of
         true ->
+            NewDb2 = commit_data(
+                NewDb#db{
+                    main_pid = Db#db.main_pid,
+                    doc_count = Db#db.doc_count,
+                    doc_del_count = Db#db.doc_del_count,
+                    filepath = Filepath}),
+                
             ?LOG_DEBUG("CouchDB swapping files ~s and ~s.", [Filepath, CompactFilepath]),
             ok = file:rename(Filepath, Filepath ++ ".old"),
             ok = file:rename(CompactFilepath, Filepath),
             
-            NewDb2 = NewDb#db{
-                main_pid = Db#db.main_pid,
-                doc_count = Db#db.doc_count,
-                doc_del_count = Db#db.doc_del_count,
-                filepath = Filepath},
-            
             couch_stream:close(Db#db.summary_stream),
             % close file handle async.
             % wait 5 secs before closing, allowing readers to finish

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_doc.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_doc.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_doc.erl Thu Jul 31 05:56:49 2008
@@ -110,13 +110,18 @@
     Revs0 ->
         Revs0
     end,
-    #doc{
-        id = proplists:get_value("_id", Props, ""),
-        revs = Revs,
-        deleted = proplists:get_value("_deleted", Props, false),
-        body = {obj, [{Key, Value} || {[FirstChar|_]=Key, Value} <- Props, FirstChar /= $_]},
-        attachments = Bins
-        }.
+    case proplists:get_value("_id", Props, "") of
+    Id when is_list(Id) ->
+        #doc{
+            id = Id,
+            revs = Revs,
+            deleted = proplists:get_value("_deleted", Props, false),
+            body = {obj, [{Key, Value} || {[FirstChar|_]=Key, Value} <- Props, FirstChar /= $_]},
+            attachments = Bins
+            };
+    _ ->
+        throw({invalid_document_id, "Document id is not a string"})
+    end.
 
 
 to_doc_info(#full_doc_info{id=Id,update_seq=Seq,rev_tree=Tree}) ->

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_file.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_file.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_file.erl Thu Jul 31 05:56:49 2008
@@ -105,7 +105,7 @@
 %%----------------------------------------------------------------------
     
 append_binary(Fd, Bin) ->
-    gen_server:call(Fd, {append_bin, Bin}).
+    gen_server:call(Fd, {append_bin, Bin}, infinity).
 
 
 %%----------------------------------------------------------------------
@@ -127,7 +127,7 @@
 %%----------------------------------------------------------------------
 
 pread_binary(Fd, Pos) ->
-    gen_server:call(Fd, {pread_bin, Pos}).
+    gen_server:call(Fd, {pread_bin, Pos}, infinity).
 
 
 %%----------------------------------------------------------------------

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_httpd.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_httpd.erl Thu Jul 31 05:56:49 2008
@@ -485,7 +485,7 @@
         fun(_Key, _Red, {AccSeparator,AccSkip,AccCount}) when AccSkip > 0 ->
             {ok, {AccSeparator,AccSkip-1,AccCount}};
         (_Key, _Red, {AccSeparator,0,AccCount}) when AccCount == 0 ->
-            {ok, {AccSeparator,0,AccCount}};
+            {stop, {AccSeparator,0,AccCount}};
         (_Key, Red, {AccSeparator,0,AccCount}) when GroupLevel == 0 ->
             Json = lists:flatten(cjson:encode({obj, [{key, null}, {value, Red}]})),
             Resp:write_chunk(AccSeparator ++ Json),
@@ -1095,5 +1095,6 @@
     end.
 
 server_header() ->
+    OTPVersion = "R" ++ integer_to_list(erlang:system_info(compat_rel)) ++ "B",
     [{"Server", "CouchDB/" ++ couch_server:get_version() ++
-                " (Erlang OTP/" ++ erlang:system_info(otp_release) ++ ")"}].
+                " (Erlang OTP/" ++ OTPVersion ++ ")"}].

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_key_tree.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_key_tree.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_key_tree.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_key_tree.erl Thu Jul 31 05:56:49 2008
@@ -1,16 +1,14 @@
-%   Copyright 2007, 2008 Damien Katz <da...@yahoo.com>
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License.  You may obtain a copy of
+% the License at
 %
-%   Licensed under the Apache License, Version 2.0 (the "License");
-%   you may not use this file except in compliance with the License.
-%   You may obtain a copy of the License at
+%   http://www.apache.org/licenses/LICENSE-2.0
 %
-%       http://www.apache.org/licenses/LICENSE-2.0
-%
-%   Unless required by applicable law or agreed to in writing, software
-%   distributed under the License is distributed on an "AS IS" BASIS,
-%   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%   See the License for the specific language governing permissions and
-%   limitations under the License.
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+% License for the specific language governing permissions and limitations under
+% the License.
 
 -module(couch_key_tree).
 

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_rep.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_rep.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_rep.erl Thu Jul 31 05:56:49 2008
@@ -113,13 +113,15 @@
     end.
 
 pull_rep(DbTarget, DbSource, SourceSeqNum) ->
-    Parent = self(),
     SaveDocsPid = spawn_link(fun() ->
-            save_docs_loop(Parent, DbTarget, 0) end),
+            save_docs_loop(DbTarget, 0) end),
     OpenDocsPid = spawn_link(fun() ->
-            open_doc_revs_loop(Parent, DbSource, SaveDocsPid, 0) end),
+            open_doc_revs_loop(DbSource, SaveDocsPid, 0) end),
+    OpenDocsPid ! got_it, % prime queue with got_it
     MissingRevsPid = spawn_link(fun() ->
-            get_missing_revs_loop(Parent, DbTarget, OpenDocsPid, 0, 0) end),
+            get_missing_revs_loop(DbTarget, OpenDocsPid, 0, 0) end),
+    MissingRevsPid ! got_it, % prime queue with got_it
+    self() ! got_it,
     {ok, NewSeq} = enum_docs_since(DbSource, SourceSeqNum,
         fun(SrcDocInfo, _, _) ->
             #doc_info{id=Id,
@@ -128,73 +130,73 @@
                 deleted_conflict_revs=DelConflicts,
                 update_seq=Seq} = SrcDocInfo,
             SrcRevs = [Rev | Conflicts] ++ DelConflicts,
-            MissingRevsPid !  {Id, SrcRevs}, % send to the missing revs process
+            receive got_it -> ok end,
+            MissingRevsPid !  {self(), Id, SrcRevs}, % send to the missing revs process
             {ok, Seq}
         end, SourceSeqNum),
-    MissingRevsPid ! shutdown,
+    
+    receive got_it -> ok end,
+    
+    MissingRevsPid ! {self(), shutdown},
     receive {done, MissingRevsPid, Stats1} -> ok end,
     
-    OpenDocsPid ! shutdown,
+    OpenDocsPid ! {self(), shutdown},
     receive {done, OpenDocsPid, Stats2} -> ok end,
     
-    SaveDocsPid ! shutdown,
+    SaveDocsPid ! {self(), shutdown},
     receive {done, SaveDocsPid, Stats3} -> ok end,
     
     {NewSeq, Stats1 ++ Stats2 ++ Stats3}.
 
 
-receive_id_revs() ->
-    receive
-    {Id, Revs} ->
-        [{Id, Revs} | receive_id_revs()]
-    after 1 ->
-        []
-    end.
-
-get_missing_revs_loop(Parent, DbTarget, OpenDocsPid, RevsChecked, MissingFound) ->
+get_missing_revs_loop(DbTarget, OpenDocsPid, RevsChecked, MissingFound) ->
+    receive got_it -> ok end,
     receive
-    {Id, Revs} ->
-        Changed = [{Id, Revs} | receive_id_revs()],
-        {ok, Missing} = get_missing_revs(DbTarget, Changed),
-        [OpenDocsPid ! {Id0, MissingRevs} || {Id0, MissingRevs} <- Missing],
-        get_missing_revs_loop(Parent, DbTarget, OpenDocsPid,
-                RevsChecked + length(Changed),
-                MissingFound + length(Missing));
-    shutdown ->
-        Parent ! {done, self(), [{"missing_checked", RevsChecked},
+    {Src, Id, Revs} ->
+        Src ! got_it,
+        MissingRevs =
+        case get_missing_revs(DbTarget, [{Id, Revs}]) of
+        {ok, [{Id, MissingRevs0}]} ->
+            OpenDocsPid ! {self(), Id, MissingRevs0},
+            MissingRevs0;
+        {ok, []} ->
+            % prime our message queue
+            self() ! got_it,
+            []
+        end,
+        get_missing_revs_loop(DbTarget, OpenDocsPid,
+                RevsChecked + length(Revs),
+                MissingFound + length(MissingRevs));
+    {Src, shutdown} ->
+        Src ! {done, self(), [{"missing_checked", RevsChecked},
                                  {"missing_found", MissingFound}]}
     end.
     
 
-open_doc_revs_loop(Parent, DbSource, SaveDocsPid, DocsRead) ->
+open_doc_revs_loop(DbSource, SaveDocsPid, DocsRead) ->
+    receive got_it -> ok end,
     receive
-    {Id, MissingRevs} ->
+    {Src, Id, MissingRevs} ->
+        Src ! got_it,
         {ok, DocResults} = open_doc_revs(DbSource, Id, MissingRevs, [latest]),
         % only save successful reads
         Docs = [RevDoc || {ok, RevDoc} <- DocResults],
-        SaveDocsPid ! Docs,
-        open_doc_revs_loop(Parent, DbSource, SaveDocsPid, DocsRead + length(Docs));
-    shutdown ->
-        Parent ! {done, self(), [{"docs_read", DocsRead}]}
+        SaveDocsPid ! {self(), docs, Docs},
+        open_doc_revs_loop(DbSource, SaveDocsPid, DocsRead + length(Docs));
+    {Src, shutdown} ->
+        Src ! {done, self(), [{"docs_read", DocsRead}]}
     end.
 
 
-receive_docs() ->
-    receive
-    Docs when is_list(Docs) ->
-        Docs ++ receive_docs()
-    after 1 ->
-        []
-    end.
         
-save_docs_loop(Parent, DbTarget, DocsWritten) ->
+save_docs_loop(DbTarget, DocsWritten) ->
     receive
-    Docs0 when is_list(Docs0)  ->
-        Docs = Docs0 ++ receive_docs(),
+    {Src, docs, Docs} ->
+        Src ! got_it,
         ok = save_docs(DbTarget, Docs, []),
-        save_docs_loop(Parent, DbTarget, DocsWritten + length(Docs));
-    shutdown ->
-        Parent ! {done, self(), [{"docs_written", DocsWritten}]}
+        save_docs_loop(DbTarget, DocsWritten + length(Docs));
+    {Src, shutdown} ->
+        Src ! {done, self(), [{"docs_written", DocsWritten}]}
     end.
 
 
@@ -239,7 +241,7 @@
 
 
 enum_docs_since(DbUrl, StartSeq, InFun, InAcc) when is_list(DbUrl) ->
-    Url = DbUrl ++ "_all_docs_by_seq?startkey=" ++ integer_to_list(StartSeq),
+    Url = DbUrl ++ "_all_docs_by_seq?count=100&startkey=" ++ integer_to_list(StartSeq),
     {obj, Results} = do_http_request(Url, get),
     DocInfoList=
     lists:map(fun({obj, RowInfoList}) ->
@@ -254,7 +256,14 @@
                 tuple_to_list(proplists:get_value("deleted_conflicts", RowValueProps, {})),
             deleted = proplists:get_value("deleted", RowValueProps, false)}
         end, tuple_to_list(proplists:get_value("rows", Results))),
-    {ok, enum_docs0(InFun, DocInfoList, InAcc)};
+    case DocInfoList of
+    [] ->
+        {ok, InAcc};
+    _ ->
+        Acc2 = enum_docs0(InFun, DocInfoList, InAcc),
+        #doc_info{update_seq=LastSeq} = lists:last(DocInfoList),
+        enum_docs_since(DbUrl, LastSeq, InFun, Acc2)
+    end;
 enum_docs_since(DbSource, StartSeq, Fun, Acc) ->
     couch_db:enum_docs_since(DbSource, StartSeq, Fun, Acc).
 

Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_view.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_view.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_view.erl Thu Jul 31 05:56:49 2008
@@ -1,16 +1,14 @@
-%   Copyright 2007, 2008 Damien Katz <da...@yahoo.com>
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License.  You may obtain a copy of
+% the License at
 %
-%   Licensed under the Apache License, Version 2.0 (the "License");
-%   you may not use this file except in compliance with the License.
-%   You may obtain a copy of the License at
+%   http://www.apache.org/licenses/LICENSE-2.0
 %
-%       http://www.apache.org/licenses/LICENSE-2.0
-%
-%   Unless required by applicable law or agreed to in writing, software
-%   distributed under the License is distributed on an "AS IS" BASIS,
-%   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%   See the License for the specific language governing permissions and
-%   limitations under the License.
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+% License for the specific language governing permissions and limitations under
+% the License.
 
 -module(couch_view).
 -behaviour(gen_server).

Modified: incubator/couchdb/branches/runtimeconfig/src/mochiweb/mochiweb_response.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/mochiweb/mochiweb_response.erl?rev=681360&r1=681359&r2=681360&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/mochiweb/mochiweb_response.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/mochiweb/mochiweb_response.erl Thu Jul 31 05:56:49 2008
@@ -50,8 +50,7 @@
     case Request:get(version) of
         Version when Version >= {1, 1} ->
             Length = iolist_size(Data),
-            send(io_lib:format("~.16b\r\n", [Length])),
-            send([Data, <<"\r\n">>]);
+            send([io_lib:format("~.16b\r\n", [Length]), Data, <<"\r\n">>]);
         _ ->
             send(Data)
     end.