summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/couchdb/default.ini.tpl.in4
-rw-r--r--src/couchdb/couch_db.hrl8
-rw-r--r--src/couchdb/couch_rep_httpc.erl14
-rw-r--r--src/couchdb/couch_rep_reader.erl8
4 files changed, 17 insertions, 17 deletions
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index ef5e4fba..13e0eee7 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -135,8 +135,8 @@ compressible_types = text/*, application/javascript, application/json, applicat
[replicator]
db = _replicator
-max_http_sessions = 10
-max_http_pipeline_size = 10
+max_http_sessions = 20
+max_http_pipeline_size = 50
; set to true to validate peer certificates
verify_ssl_certificates = false
; file containing a list of peer trusted certificates (PEM format)
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl
index 74d2c630..6e205ec1 100644
--- a/src/couchdb/couch_db.hrl
+++ b/src/couchdb/couch_db.hrl
@@ -268,13 +268,7 @@
body = nil,
options = [
{response_format,binary},
- {inactivity_timeout, 30000},
- {max_sessions, list_to_integer(
- couch_config:get("replicator", "max_http_sessions", "10")
- )},
- {max_pipeline_size, list_to_integer(
- couch_config:get("replicator", "max_http_pipeline_size", "10")
- )}
+ {inactivity_timeout, 30000}
],
retries = 10,
pause = 500,
diff --git a/src/couchdb/couch_rep_httpc.erl b/src/couchdb/couch_rep_httpc.erl
index 7a5bd18b..cfd815b4 100644
--- a/src/couchdb/couch_rep_httpc.erl
+++ b/src/couchdb/couch_rep_httpc.erl
@@ -93,6 +93,7 @@ db_exists(Req, CanonicalUrl, CreateDB) ->
end,
case catch ibrowse:send_req(Url, HeadersFun(head), head, [], Options) of
{ok, "200", _, _} ->
+ config_http(CanonicalUrl),
Req#http_db{url = CanonicalUrl};
{ok, "301", RespHeaders, _} ->
RedirectUrl = redirect_url(RespHeaders, Req#http_db.url),
@@ -110,6 +111,19 @@ db_exists(Req, CanonicalUrl, CreateDB) ->
throw({db_not_found, ?l2b(Url)})
end.
+config_http(Url) ->
+ #url{host = Host, port = Port} = ibrowse_lib:parse_url(Url),
+ ok = ibrowse:set_max_sessions(Host, Port, list_to_integer(
+ couch_config:get("replicator", "max_http_sessions", "20"))),
+ ok = ibrowse:set_max_pipeline_size(Host, Port, list_to_integer(
+ couch_config:get("replicator", "max_http_pipeline_size", "50"))),
+ ok = couch_config:register(
+ fun("replicator", "max_http_sessions", MaxSessions) ->
+ ibrowse:set_max_sessions(Host, Port, list_to_integer(MaxSessions));
+ ("replicator", "max_http_pipeline_size", PipeSize) ->
+ ibrowse:set_max_pipeline_size(Host, Port, list_to_integer(PipeSize))
+ end).
+
redirect_url(RespHeaders, OrigUrl) ->
MochiHeaders = mochiweb_headers:make(RespHeaders),
RedUrl = mochiweb_headers:get_value("Location", MochiHeaders),
diff --git a/src/couchdb/couch_rep_reader.erl b/src/couchdb/couch_rep_reader.erl
index 9252bc8c..1bd3e171 100644
--- a/src/couchdb/couch_rep_reader.erl
+++ b/src/couchdb/couch_rep_reader.erl
@@ -21,11 +21,8 @@
-define (BUFFER_SIZE, 1000).
-define (MAX_CONCURRENT_REQUESTS, 100).
--define (MAX_CONNECTIONS, 20).
--define (MAX_PIPELINE_SIZE, 50).
-include("couch_db.hrl").
--include("../ibrowse/ibrowse.hrl").
-record (state, {
parent,
@@ -51,11 +48,6 @@ next(Pid) ->
init([Parent, Source, MissingRevs, _PostProps]) ->
process_flag(trap_exit, true),
- if is_record(Source, http_db) ->
- #url{host=Host, port=Port} = ibrowse_lib:parse_url(Source#http_db.url),
- ibrowse:set_max_sessions(Host, Port, ?MAX_CONNECTIONS),
- ibrowse:set_max_pipeline_size(Host, Port, ?MAX_PIPELINE_SIZE);
- true -> ok end,
Self = self(),
ReaderLoop = spawn_link(
fun() -> reader_loop(Self, Parent, Source, MissingRevs) end),