couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1156370 - in /couchdb/trunk: etc/couchdb/default.ini.tpl.in src/couchdb/couch_log.erl
Date Wed, 10 Aug 2011 21:07:05 GMT
Author: rnewson
Date: Wed Aug 10 21:07:04 2011
New Revision: 1156370

URL: http://svn.apache.org/viewvc?rev=1156370&view=rev
Log:
COUCHDB-1245 - enforce maximum chunk size for _log call to better manage memory.

Modified:
    couchdb/trunk/etc/couchdb/default.ini.tpl.in
    couchdb/trunk/src/couchdb/couch_log.erl

Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=1156370&r1=1156369&r2=1156370&view=diff
==============================================================================
--- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Wed Aug 10 21:07:04 2011
@@ -41,6 +41,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/trunk/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_log.erl?rev=1156370&r1=1156369&r2=1156370&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_log.erl (original)
+++ couchdb/trunk/src/couchdb/couch_log.erl Wed Aug 10 21:07:04 2011
@@ -165,6 +165,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,



Mime
View raw message