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:32 UTC

svn commit: r1156368 - in /couchdb/branches/1.0.x: etc/couchdb/default.ini.tpl.in src/couchdb/couch_log.erl

Author: rnewson
Date: Wed Aug 10 21:06:32 2011
New Revision: 1156368

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

Modified:
    couchdb/branches/1.0.x/etc/couchdb/default.ini.tpl.in
    couchdb/branches/1.0.x/src/couchdb/couch_log.erl

Modified: couchdb/branches/1.0.x/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/etc/couchdb/default.ini.tpl.in?rev=1156368&r1=1156367&r2=1156368&view=diff
==============================================================================
--- couchdb/branches/1.0.x/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/branches/1.0.x/etc/couchdb/default.ini.tpl.in Wed Aug 10 21:06:32 2011
@@ -22,6 +22,7 @@ default_handler = {couch_httpd_db, handl
 secure_rewrites = true
 vhost_global_handlers = _utils, _uuids, _session, _oauth, _users
 allow_jsonp = false
+log_max_chunk_size = 1000000
 
 [log]
 file = %localstatelogdir%/couch.log

Modified: couchdb/branches/1.0.x/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_log.erl?rev=1156368&r1=1156367&r2=1156368&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_log.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_log.erl Wed Aug 10 21:06:32 2011
@@ -140,6 +140,15 @@ log(Fd, Pid, Level, Format, Args) ->
 read(Bytes, Offset) ->
     LogFileName = couch_config:get("log", "file"),
     LogFileSize = couch_util:file_read_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,