Skip to content

Commit

Permalink
Merged revision 1052227 from trunk:
Browse files Browse the repository at this point in the history
Fix: replicator didn't use the HTTP settings defined in the .ini config

Issue found by Randall Leeds. Thanks. 
Closes COUCHDB-992



git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@1052228 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
fdmanana committed Dec 23, 2010
1 parent 7b10d89 commit 3c69bd3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions etc/couchdb/default.ini.tpl.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ compression_level = 8 ; from 1 (lowest, fastest) to 9 (highest, slowest), 0 to d
compressible_types = text/*, application/javascript, application/json, application/xml

[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)
Expand Down
8 changes: 1 addition & 7 deletions src/couchdb/couch_db.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,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,
Expand Down
14 changes: 14 additions & 0 deletions src/couchdb/couch_rep_httpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,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),
Expand All @@ -106,6 +107,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),
Expand Down
8 changes: 0 additions & 8 deletions src/couchdb/couch_rep_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -53,11 +50,6 @@ next(Pid) ->

init([Parent, Source, MissingRevs_or_DocIds, _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_or_DocIds) end
Expand Down

0 comments on commit 3c69bd3

Please sign in to comment.