summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2017-04-25 14:13:13 -0700
committerILYA Khlopotov <iilyak@apache.org>2017-04-25 14:13:13 -0700
commite1e16367276c9eb2e1b888c724d7afc503c527ef (patch)
tree4eeecf7fd65bed3ca9e896b9623e4e63ed12db34
parente5550fbd9ad3ee97cd90b01bd8162e38bd3f9299 (diff)
downloadcouchdb-e1e16367276c9eb2e1b888c724d7afc503c527ef.tar.gz
Revert "fix compiler and dialyzer warnings"
This reverts commit 2d984b59ed6886a179fd500efe9780a0d0ad62e3.
-rw-r--r--src/couch/src/couch_server.erl28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index 115230029..1272e7aa3 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/src/couch_server.erl
@@ -359,7 +359,7 @@ handle_call({open_result, _T0, DbName, Error}, {FromPid, _Tag}, Server) ->
[] ->
% db was deleted during async open
{reply, ok, Server};
- [#db{fd=ReqType, compactor_pid=Froms}] ->
+ [#db{fd=ReqType, compactor_pid=Froms}=Db] ->
[gen_server:reply(From, Error) || From <- Froms],
couch_log:info("open_result error ~p for ~s", [Error, DbName]),
true = ets:delete(couch_dbs, DbName),
@@ -378,9 +378,13 @@ handle_call({open, DbName, Options}, From, Server) ->
DbNameList = binary_to_list(DbName),
case check_dbname(Server, DbNameList) of
ok ->
- {ok, Server2} = maybe_close_lru_db(Server),
- Filepath = get_full_filename(Server, DbNameList),
- {noreply, open_async(Server2, From, DbName, Filepath, Options)};
+ case maybe_close_lru_db(Server) of
+ {ok, Server2} ->
+ Filepath = get_full_filename(Server, DbNameList),
+ {noreply, open_async(Server2, From, DbName, Filepath, Options)};
+ CloseError ->
+ {reply, CloseError, Server}
+ end;
Error ->
{reply, Error, Server}
end;
@@ -402,9 +406,13 @@ handle_call({create, DbName, Options}, From, Server) ->
ok ->
case ets:lookup(couch_dbs, DbName) of
[] ->
- {ok, Server2} = maybe_close_lru_db(Server),
- {noreply, open_async(Server2, From, DbName, Filepath,
- [create | Options])};
+ case maybe_close_lru_db(Server) of
+ {ok, Server2} ->
+ {noreply, open_async(Server2, From, DbName, Filepath,
+ [create | Options])};
+ CloseError ->
+ {reply, CloseError, Server}
+ end;
[#db{fd=open}=Db] ->
% We're trying to create a database while someone is in
% the middle of trying to open it. We allow one creator
@@ -428,14 +436,14 @@ handle_call({delete, DbName, Options}, _From, Server) ->
Server2 =
case ets:lookup(couch_dbs, DbName) of
[] -> Server;
- [#db{main_pid=Pid, compactor_pid=Froms}] when is_list(Froms) ->
+ [#db{main_pid=Pid, compactor_pid=Froms} = Db] when is_list(Froms) ->
% icky hack of field values - compactor_pid used to store clients
true = ets:delete(couch_dbs, DbName),
true = ets:delete(couch_dbs_pid_to_name, Pid),
exit(Pid, kill),
[gen_server:reply(F, not_found) || F <- Froms],
db_closed(Server);
- [#db{main_pid=Pid}] ->
+ [#db{main_pid=Pid} = Db] ->
true = ets:delete(couch_dbs, DbName),
true = ets:delete(couch_dbs_pid_to_name, Pid),
exit(Pid, kill),
@@ -494,7 +502,7 @@ handle_info({'EXIT', _Pid, config_change}, Server) ->
handle_info({'EXIT', Pid, Reason}, Server) ->
case ets:lookup(couch_dbs_pid_to_name, Pid) of
[{Pid, DbName}] ->
- [#db{compactor_pid=Froms}] = ets:lookup(couch_dbs, DbName),
+ [#db{compactor_pid=Froms}=Db] = ets:lookup(couch_dbs, DbName),
if Reason /= snappy_nif_not_loaded -> ok; true ->
Msg = io_lib:format("To open the database `~s`, Apache CouchDB "
"must be built with Erlang OTP R13B04 or higher.", [DbName]),