diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-03-04 03:10:19 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-03-04 03:10:19 +0000 |
commit | d318717866ffa267781ab482e99a05415e2ac0e4 (patch) | |
tree | 207409d78eacca8e206deb05b99689ec449722a4 /src/couchdb/couch_util.erl | |
parent | 3a3a9c1efab1c9fe4cd5ebb6c80da4005eb0806b (diff) |
reverting damien's latest commit until we can figure out why it's causing failures
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@918834 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_util.erl')
-rw-r--r-- | src/couchdb/couch_util.erl | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index a9831fde..ca36a6db 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -12,7 +12,7 @@ -module(couch_util). --export([priv_dir/0, start_driver/1]). +-export([priv_dir/0, start_driver/1,terminate_linked/1]). -export([should_flush/0, should_flush/1, to_existing_atom/1]). -export([rand32/0, implode/2, collate/2, collate/3]). -export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]). @@ -21,7 +21,7 @@ -export([file_read_size/1, get_nested_json_value/2, json_user_ctx/1]). -export([to_binary/1, to_integer/1, to_list/1, url_encode/1]). -export([json_encode/1, json_decode/1]). --export([verify/2,simple_call/2,shutdown_sync/1]). +-export([verify/2]). -export([compressible_att_type/1]). -include("couch_db.hrl"). @@ -59,35 +59,14 @@ to_existing_atom(V) when is_binary(V) -> to_existing_atom(V) when is_atom(V) -> V. -shutdown_sync(Pid) when not is_pid(Pid)-> - ok; -shutdown_sync(Pid) -> - MRef = erlang:monitor(process, Pid), - try - catch unlink(Pid), - catch exit(Pid, shutdown), - receive - {'DOWN', MRef, _, _, _} -> - ok - end - after - erlang:demonitor(MRef, [flush]) - end. - -simple_call(Pid, Message) -> - MRef = erlang:monitor(process, Pid), - try - Pid ! {self(), Message}, - receive - {Pid, Result} -> - Result; - {'DOWN', MRef, _, _, Reason} -> - exit(Reason) - end - after - erlang:demonitor(MRef, [flush]) - end. +terminate_linked(normal) -> + terminate_linked(shutdown); +terminate_linked(Reason) -> + {links, Links} = process_info(self(), links), + [catch exit(Pid, Reason) || Pid <- Links], + ok. + to_hex([]) -> []; |