summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2011-07-25 21:25:40 +0000
committerRobert Newson <rnewson@apache.org>2011-07-25 21:25:40 +0000
commit9e4abecfc2d26dc9ec109c24d97ee03c111e1d30 (patch)
tree879f533c127564fea3549a46c9b3424936937329 /src
parent8d53b7d926c9169c914f6421e681842529d9ac3f (diff)
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 git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1150918 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_db_updater.erl6
-rw-r--r--src/couchdb/couch_file.erl2
-rw-r--r--src/couchdb/couch_server_sup.erl2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index 2b317d95..714a337f 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -49,7 +49,7 @@ init({MainPid, DbName, Filepath, Fd, Options}) ->
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};
_ ->
diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl
index 7b677034..07ec18dc 100644
--- a/src/couchdb/couch_file.erl
+++ b/src/couchdb/couch_file.erl
@@ -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).
diff --git a/src/couchdb/couch_server_sup.erl b/src/couchdb/couch_server_sup.erl
index fafd83ed..dd210381 100644
--- a/src/couchdb/couch_server_sup.erl
+++ b/src/couchdb/couch_server_sup.erl
@@ -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}.