summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/www/script/test/basics.js8
-rw-r--r--share/www/script/test/stats.js6
-rw-r--r--src/couchdb/couch_db.erl3
-rw-r--r--src/couchdb/couch_db_updater.erl4
-rw-r--r--src/couchdb/couch_file.erl6
-rw-r--r--src/couchdb/couch_ref_counter.erl3
-rw-r--r--src/couchdb/couch_server.erl3
-rw-r--r--src/couchdb/couch_util.erl10
-rw-r--r--src/couchdb/couch_view.erl4
-rw-r--r--src/couchdb/couch_view_group.erl1
10 files changed, 33 insertions, 15 deletions
diff --git a/share/www/script/test/basics.js b/share/www/script/test/basics.js
index 4571200e..8adf5a84 100644
--- a/share/www/script/test/basics.js
+++ b/share/www/script/test/basics.js
@@ -29,10 +29,10 @@ couchTests.basics = function(debug) {
if (debug) debugger;
// creating a new DB should return Location header
- xhr = CouchDB.request("DELETE", "/new-db");
- xhr = CouchDB.request("PUT", "/new-db");
- TEquals("/new-db",
- xhr.getResponseHeader("Location").substr(-7),
+ xhr = CouchDB.request("DELETE", "/test_suite_db");
+ xhr = CouchDB.request("PUT", "/test_suite_db");
+ TEquals("/test_suite_db",
+ xhr.getResponseHeader("Location").substr(-14),
"should return Location header to newly created document");
TEquals("http://",
diff --git a/share/www/script/test/stats.js b/share/www/script/test/stats.js
index 267a48ef..dc3edb1f 100644
--- a/share/www/script/test/stats.js
+++ b/share/www/script/test/stats.js
@@ -56,7 +56,8 @@ couchTests.stats = function(debug) {
value: max.toString()}],
function () {
- var files_open = requestStatsTest("couchdb", "open_databases").current;
+ var dbs_open = requestStatsTest("couchdb", "open_databases").current;
+ var files_open = requestStatsTest("couchdb", "open_os_files").current;
for(var i=0; i<max+1; i++) {
var db = new CouchDB("test_suite_db" + i);
db.deleteDb();
@@ -70,7 +71,8 @@ couchTests.stats = function(debug) {
var db = new CouchDB("test_suite_db" + i);
db.deleteDb();
}
- T(files_open == requestStatsTest("couchdb", "open_databases").current);
+ T(dbs_open == requestStatsTest("couchdb", "open_databases").current);
+ T(files_open == requestStatsTest("couchdb", "open_os_files").current);
})
},
};
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 18cb98ee..e7df2f25 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -677,7 +677,8 @@ init({DbName, Filepath, Fd, Options}) ->
couch_ref_counter:add(RefCntr),
{ok, Db}.
-terminate(_Reason, _Db) ->
+terminate(Reason, _Db) ->
+ couch_util:terminate_linked(Reason),
ok.
handle_call({open_ref_count, OpenerPid}, _, #db{fd_ref_counter=RefCntr}=Db) ->
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index 969a79d4..ba9be1e4 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -37,7 +37,9 @@ init({MainPid, DbName, Filepath, Fd, Options}) ->
Db2 = refresh_validate_doc_funs(Db),
{ok, Db2#db{main_pid=MainPid}}.
-terminate(_Reason, _Db) ->
+
+terminate(Reason, _Srv) ->
+ couch_util:terminate_linked(Reason),
ok.
handle_call(get_db, _From, Db) ->
diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl
index 900e369a..b9da5488 100644
--- a/src/couchdb/couch_file.erl
+++ b/src/couchdb/couch_file.erl
@@ -311,7 +311,7 @@ init({Filepath, Options, ReturnPid, Ref}) ->
end.
-terminate(_Reason, _Fd) ->
+terminate(_Reason, _Fd) ->
ok.
track_stats() ->
@@ -359,5 +359,5 @@ handle_cast(close, Fd) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
-handle_info(foo, _Fd) ->
- ok.
+handle_info({'EXIT', _, Reason}, Fd) ->
+ {stop, Reason, Fd}.
diff --git a/src/couchdb/couch_ref_counter.erl b/src/couchdb/couch_ref_counter.erl
index 95093f72..4c824aa6 100644
--- a/src/couchdb/couch_ref_counter.erl
+++ b/src/couchdb/couch_ref_counter.erl
@@ -49,7 +49,8 @@ init({Pid, ChildProcs}) ->
{ok, #srv{referrers=Referrers}}.
-terminate(_Reason, _Srv) ->
+terminate(Reason, _Srv) ->
+ couch_util:terminate_linked(Reason),
ok.
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 164af094..870d0d76 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -159,7 +159,8 @@ init([]) ->
max_dbs_open=MaxDbsOpen,
start_time=httpd_util:rfc1123_date()}}.
-terminate(_Reason, _Server) ->
+terminate(Reason, _Srv) ->
+ couch_util:terminate_linked(Reason),
ok.
all_databases() ->
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index bd377d80..a119cf1c 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -12,7 +12,7 @@
-module(couch_util).
--export([start_driver/1]).
+-export([start_driver/1,terminate_linked/1]).
-export([should_flush/0, should_flush/1, to_existing_atom/1, to_binary/1]).
-export([new_uuid/0, rand32/0, implode/2, collate/2, collate/3]).
-export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]).
@@ -43,6 +43,14 @@ to_existing_atom(V) when is_atom(V)->
V.
+terminate_linked(normal) ->
+ terminate_linked(shutdown);
+terminate_linked(Reason) ->
+ {links, Links} = process_info(self(), links),
+ [catch exit(Pid, Reason) || Pid <- Links],
+ ok.
+
+
new_uuid() ->
list_to_binary(to_hex(crypto:rand_bytes(16))).
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index bac9f635..b74fb47d 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -226,7 +226,9 @@ init([]) ->
process_flag(trap_exit, true),
{ok, #server{root_dir=RootDir}}.
-terminate(_Reason,_State) ->
+
+terminate(Reason, _Srv) ->
+ couch_util:terminate_linked(Reason),
ok.
diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl
index e44d637c..57ee97da 100644
--- a/src/couchdb/couch_view_group.erl
+++ b/src/couchdb/couch_view_group.erl
@@ -272,6 +272,7 @@ handle_info({'DOWN',_,_,_,_}, State) ->
terminate(Reason, State) ->
reply_all(State, Reason),
+ couch_util:terminate_linked(Reason),
ok.
code_change(_OldVsn, State, _Extra) ->