Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
assert that calls to file functions actually succeed.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rnewson authored and kocolosk committed Aug 13, 2011
1 parent a563a53 commit c78b192
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/couch/src/couch_db_updater.erl
Expand Up @@ -52,7 +52,7 @@ init({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),
ok.
Expand Down Expand Up @@ -513,9 +513,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,
#leaf{
deleted = IsDeleted,
Expand Down
2 changes: 1 addition & 1 deletion apps/couch/src/couch_file.erl
Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion apps/couch/src/couch_server_sup.erl
Expand Up @@ -120,7 +120,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}.
Expand Down

0 comments on commit c78b192

Please sign in to comment.