summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_util.erl
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2009-04-10 02:21:37 +0000
committerDamien F. Katz <damien@apache.org>2009-04-10 02:21:37 +0000
commit1df631f8653fefdda8d852b39f4ca9aec46f69da (patch)
treeb689897a497fed4599a68d96322023a4782573a2 /src/couchdb/couch_util.erl
parent7db96420155d3fe6b6d8b5eaa10660a65d19b8cc (diff)
Fixes for leaked file handles, with test.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@763858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_util.erl')
-rw-r--r--src/couchdb/couch_util.erl10
1 files changed, 9 insertions, 1 deletions
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))).