Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trigger reconnection when socket broken #38

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mysql_recv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%%% Note : All MySQL code was written by Magnus Ahltorp, originally
%%% in the file mysql.erl - I just moved it here.
%%%
%%% Copyright (c) 2001-2004 Kungliga Tekniska H�gskolan
%%% Copyright (c) 2001-2004 Kungliga Tekniska Högskolan
%%% See the file COPYING
%%%
%%% Signals this receiver process can send to it's parent
Expand Down Expand Up @@ -75,6 +75,7 @@ start_link(Host, Port, LogFun, Parent) when is_list(Host), is_integer(Port) ->
spawn_link(fun () ->
init(Host, Port, LogFun, Parent)
end),
erlang:monitor(process, RecvPid),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I suggested in #37, I would move this call to mysql_conn:

    case mysql_recv:start_link(Host, Port, LogFun, self()) of
	{ok, RecvPid, Sock} ->
	    erlang:monitor(process, RecvPid), % <-- here
	    case mysql_init(Sock, RecvPid, User, Password, LogFun, FoundRows) of

Other than that suggestion, your change looks good to me.

%% wait for the socket from the spawned pid
receive
{mysql_recv, RecvPid, init, {error, E}} ->
Expand Down