aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-03-02 13:03:36 -0500
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-03-02 13:03:36 -0500
commitac2a3d11382d8d97975b9b10ae4c148ef9ae3a5c (patch)
tree80c57d48d238fa2eb1837c8aec30ab9c52ff49fd /src
parent42c78117ef020ac51c410fe4383160df15ac62a6 (diff)
downloadmysqlerl-ac2a3d11382d8d97975b9b10ae4c148ef9ae3a5c.tar.gz
mysqlerl-ac2a3d11382d8d97975b9b10ae4c148ef9ae3a5c.zip
Add process owner to state, to allow odbc compatibility.
Diffstat (limited to 'src')
-rw-r--r--src/mysqlerl_connection.erl12
-rw-r--r--src/mysqlerl_connection_sup.erl2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/mysqlerl_connection.erl b/src/mysqlerl_connection.erl
index babb109..4341aaa 100644
--- a/src/mysqlerl_connection.erl
+++ b/src/mysqlerl_connection.erl
@@ -5,28 +5,28 @@
-behavior(gen_server).
--export([start_link/6, stop/1]).
+-export([start_link/7, stop/1]).
-export([init/1, terminate/2, code_change/3,
handle_call/3, handle_cast/2, handle_info/2]).
--record(state, {ref}).
+-record(state, {ref, owner}).
-record(port_closed, {reason}).
-start_link(Host, Port, Database, User, Password, Options) ->
- gen_server:start_link(?MODULE, [Host, Port, Database,
+start_link(Owner, Host, Port, Database, User, Password, Options) ->
+ gen_server:start_link(?MODULE, [Owner, Host, Port, Database,
User, Password, Options], []).
stop(Pid) ->
gen_server:cast(Pid, stop).
-init([Host, Port, Database, User, Password, Options]) ->
+init([Owner, Host, Port, Database, User, Password, Options]) ->
process_flag(trap_exit, true),
Cmd = lists:flatten(io_lib:format("~s ~s ~w ~s ~s ~s ~s",
[helper(), Host, Port, Database,
User, Password, Options])),
Ref = open_port({spawn, Cmd}, [{packet, 4}, binary]),
- {ok, #state{ref = Ref}}.
+ {ok, #state{ref = Ref, owner = Owner}}.
terminate(#port_closed{reason = Reason}, #state{ref = Ref}) ->
io:format("DEBUG: mysqlerl connection ~p shutting down (~p).~n",
diff --git a/src/mysqlerl_connection_sup.erl b/src/mysqlerl_connection_sup.erl
index fd805d3..30b9537 100644
--- a/src/mysqlerl_connection_sup.erl
+++ b/src/mysqlerl_connection_sup.erl
@@ -11,7 +11,7 @@ start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
connect(Host, Port, Database, User, Password, Options) ->
- supervisor:start_child(?MODULE, [Host, Port, Database,
+ supervisor:start_child(?MODULE, [self(), Host, Port, Database,
User, Password, Options]).
random_child() ->