From commits-return-6693-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Mon Jul 25 21:26:06 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 249686BD1 for ; Mon, 25 Jul 2011 21:26:06 +0000 (UTC) Received: (qmail 21275 invoked by uid 500); 25 Jul 2011 21:26:05 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 21201 invoked by uid 500); 25 Jul 2011 21:26:05 -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 21147 invoked by uid 99); 25 Jul 2011 21:26:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jul 2011 21:26:05 +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; Mon, 25 Jul 2011 21:26:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 88D192388A3C for ; Mon, 25 Jul 2011 21:25:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1150918 - in /couchdb/branches/1.1.x/src/couchdb: couch_db_updater.erl couch_file.erl couch_server_sup.erl Date: Mon, 25 Jul 2011 21:25:41 -0000 To: commits@couchdb.apache.org From: rnewson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110725212541.88D192388A3C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rnewson Date: Mon Jul 25 21:25:40 2011 New Revision: 1150918 URL: http://svn.apache.org/viewvc?rev=1150918&view=rev Log: assert that calls to file functions actually succeed. 1) couch_file:sync could leave open fd's if close failed. Now we'll get a trace. 2) couch_file:append_term failing would be bad, so let's test that too. backported from trunk r1150915 Modified: couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl couchdb/branches/1.1.x/src/couchdb/couch_file.erl couchdb/branches/1.1.x/src/couchdb/couch_server_sup.erl Modified: couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl?rev=1150918&r1=1150917&r2=1150918&view=diff ============================================================================== --- couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl (original) +++ couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl Mon Jul 25 21:25:40 2011 @@ -49,7 +49,7 @@ init({MainPid, DbName, Filepath, Fd, Opt terminate(_Reason, Db) -> - couch_file:close(Db#db.fd), + ok = couch_file:close(Db#db.fd), couch_util:shutdown_sync(Db#db.compactor_pid), couch_util:shutdown_sync(Db#db.fd_ref_counter), ok. @@ -484,9 +484,9 @@ flush_trees(#db{fd=Fd,header=Header}=Db, {ok, NewSummaryPointer} = case Header#db_header.disk_version < 4 of true -> - couch_file:append_term(Fd, {Doc#doc.body, DiskAtts}); + {ok, _} = couch_file:append_term(Fd, {Doc#doc.body, DiskAtts}); false -> - couch_file:append_term_md5(Fd, {Doc#doc.body, DiskAtts}) + {ok, _} = couch_file:append_term_md5(Fd, {Doc#doc.body, DiskAtts}) end, {IsDeleted, NewSummaryPointer, UpdateSeq}; _ -> Modified: couchdb/branches/1.1.x/src/couchdb/couch_file.erl URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_file.erl?rev=1150918&r1=1150917&r2=1150918&view=diff ============================================================================== --- couchdb/branches/1.1.x/src/couchdb/couch_file.erl (original) +++ couchdb/branches/1.1.x/src/couchdb/couch_file.erl Mon Jul 25 21:25:40 2011 @@ -164,7 +164,7 @@ truncate(Fd, Pos) -> sync(Filepath) when is_list(Filepath) -> {ok, Fd} = file:open(Filepath, [append, raw]), - try file:sync(Fd) after file:close(Fd) end; + try ok = file:sync(Fd) after ok = file:close(Fd) end; sync(Fd) -> gen_server:call(Fd, sync, infinity). Modified: couchdb/branches/1.1.x/src/couchdb/couch_server_sup.erl URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_server_sup.erl?rev=1150918&r1=1150917&r2=1150918&view=diff ============================================================================== --- couchdb/branches/1.1.x/src/couchdb/couch_server_sup.erl (original) +++ couchdb/branches/1.1.x/src/couchdb/couch_server_sup.erl Mon Jul 25 21:25:40 2011 @@ -135,7 +135,7 @@ start_server(IniFiles) -> undefined -> []; Uri -> io_lib:format("~s~n", [Uri]) end end || Uri <- Uris], - file:write_file(UriFile, Lines) + ok = file:write_file(UriFile, Lines) end, {ok, Pid}.