cloudant/couch_replicator — pull request #43 by banjiewen (2013-11-14 02:39:04+00:00)
Title: Catch/re-throw recurse exceptions and clean up http message queues

When couch_replicator_changes_reader:process_change/2 throws in order to
recurse back in to another _changes request, the control flow passes
down the stack past couch_replicator_httpc:process_stream_response/5.
Unless we catch `throw:recurse` on the way down, the process will
be prevented from cleaning any remaining "end of stream" messages out
of its mailbox for the ReqId in process.

I've also added some additional calls to `clean_mailbox_req` for error cases;
I haven't observed them causing issues in production, but I can't see why it
isn't necessary.