-
Notifications
You must be signed in to change notification settings - Fork 105
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
base: main
Are you sure you want to change the base?
Conversation
This commit can fix the problem that old codes do not trigger reconnection when socket broken.The new codes can trigger reconnection when socket broken occur.
Last solution is a wrong answer.The right answer is to add "erlang:monitor(process, RecvPid)," in mysql_recv.erl:73,after spawn_link()。 This commit can fix the problem that old codes do not trigger reconnection when socket broken.The new codes can trigger reconnection when socket broken occur.
@@ -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), |
There was a problem hiding this comment.
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.
This pull request fixes an insidious bug in erlang-mysql-driver's closed-connection handling. I've written a longer description of the problem and why the fix works, which can perhaps be used as the commit message: Fix handling of closed mysql socket. mysql_recv sends mysql_conn a Furthermore, although mysql_conn is linked to mysql_recv, when Finally, the mysql gen_server only removes the mysql socket from the This code change fixes the problem because it causes the mysql_conn This code change also has the advantage over having mysql_recv just |
This commit can fix the problem that old codes do not trigger reconnection when socket broken.The new codes can trigger reconnection when socket broken occur.