summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2011-08-10 21:06:50 +0000
committerRobert Newson <rnewson@apache.org>2011-08-10 21:06:50 +0000
commit0ac7f70c85f3be8fc65d814473b9a5a5a0aed0f7 (patch)
tree60c047443e1499aad8ee84bf9195eb0deca8f26b /src/couchdb
parentb2db4f11376472fa801c58f98dcc2e356783e276 (diff)
COUCHDB-1245 - enforce maximum chunk size for _log call to better manage memory.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1156369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_log.erl9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index bb75f161..ab649cac 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -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,