Only call mysql_library_end() once when using MariaDB

MariaDB allows only a single call to mysql_library_end(), all subsequent calls
to mysql_library_init() or any other API call will fail. Since QMYSQLDriver
calls mysql_library_end() function whenever the refcount drops to 0, this
breaks applications that close and reopen database connections.

This change registers call to mysql_library_init() via qAddPostRoutine()
when compiled against MariaDB, so that we only call it once.

Task-number: QTBUG-63108
Change-Id: I22c1f0c5b081216f12596a32748dca25cae919e9
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Daniel Vrátil 2017-09-18 22:33:55 +02:00
parent 64ab7489b3
commit d253464172

View File

@ -1158,16 +1158,22 @@ static void qLibraryInit()
} }
# endif // MYSQL_VERSION_ID # endif // MYSQL_VERSION_ID
#endif // Q_NO_MYSQL_EMBEDDED #endif // Q_NO_MYSQL_EMBEDDED
#ifdef MARIADB_BASE_VERSION
qAddPostRoutine(mysql_server_end);
#endif
} }
static void qLibraryEnd() static void qLibraryEnd()
{ {
#ifndef Q_NO_MYSQL_EMBEDDED #if !defined(MARIADB_BASE_VERSION)
# if MYSQL_VERSION_ID > 40000 # if !defined(Q_NO_MYSQL_EMBEDDED)
# if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003 # if MYSQL_VERSION_ID > 40000
mysql_library_end(); # if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003
# else mysql_library_end();
mysql_server_end(); # else
mysql_server_end();
# endif
# endif # endif
# endif # endif
#endif #endif