couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
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 GMT
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}.



Mime
View raw message