mike2m / erlang-mysql-driver

Automatically exported from code.google.com/p/erlang-mysql-driver
Other
0 stars 0 forks source link

mysql connection leak on error #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I was playing with the driver and noticed when the main mysql module timed
out during a connection the main process would exit with an error but the
mysql_conn process stayed around and held the mysql connection open... the
following seems to fix it

Index: src/mysql_conn.erl
===================================================================
--- src/mysql_conn.erl  (revision 27)
+++ src/mysql_conn.erl  (working copy)
@@ -145,7 +145,7 @@
 %%--------------------------------------------------------------------
 start(Host, Port, User, Password, Database, LogFun, PoolId) ->
     ConnPid = self(),
-    Pid = spawn(fun () ->
+    Pid = spawn_link(fun () ->
                        init(Host, Port, User, Password, Database,
                             LogFun, PoolId, ConnPid)
                end),
Index: src/mysql.erl
===================================================================
--- src/mysql.erl       (revision 27)
+++ src/mysql.erl       (working copy)
@@ -679,7 +679,7 @@
     end.

 start_reconnect(Conn, LogFun) ->
-    Pid = spawn(fun () ->
+    Pid = spawn_link(fun () ->
                        reconnect_loop(Conn#conn{pid = undefined}, LogFun, 0)
                end),
     {PoolId, Host, Port} = {Conn#conn.pool_id, Conn#conn.host,
Conn#conn.port},

Original issue reported on code.google.com by jla...@gmail.com on 27 Oct 2006 at 10:00

GoogleCodeExporter commented 8 years ago
If this solve the problem and it does look like it, who should add it in the 
repo?

Original comment by JLdeBr...@gmail.com on 19 Jan 2011 at 8:38