summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Joseph Davis <davisp@apache.org>2009-06-09 00:56:34 +0000
committerPaul Joseph Davis <davisp@apache.org>2009-06-09 00:56:34 +0000
commitd6946dc120a7eaf0897e2149317a2ead477af297 (patch)
treeb253a9c85748e7c1434c097a2f4b3223e76ba305
parentd4ac5c5083a310c16ac1754e3dbc3fafe8c5eb66 (diff)
Fixes COUCHDB-372
New couchspawnkillable requires update notifiers to expect a line of input to be read back. Undeleting the couch_os_process:write/2 method that got ixnayed. Now named send/2 and uses a gen_server:cast/2 to make it more apparent on what's going on. Thanks rnewson. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@782854 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--THANKS1
-rw-r--r--src/couchdb/couch_db_update_notifier.erl4
-rw-r--r--src/couchdb/couch_os_process.erl15
3 files changed, 17 insertions, 3 deletions
diff --git a/THANKS b/THANKS
index 3e082539..7e57a00a 100644
--- a/THANKS
+++ b/THANKS
@@ -29,5 +29,6 @@ suggesting improvements or submitting changes. Some of these people are:
* Brian Candler <B.Candler@pobox.com>
* Brad Anderson <brad@sankatygroup.com>
* Nick Gerakines <nick@gerakines.net>
+ * Robert Newson <robert.newson@gmail.com>
For a list of authors see the `AUTHORS` file.
diff --git a/src/couchdb/couch_db_update_notifier.erl b/src/couchdb/couch_db_update_notifier.erl
index a1019556..f21ce057 100644
--- a/src/couchdb/couch_db_update_notifier.erl
+++ b/src/couchdb/couch_db_update_notifier.erl
@@ -37,7 +37,7 @@ stop(Pid) ->
couch_event_sup:stop(Pid).
init(Exec) when is_list(Exec) -> % an exe
- couch_os_process:start_link(Exec, [], [stream, exit_status, hide]);
+ couch_os_process:start_link(Exec, []);
init(Else) ->
{ok, Else}.
@@ -55,7 +55,7 @@ handle_event(Event, {Fun, FunAcc}) ->
{ok, {Fun, FunAcc2}};
handle_event({EventAtom, DbName}, Pid) ->
Obj = {[{type, list_to_binary(atom_to_list(EventAtom))}, {db, DbName}]},
- true = couch_os_process:write(Pid, Obj),
+ ok = couch_os_process:send(Pid, Obj),
{ok, Pid}.
handle_call(_Request, State) ->
diff --git a/src/couchdb/couch_os_process.erl b/src/couchdb/couch_os_process.erl
index 75937eb8..66853b65 100644
--- a/src/couchdb/couch_os_process.erl
+++ b/src/couchdb/couch_os_process.erl
@@ -15,7 +15,7 @@
-export([start_link/1, start_link/2, start_link/3, stop/1]).
-export([set_timeout/2, prompt/2]).
--export([writeline/2, readline/1, writejson/2, readjson/1]).
+-export([send/2, writeline/2, readline/1, writejson/2, readjson/1]).
-export([init/1, terminate/2, handle_call/3, handle_cast/2, handle_info/2, code_change/3]).
-include("couch_db.hrl").
@@ -44,6 +44,10 @@ stop(Pid) ->
set_timeout(Pid, TimeOut) when is_integer(TimeOut) ->
ok = gen_server:call(Pid, {set_timeout, TimeOut}).
+% Used by couch_db_update_notifier.erl
+send(Pid, Data) ->
+ gen_server:cast(Pid, {send, Data}).
+
prompt(Pid, Data) ->
case gen_server:call(Pid, {prompt, Data}, infinity) of
{ok, Result} ->
@@ -148,6 +152,15 @@ handle_call({prompt, Data}, _From, OsProc) ->
{stop, normal, OsError, OsProc}
end.
+handle_cast({send, Data}, #os_proc{writer=Writer}=OsProc) ->
+ try
+ Writer(OsProc, Data),
+ {noreply, OsProc}
+ catch
+ throw:OsError ->
+ ?LOG_ERROR("Failed sending data: ~p -> ~p", [Data, OsError]),
+ {stop, normal, OsProc}
+ end;
handle_cast(stop, OsProc) ->
{stop, normal, OsProc};
handle_cast(Msg, OsProc) ->