https://redmine.lighttpd.net/https://redmine.lighttpd.net/favicon.ico?13667327412007-01-03T17:27:42Zlighty labsLighttpd - Bug #518: mysqld disconnects and mod doesn't auto-reconnecthttps://redmine.lighttpd.net/issues/518?journal_id=13102007-01-03T17:27:42ZAnonymous
<ul></ul><p>Maybe this could be a solution...</p>
<p>From the MySQL API manual:<br />"Note that upon connection, mysql_real_connect() sets the reconnect flag (part of the MYSQL structure) to a value of 1 in versions of the API older than 5.0.3, or 0 in newer versions. A value of 1 for this flag indicates that if a statement cannot be performed because of a lost connection, to try reconnecting to the server before giving up. As of MySQL 5.0.13, you can use the MYSQL_OPT_RECONNECT option to mysql_options() to control reconnection behavior."</p>
<p>I have tested to do this right before mysql_real_connect() in mod_mysql_vhost.c (somewhere around row 255, 1.4.13). It seems to works for me.</p>
<p>my_bool reconnect = 1;</p>
<p>mysql_options(s->mysql, MYSQL_OPT_RECONNECT, &reconnect);</p>
<p>Probably there must be some code to recognize which version of the MySQL library that is in use.</p>
<p>-- patrik</p> Lighttpd - Bug #518: mysqld disconnects and mod doesn't auto-reconnecthttps://redmine.lighttpd.net/issues/518?journal_id=13112007-05-02T17:01:30ZAnonymous
<ul></ul><p>Replying to <a class="wiki-page new" href="https://redmine.lighttpd.net/projects/lighttpd/wiki/Comment1"><a class="email" href="mailto:patrik@medieteknik.se">patrik@medieteknik.se</a></a>:</p>
<blockquote>
<p>I have tested to do this right before mysql_real_connect() in mod_mysql_vhost.c<br />(somewhere around row 255, 1.4.13). It seems to works for me.</p>
</blockquote>
<p>Thanks Patrik, based on your description I created a .diff. Compile tested for now, hopefully works as well as you said:</p>
<pre>
--- lighttpd-1.4.x/src/mod_mysql_vhost.c.ORIG 2007-05-02 17:50:58.000000000 +0100
+++ lighttpd-1.4.x/src/mod_mysql_vhost.c 2007-05-02 17:52:50.000000000 +0100
@@ -256,2 +256,6 @@ SERVER_FUNC(mod_mysql_vhost_set_defaults
+ /* http://trac.lighttpd.net/trac/ticket/518 */
+ my_bool reconnect = 1;
+ mysql_options(s->mysql, MYSQL_OPT_RECONNECT, &reconnect);
+
if (!mysql_real_connect(s->mysql, FOO(hostname), FOO(myuser), FOO(mypass),
</pre>
<p>-- lists</p> Lighttpd - Bug #518: mysqld disconnects and mod doesn't auto-reconnecthttps://redmine.lighttpd.net/issues/518?journal_id=13122007-05-21T09:09:09ZAnonymous
<ul></ul><p>Hi darix,</p>
<p>the patch works great (we talked in irc). please don't forget to commit it ;)</p>
<p>-- sr</p> Lighttpd - Bug #518: mysqld disconnects and mod doesn't auto-reconnecthttps://redmine.lighttpd.net/issues/518?journal_id=13132007-08-17T06:41:05Zglen
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Fixed</i></li><li><strong>Resolution</strong> set to <i>fixed</i></li></ul><p>applied in r1920 and r1919.</p>