Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
COUCHDB-1245 - enforce maximum chunk size for _log call to better man…
Browse files Browse the repository at this point in the history
…age memory.

git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1156369 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rnewson committed Aug 10, 2011
1 parent b2db4f1 commit 0ac7f70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions etc/couchdb/default.ini.tpl.in
Expand Up @@ -24,6 +24,7 @@ allow_jsonp = false
;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
; For more socket options, consult Erlang's module 'inet' man page.
;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
log_max_chunk_size = 1000000

[ssl]
port = 6984
Expand Down
9 changes: 9 additions & 0 deletions src/couchdb/couch_log.erl
Expand Up @@ -172,6 +172,15 @@ get_log_messages(Pid, Level, Format, Args) ->
read(Bytes, Offset) ->
LogFileName = couch_config:get("log", "file"),
LogFileSize = filelib:file_size(LogFileName),
MaxChunkSize = list_to_integer(
couch_config:get("httpd", "log_max_chunk_size", "1000000")),
case Bytes > MaxChunkSize of
true ->
throw({bad_request, "'bytes' cannot exceed " ++
integer_to_list(MaxChunkSize)});
false ->
ok
end,

{ok, Fd} = file:open(LogFileName, [read]),
Start = lists:max([LogFileSize - Bytes, 0]) + Offset,
Expand Down

0 comments on commit 0ac7f70

Please sign in to comment.