[Amarok] Check to make sure mysql server hasn't gone away b
Peter C. Ndikuwera
pndiku at gmail.com
Sun Oct 4 13:36:24 UTC 2009
This patch breaks my amarok. I'm using the MySQL server
See attached crash dump.
When I comment out the block with mysql_ping in it, I run fine.
On 02/10/2009, Jeff Mitchell <mitchell at kde.org> wrote:
> commit 2e9f34c290830fda8013c235e7faecd68eb08e03
> Author: Jeff Mitchell <mitchell at kde.org>
> AuthorDate: Fri Oct 2 11:50:55 2009 -0400
> Commit: Jeff Mitchell <mitchell at kde.org>
> CommitDate: Fri Oct 2 11:50:55 2009 -0400
>
> Check to make sure mysql server hasn't gone away before making queries,
> and reconnect if so.
>
> diff --git a/ChangeLog b/ChangeLog
> index 2dccb38..3a1434f 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -34,6 +34,9 @@ VERSION 2.2.1
> the lyrics applet.
>
> BUGFIXES:
> + * When using a MySQL server, very long periods of idle Amarok could
> allow
> + the server to close the local connection. This is now detected and
> + should be worked around.
> * Correctly set the lyrics applet's title when displaying HTML
> formatted lyrics
> * Track selection is now correctly preserved when using Dynamic
> Playlists.
> Patch by John Atkinson <john at fauxnetic.co.uk>. (BR 208349)
> diff --git a/src/collection/mysqlservercollection/MySqlServerCollection.cpp
> b/src/collection/mysqlservercollection/MySqlServerCollection.cpp
> index fe7a036..2abcc50 100644
> --- a/src/collection/mysqlservercollection/MySqlServerCollection.cpp
> +++ b/src/collection/mysqlservercollection/MySqlServerCollection.cpp
> @@ -75,6 +75,12 @@ MySqlServerCollection::MySqlServerCollection( const
> QString &id, const QString &
> }
> else
> {
> + my_bool reconnect = true;
> + if( mysql_options( m_db, MYSQL_OPT_RECONNECT, &reconnect ) )
> + reportError( "Asking for automatic reconnect did not succeed!"
> );
> + else
> + debug() << "Automatic reconnect successfully activated";
> +
> QString databaseName = Amarok::config( "MySQL" ).readEntry(
> "Database", "amarokdb" );
> if( mysql_query( m_db, QString( "SET NAMES 'utf8'" ).toUtf8() ) )
> reportError( "SET NAMES 'utf8' died" );
> @@ -103,5 +109,31 @@ MySqlServerCollection::type() const
> return "MySQL";
> }
>
> +QStringList
> +MySqlServerCollection::query( const QString &query )
> +{
> + unsigned long tid = mysql_thread_id( m_db );
> +
> + int res = mysql_ping( m_db );
> + if( res )
> + {
> + reportError( "mysql_ping failed!" );
> + return QStringList();
> + }
> +
> + if( tid != mysql_thread_id( m_db ) )
> + {
> + debug() << "NOTE: MySQL server had gone away, ping reconnected it";
> + QString databaseName = Amarok::config( "MySQL" ).readEntry(
> "Database", "amarokdb" );
> + if( mysql_query( m_db, QString( "SET NAMES 'utf8'" ).toUtf8() ) )
> + reportError( "SET NAMES 'utf8' died" );
> + if( mysql_query( m_db, QString( "USE %1" ).arg( databaseName
> ).toUtf8() ) )
> + reportError( "Could not select database" );
> + }
> +
> +
> + return MySqlCollection::query( query );
> +}
> +
> #include "MySqlServerCollection.moc"
>
> diff --git a/src/collection/mysqlservercollection/MySqlServerCollection.h
> b/src/collection/mysqlservercollection/MySqlServerCollection.h
> index 99acb25..e70eb37 100644
> --- a/src/collection/mysqlservercollection/MySqlServerCollection.h
> +++ b/src/collection/mysqlservercollection/MySqlServerCollection.h
> @@ -45,6 +45,7 @@ class MySqlServerCollection: public MySqlCollection
> virtual ~MySqlServerCollection();
>
> virtual QString type() const;
> + virtual QStringList query( const QString &query );
> };
>
> #endif
>
>
>
--
"Happiness makes up in height what it lacks in length"
-- Robert Frost
-------------- next part --------------
A non-text attachment was scrubbed...
Name: amarok-20091004.kcrash
Type: application/octet-stream
Size: 9876 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/amarok/attachments/20091004/de0e8802/attachment.obj>
More information about the Amarok
mailing list