From commits-return-6725-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Wed Aug 10 21:07:16 2011 Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B93D58A71 for ; Wed, 10 Aug 2011 21:07:16 +0000 (UTC) Received: (qmail 98295 invoked by uid 500); 10 Aug 2011 21:07:16 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 98224 invoked by uid 500); 10 Aug 2011 21:07:16 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 98217 invoked by uid 99); 10 Aug 2011 21:07:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Aug 2011 21:07:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Aug 2011 21:07:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id ED91023888CE for ; Wed, 10 Aug 2011 21:06:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1156369 - in /couchdb/branches/1.1.x: etc/couchdb/default.ini.tpl.in src/couchdb/couch_log.erl Date: Wed, 10 Aug 2011 21:06:50 -0000 To: commits@couchdb.apache.org From: rnewson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110810210650.ED91023888CE@eris.apache.org> 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,