You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2011/08/10 23:06:50 UTC
svn commit: r1156369 - in /couchdb/branches/1.1.x:
etc/couchdb/default.ini.tpl.in src/couchdb/couch_log.erl
Author: rnewson
Date: Wed Aug 10 21:06:50 2011
New Revision: 1156369
URL: http://svn.apache.org/viewvc?rev=1156369&view=rev
Log:
COUCHDB-1245 - enforce maximum chunk size for _log call to better manage memory.
Modified:
couchdb/branches/1.1.x/etc/couchdb/default.ini.tpl.in
couchdb/branches/1.1.x/src/couchdb/couch_log.erl
Modified: couchdb/branches/1.1.x/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/etc/couchdb/default.ini.tpl.in?rev=1156369&r1=1156368&r2=1156369&view=diff
==============================================================================
--- couchdb/branches/1.1.x/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/branches/1.1.x/etc/couchdb/default.ini.tpl.in Wed Aug 10 21:06:50 2011
@@ -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
Modified: couchdb/branches/1.1.x/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_log.erl?rev=1156369&r1=1156368&r2=1156369&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_log.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_log.erl Wed Aug 10 21:06:50 2011
@@ -172,6 +172,15 @@ get_log_messages(Pid, Level, Format, Arg
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,