couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1150925 - in /couchdb/branches/1.0.x/src/couchdb: couch_db_updater.erl couch_file.erl couch_server_sup.erl
Date Mon, 25 Jul 2011 21:36:15 GMT
Author: rnewson
Date: Mon Jul 25 21:36:14 2011
New Revision: 1150925

URL: http://svn.apache.org/viewvc?rev=1150925&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 1.1.x r1150918.

Modified:
    couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl
    couchdb/branches/1.0.x/src/couchdb/couch_file.erl
    couchdb/branches/1.0.x/src/couchdb/couch_server_sup.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl?rev=1150925&r1=1150924&r2=1150925&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl Mon Jul 25 21:36:14 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.
@@ -474,9 +474,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.0.x/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_file.erl?rev=1150925&r1=1150924&r2=1150925&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_file.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_file.erl Mon Jul 25 21:36:14 2011
@@ -161,7 +161,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.0.x/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_server_sup.erl?rev=1150925&r1=1150924&r2=1150925&view=diff
==============================================================================
--- couchdb/branches/1.0.x/src/couchdb/couch_server_sup.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_server_sup.erl Mon Jul 25 21:36:14 2011
@@ -127,7 +127,7 @@ start_server(IniFiles) ->
     null -> ok;
     UriFile ->
         Line = io_lib:format("http://~s:~w/~n", [Ip, Port]),
-        file:write_file(UriFile, Line)
+        ok = file:write_file(UriFile, Line)
     end,
 
     {ok, Pid}.



Mime
View raw message