couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r917102 - in /couchdb/trunk: THANKS share/www/script/test/show_documents.js src/couchdb/couch_httpd_show.erl src/couchdb/couch_rep_att.erl src/couchdb/couch_rep_changes_feed.erl
Date Sun, 28 Feb 2010 02:45:53 GMT
Author: jan
Date: Sun Feb 28 02:45:53 2010
New Revision: 917102

URL: http://svn.apache.org/viewvc?rev=917102&view=rev
Log:
revert accidental commit

Modified:
    couchdb/trunk/THANKS
    couchdb/trunk/share/www/script/test/show_documents.js
    couchdb/trunk/src/couchdb/couch_httpd_show.erl
    couchdb/trunk/src/couchdb/couch_rep_att.erl
    couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl

Modified: couchdb/trunk/THANKS
URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=917102&r1=917101&r2=917102&view=diff
==============================================================================
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Sun Feb 28 02:45:53 2010
@@ -50,5 +50,6 @@
  * Joel Clark <unsigned_char@yahoo.com>
  * Matt Lyon <matt@flowerpowered.com>
  * mikeal <mikeal.rogers@gmail.com>
+ * Randall Leeds <randall.leeds@gmail.com>
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/share/www/script/test/show_documents.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/show_documents.js?rev=917102&r1=917101&r2=917102&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/show_documents.js (original)
+++ couchdb/trunk/share/www/script/test/show_documents.js Sun Feb 28 02:45:53 2010
@@ -54,13 +54,6 @@
           json : req
         }
       }),
-      "show-deleted" : stringFun(function(doc, req) {
-        if(doc) {
-          return doc._id;
-        } else {
-          return "No doc " + req.id;
-        }
-      }),
       "render-error" : stringFun(function(doc, req) {
         return noSuchVariable;
       }),
@@ -400,15 +393,5 @@
   T(xhr.responseText == "Hey Dude");
   TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool");
   TEquals("Oh Yeah!", xhr.getResponseHeader("X-Couch-Test-Header-Awesome"), "header should
be cool");
-
-  // test deleted docs
-  var doc = {_id:"testdoc",foo:1};
-  db.save(doc);
-  var xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/show-deleted/testdoc");
-  TEquals("testdoc", xhr.responseText, "should return 'testdoc'");
-
-  db.deleteDoc(doc);
-  var xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/show-deleted/testdoc");
-  TEquals("No doc testdoc", xhr.responseText, "should return 'no doc testdoc'");
   
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_show.erl?rev=917102&r1=917101&r2=917102&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_show.erl Sun Feb 28 02:45:53 2010
@@ -31,7 +31,6 @@
 maybe_open_doc(Db, DocId) ->
     case catch couch_httpd_db:couch_doc_open(Db, DocId, nil, [conflicts]) of
         {not_found, missing} -> nil;
-        {not_found,deleted} -> nil;
         Doc -> Doc
     end.
 handle_doc_show_req(#httpd{

Modified: couchdb/trunk/src/couchdb/couch_rep_att.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_att.erl?rev=917102&r1=917101&r2=917102&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep_att.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_att.erl Sun Feb 28 02:45:53 2010
@@ -25,7 +25,11 @@
         qs = [{rev, couch_doc:rev_to_str({Pos,RevId})}]
     },
     Ref = make_ref(),
-    RcvFun = fun() -> attachment_receiver(Ref, Request) end,
+    RcvFun = fun() ->
+                 Bin = attachment_receiver(Ref, Request),
+                 cleanup(),
+                 Bin
+             end,
     Attachment#att{data=RcvFun}.
 
 cleanup() ->
@@ -34,6 +38,8 @@
         %% TODO maybe log, didn't expect to have data here
         cleanup();
     {ibrowse_async_response_end, _} -> 
+        cleanup();
+    {ibrowse_async_headers, _, _, _} ->
         cleanup()
     after 0 ->
         erase(),
@@ -43,13 +49,27 @@
 % internal funs
 
 attachment_receiver(Ref, Request) ->
-    case get(Ref) of
+    try case get(Ref) of
     undefined ->
         {ReqId, ContentEncoding} = start_http_request(Request),
         put(Ref, {ReqId, ContentEncoding}),
         receive_data(Ref, ReqId, ContentEncoding);
     {ReqId, ContentEncoding} ->
         receive_data(Ref, ReqId, ContentEncoding)
+    end
+    catch
+    throw:{attachment_request_failed, timeout} ->
+        case {Request#http_db.retries, Request#http_db.pause} of
+        {0, _} ->
+             ?LOG_INFO("request for ~p failed", [Request#http_db.resource]),
+             throw({attachment_request_failed, max_retries_reached});
+        {N, Pause} when N > 0 ->
+            ?LOG_INFO("request for ~p timed out, retrying in ~p seconds",
+                [Request#http_db.resource, Pause/1000]),
+            timer:sleep(Pause),
+            cleanup(),
+            attachment_receiver(Ref, Request#http_db{retries = N-1})
+        end
     end.
 
 receive_data(Ref, ReqId, ContentEncoding) ->
@@ -71,6 +91,8 @@
     {ibrowse_async_response_end, ReqId} ->
         ?LOG_ERROR("streaming att. ended but more data requested ~p", [ReqId]),
         throw({attachment_request_failed, premature_end})
+    after 31000 ->
+        throw({attachment_request_failed, timeout})
     end.
 
 start_http_request(Req) ->
@@ -84,6 +106,8 @@
         {ok, ContentEncoding, NewReqId} ->
             {NewReqId, ContentEncoding}
         end
+    after 10000 ->
+        throw({attachment_request_failed, timeout})
     end.
 
 validate_headers(_Req, 200, Headers) ->

Modified: couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl?rev=917102&r1=917101&r2=917102&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_changes_feed.erl Sun Feb 28 02:45:53 2010
@@ -83,8 +83,7 @@
         resource = "_changes",
         qs = QS,
         conn = Pid,
-        options = [{stream_to, {self(), once}}, {response_format, binary},
-            {inactivity_timeout, 31000}], % miss 3 heartbeats, assume death
+        options = [{stream_to, {self(), once}}, {response_format, binary}],
         headers = Source#http_db.headers -- [{"Accept-Encoding", "gzip"}]
     },
     {ibrowse_req_id, ReqId} = couch_rep_httpc:request(Req),
@@ -203,6 +202,9 @@
     ?LOG_ERROR("changes_loop died with reason ~p", [Reason]),
     {stop, changes_loop_died, State};
 
+handle_info({'EXIT', _From, normal}, State) ->
+    {noreply, State};
+
 handle_info(Msg, State) ->
     ?LOG_DEBUG("unexpected message at changes_feed ~p", [Msg]),
     {noreply, State}.



Mime
View raw message