[tpop3d-discuss][PATCH]: mysql and reconnection

Arkadiusz Miskiewicz arekm at pld-linux.org
Thu, 14 Dec 2006 16:03:11 +0100


The problem is that reconnect behaviour is different for
libmysqclient < 5.0.3 (reconnect is ON by default)
and for libmysqclient >=3D 5.0.3 (reconnect is OFF by default)

What is desired behaviour? mysql_ping() can do reconnection.
IMO it should be defined explictly and probably should be off
because there is already manual reconnection routine few lines
below mysql_ping().

Index: auth_mysql.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/chris/vcvs/repos/tpop3d/auth_mysql.c,v
retrieving revision 1.56
diff -u -u -r1.56 auth_mysql.c
=2D-- auth_mysql.c	19 Aug 2004 23:57:05 -0000	1.56
+++ auth_mysql.c	14 Dec 2006 14:47:11 -0000
@@ -85,6 +85,7 @@
     static MYSQL mysql_handle;
     char *password;
     unsigned int timeout;
+    my_bool want_reconnect =3D 0;
=20
     if (mysql && mysql_ping(mysql) =3D=3D 0)
         /* The current server is up and running. */
@@ -113,6 +114,9 @@
         timeout =3D 5;
         mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&(timeout));
=20
+	/* We don't want automatic reconnect to happen. */
+	mysql_options(mysql, MYSQL_OPT_RECONNECT, &want_reconnect);
+
         if (mysql_real_connect(mysql, mysql_servers->toks[n],
                 config_get_string("auth-mysql-username"),
                 password,


=2D-=20
Arkadiusz Mi=B6kiewicz        PLD/Linux Team
arekm / maven.pl            http://ftp.pld-linux.org/